restrict open application multiple times
This commit is contained in:
parent
543385d0fa
commit
853997bfd5
|
@ -21,7 +21,7 @@
|
|||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
*.log*
|
||||
*.log
|
||||
|
||||
package-lock*
|
||||
|
||||
|
|
2
INSTALL
2
INSTALL
|
@ -32,6 +32,8 @@ The following packages must be installed using PIP
|
|||
pip3 install orjson
|
||||
pip3 install escpos
|
||||
pip3 install PySide6
|
||||
pip3 install psutil
|
||||
pip3 install setproctitle
|
||||
|
||||
|
||||
For Windows add:
|
||||
|
|
|
@ -34,6 +34,8 @@ Los siguientes paquetes se deben instalar usando PIP
|
|||
pip3 install orjson
|
||||
pip3 install escpos
|
||||
pip3 install PySide6
|
||||
pip3 install psutil
|
||||
pip3 install setproctitle
|
||||
|
||||
|
||||
Tener en cuenta que algunos paquetes se deben instalar con pip para python3.
|
||||
|
|
31
pospro
31
pospro
|
@ -3,10 +3,14 @@
|
|||
import os
|
||||
import sys
|
||||
import argparse
|
||||
from PySide6.QtWidgets import QApplication
|
||||
import setproctitle
|
||||
import psutil
|
||||
from PySide6.QtCore import Qt, QCoreApplication
|
||||
from PySide6.QtWidgets import QApplication, QMessageBox
|
||||
# from PyQt5.QtWidgets import QApplication
|
||||
from app.commons.dblogin import Login
|
||||
from app import main
|
||||
from logger_config import logger
|
||||
|
||||
parser = argparse.ArgumentParser(description='Process some integers.')
|
||||
parser.add_argument('-o', metavar="theme", help='execute argument')
|
||||
|
@ -20,15 +24,38 @@ try:
|
|||
except NameError:
|
||||
pass
|
||||
|
||||
PROCESS_NAME = "app_presik_pos"
|
||||
|
||||
|
||||
class SingleInstanceApp(QApplication):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
for process in psutil.process_iter(['pid', 'name']):
|
||||
if process.info['name'] == PROCESS_NAME:
|
||||
logger.error('La aplicación ya esta en ejecución')
|
||||
self.show_already_running_dialog()
|
||||
sys.exit(1)
|
||||
|
||||
def show_already_running_dialog(self):
|
||||
msg = QMessageBox()
|
||||
msg.setIcon(QMessageBox.Warning)
|
||||
msg.setText("La aplicación ya está en ejecución.")
|
||||
msg.setWindowTitle("Aplicación en ejecución")
|
||||
msg.setStandardButtons(QMessageBox.Ok)
|
||||
msg.exec()
|
||||
|
||||
|
||||
class Client(object):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
self.app = QApplication(sys.argv)
|
||||
# self.app = QApplication(sys.argv)
|
||||
self.app = SingleInstanceApp(sys.argv)
|
||||
self.app.setOrganizationName("PRESIK SAS")
|
||||
self.app.setOrganizationDomain("presik.com")
|
||||
self.app.setApplicationName("SMART POS")
|
||||
self.app.setStyle("fusion")
|
||||
setproctitle.setproctitle(PROCESS_NAME)
|
||||
|
||||
def init_login(self):
|
||||
_file_config = 'config_pos.ini'
|
||||
|
|
Loading…
Reference in New Issue