54 lines
1.4 KiB
Python
54 lines
1.4 KiB
Python
|
#!/usr/bin/env python3
|
||
|
# -*- coding: UTF-8 -*-
|
||
|
import os
|
||
|
import sys
|
||
|
|
||
|
from PyQt5.QtWidgets import QApplication, QStyleFactory
|
||
|
from PyQt5.QtCore import QTranslator
|
||
|
|
||
|
from neox.commons.dblogin import Login
|
||
|
from app import mainwindow
|
||
|
|
||
|
try:
|
||
|
DIR = os.path.abspath(os.path.normpath(os.path.join(__file__,
|
||
|
'..', '..', '..')))
|
||
|
if os.path.isdir(DIR):
|
||
|
sys.path.insert(0, os.path.dirname(DIR))
|
||
|
except NameError:
|
||
|
pass
|
||
|
|
||
|
|
||
|
class Client(object):
|
||
|
|
||
|
def __init__(self, parent=None):
|
||
|
self.app = QApplication(sys.argv)
|
||
|
path_trans = os.path.join(os.path.abspath(
|
||
|
os.path.dirname(__file__)), 'app', 'translations', 'i18n_es.qm')
|
||
|
self.translator = QTranslator()
|
||
|
self.translator.load(path_trans)
|
||
|
# This is to make Qt use locale configuration; i.e. Standard Buttons
|
||
|
# in your system's language.
|
||
|
self.app.installTranslator(self.translator)
|
||
|
self.app.setStyle(QStyleFactory.create('Fusion'))
|
||
|
|
||
|
def init_login(self):
|
||
|
login = Login(file_config='config_pos.ini')
|
||
|
|
||
|
while not login.connection:
|
||
|
login.run()
|
||
|
login.exec_()
|
||
|
|
||
|
return login.connection, login.params
|
||
|
|
||
|
def main(self, conn, params):
|
||
|
mw = mainwindow.MainWindow(conn, params)
|
||
|
self.app.exec_()
|
||
|
|
||
|
|
||
|
client = Client()
|
||
|
conn, params = client.init_login()
|
||
|
|
||
|
if conn:
|
||
|
client.main(conn, params)
|
||
|
sys.exit()
|