示例#1
0
 def setup_gui(self):
     """Sets up a sample gui interface."""
     central_widget = QWidget(self)
     central_widget.setObjectName('central_widget')
     self.label = QLabel('Hello World')
     self.input_field = QLineEdit()
     change_button = QPushButton('Change text')
     close_button = QPushButton('close')
     quit_button = QPushButton('quit')
     central_layout = QVBoxLayout()
     button_layout = QHBoxLayout()
     central_layout.addWidget(self.label)
     central_layout.addWidget(self.input_field)
     # a separate layout to display buttons horizontal
     button_layout.addWidget(change_button)
     button_layout.addWidget(close_button)
     button_layout.addWidget(quit_button)
     central_layout.addLayout(button_layout)
     central_widget.setLayout(central_layout)
     self.setCentralWidget(central_widget)
     # create a system tray icon. Uncomment the second form, to have an
     # icon assigned, otherwise you will only be seeing an empty space in
     # system tray
     self.systemtrayicon = QSystemTrayIcon(self)
     self.systemtrayicon.show()
     # set a fancy icon
     self.systemtrayicon.setIcon(QIcon.fromTheme('help-browser'))
     change_button.clicked.connect(self.change_text)
     quit_button.clicked.connect(QApplication.instance().quit)
     close_button.clicked.connect(self.hide)
     # show main window, if the system tray icon was clicked
     self.systemtrayicon.activated.connect(self.icon_activated)
 def setup_gui(self):
     """Sets up a sample gui interface."""
     central_widget = QWidget(self)
     central_widget.setObjectName('central_widget')
     self.label = QLabel('Hello World')
     self.input_field = QLineEdit()
     change_button = QPushButton('Change text')
     close_button = QPushButton('close')
     quit_button = QPushButton('quit')
     central_layout = QVBoxLayout()
     button_layout = QHBoxLayout()
     central_layout.addWidget(self.label)
     central_layout.addWidget(self.input_field)
     # a separate layout to display buttons horizontal
     button_layout.addWidget(change_button)
     button_layout.addWidget(close_button)
     button_layout.addWidget(quit_button)
     central_layout.addLayout(button_layout)
     central_widget.setLayout(central_layout)
     self.setCentralWidget(central_widget)
     # create a system tray icon. Uncomment the second form, to have an
     # icon assigned, otherwise you will only be seeing an empty space in
     # system tray
     self.systemtrayicon = QSystemTrayIcon(self)
     self.systemtrayicon.show()
     # set a fancy icon
     self.systemtrayicon.setIcon(QIcon.fromTheme('help-browser'))
     change_button.clicked.connect(self.change_text)
     quit_button.clicked.connect(QApplication.instance().quit)
     close_button.clicked.connect(self.hide)
     # show main window, if the system tray icon was clicked
     self.systemtrayicon.activated.connect(self.icon_activated)
示例#3
0
class addawrd(QDialog):
	def __init__(self, parent=None):
		super(addawrd, self).__init__(parent)
		appicom = QIcon(":/icons/njnlogo.png")
		self.setWindowIcon(appicom)
		self.setWindowTitle("Nigandu | Add a word")
		self.setFixedSize(364, 188)

		self.horizontalLayoutWidget = QWidget(self)
		self.horizontalLayoutWidget.setGeometry(QRect(10, 10, 341, 61))
		self.horizontalLayoutWidget.setObjectName("horizontalLayoutWidget")

		self.horizontalLayout = QHBoxLayout(self.horizontalLayoutWidget)
		self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
		self.horizontalLayout.setObjectName("horizontalLayout")

		self.label = QLabel(self.horizontalLayoutWidget)
		self.label.setMinimumSize(QSize(70, 25))
		self.horizontalLayout.addWidget(self.label)
		self.label.setText("English Word:")

		self.lineEdit = QLineEdit(self.horizontalLayoutWidget)
		self.lineEdit.setEnabled(True)
		self.lineEdit.setMinimumSize(QSize(0, 25))
		self.lineEdit.setObjectName("lineEdit_2")
		self.horizontalLayout.addWidget(self.lineEdit)
		self.lineEdit.setFocus()

		self.buttonBox = QDialogButtonBox(self)
		self.buttonBox.setGeometry(QRect(10, 150, 341, 25))
		self.buttonBox.setMinimumSize(QSize(70, 25))
		self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Save)
		self.buttonBox.setObjectName("buttonBox")

		self.horizontalLayoutWidget_2 = QWidget(self)
		self.horizontalLayoutWidget_2.setGeometry(QRect(10, 80, 341, 61))
		self.horizontalLayoutWidget_2.setObjectName("horizontalLayoutWidget_2")
		self.horizontalLayout_2 = QHBoxLayout(self.horizontalLayoutWidget_2)
		self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0)
		self.horizontalLayout_2.setObjectName("horizontalLayout_2")

		self.label_2 = QLabel(self.horizontalLayoutWidget_2)
		self.label_2.setMinimumSize(QSize(70, 25))
		self.label_2.setObjectName("label_2")
		self.horizontalLayout_2.addWidget(self.label_2)
		self.label_2.setText("Tamil Word:")

		self.lineEdit_2 = QLineEdit(self.horizontalLayoutWidget_2)
		self.lineEdit_2.setMinimumSize(QSize(0, 25))
		self.lineEdit_2.setObjectName("lineEdit_3")
		self.horizontalLayout_2.addWidget(self.lineEdit_2)

		self.setTabOrder(self.lineEdit, self.lineEdit_2)
		self.setTabOrder(self.lineEdit_2, self.buttonBox)
示例#4
0
文件: menu.py 项目: tinavas/FSERP
class Menu():
    """Menu management main container"""
    def __init__(self):
        ####
        self.menu_tab_4 = QWidget()
        self.menu_tab_4.setStyleSheet("")
        self.menu_tab_4.setObjectName("menu_tab_4")
        self.horizontalLayout_7 = QHBoxLayout(self.menu_tab_4)
        self.horizontalLayout_7.setObjectName("horizontalLayout_7")
        self.menu_detail_tabWidget = QTabWidget(self.menu_tab_4)
        self.menu_detail_tabWidget.setObjectName("menu_detail_tabWidget")
        self.weeklytabs = None
        self.add_tabs()
        self.horizontalLayout_7.addWidget(self.menu_detail_tabWidget)
        ####signals and slots && other stuffs
        # self.mainwindow = Ui_MainWindow  # just for the ease of finding the attributes in pycharm
        self.menu_detail_tabWidget.currentChanged.connect(self.change_focus)
        self.menu_tab_4.setFocusPolicy(Qt.StrongFocus)
        self.menu_tab_4.focusInEvent = self.change_focus


    def add_tabs(self):
        """
        :return: adds the tab
        """
        menu = MenuDetails()
        self.menu_detail_tabWidget.addTab(menu.menudetail_tab_1, "&Menu")
        self.weeklytabs = {}
        days = [('monday', 'Monday'),
                ('tuesday', 'Tuesday'),
                ('wednesday', 'Wednesday'),
                ('thursday', 'Thursday'),
                ('friday', 'Friday'),
                ('saturday', 'Saturday'),
                ('sunday', 'Sunday')]
        for n, i in enumerate(days):
            menu = MenuWeekday(day=i[0])
            index = n + 1
            self.weeklytabs[index] = menu
            self.menu_detail_tabWidget.addTab(menu.menudetail_tab_1, i[1])

    def change_focus(self, event=None):
        """
        focus event handler
        """
        wid = self.menu_detail_tabWidget.currentWidget()
        if wid.isVisible():
            wid.setFocus()
示例#5
0
class managebkm(QDialog):
	def __init__(self, parent=None):
		super(managebkm, self).__init__(parent)
		appicom = QIcon(":/icons/njnlogo.png")
		self.setWindowIcon(appicom)
		self.setWindowTitle("Nigandu | Manage Book Marks")
		self.setFixedSize(463, 242)

		self.verticalLayoutWidget = QWidget(self)
		self.verticalLayoutWidget.setGeometry(QRect(350, 30, 101, 201))
		self.verticalLayoutWidget.setObjectName("verticalLayoutWidget")
		self.verticalLayout = QVBoxLayout(self.verticalLayoutWidget)
		self.verticalLayout.setContentsMargins(0, 0, 0, 0)
		self.verticalLayout.setObjectName("verticalLayout")

		self.sortbtn = QPushButton(self.verticalLayoutWidget)
		self.sortbtn.setText("&Sort")
		self.verticalLayout.addWidget(self.sortbtn)

		self.deletebtn = QPushButton(self.verticalLayoutWidget)
		self.deletebtn.setText("&Delete")
		self.verticalLayout.addWidget(self.deletebtn)

		self.deleteallbtn = QPushButton(self.verticalLayoutWidget)
		self.deleteallbtn.setText("Delete &All")
		self.verticalLayout.addWidget(self.deleteallbtn)

		self.closebtn = QPushButton(self.verticalLayoutWidget)
		self.closebtn.setText("&Close")
		self.verticalLayout.addWidget(self.closebtn)

		self.listWidget = QListWidget(self)
		self.listWidget.setGeometry(QRect(10, 30, 331, 201))

		self.label = QLabel(self)
		self.label.setGeometry(QRect(20, 10, 91, 25))
		font = QFont()
		font.setPointSize(10)
		self.label.setFont(font)
		self.label.setBuddy(self.listWidget)
		self.label.setText("Book Mark List:")
示例#6
0
文件: report.py 项目: tinavas/FSERP
class Report():
    """
    The Basic Report Module Class
    """
    def __init__(self):
        ####
        self.report_tab_5 = QWidget()
        self.report_tab_5.setStyleSheet("")
        self.report_tab_5.setObjectName("report_tab_5")
        self.horizontalLayout_8 = QHBoxLayout(self.report_tab_5)
        self.horizontalLayout_8.setObjectName("horizontalLayout_8")
        self.report_detail_tabWidget = QTabWidget(self.report_tab_5)
        self.report_detail_tabWidget.setObjectName("report_detail_tabWidget")
        self.add_tabs()
        self.horizontalLayout_8.addWidget(self.report_detail_tabWidget)
        ###signals and slots && other stuffs
        # self.mainwindow = Ui_MainWindow  # just for the ease of finding the attributes in pycharm
        self.report_detail_tabWidget.currentChanged.connect(self.change_focus)
        self.report_tab_5.setFocusPolicy(Qt.StrongFocus)
        self.report_tab_5.focusInEvent = self.change_focus

    def add_tabs(self):
        """
        add new tabs to the table
        """
        employee = EmployeeNew()
        hygiene = Hygiene()
        report = Stock()
        self.report_detail_tabWidget.addTab(employee.employeedetail_tab_1,
                                            'Employee')
        self.report_detail_tabWidget.addTab(hygiene.reporthygiene_tab_2,
                                            'Hygiene')
        self.report_detail_tabWidget.addTab(report.stock_tab_1, 'Stock')

    def change_focus(self, event=None):
        """
        sets focus for the  child widgets
        """
        wid = self.report_detail_tabWidget.currentWidget()
        if wid.isVisible():
            wid.setFocus()
示例#7
0
文件: waste.py 项目: tinavas/FSERP
class Waste():
    """Waste management main container"""
    def __init__(self):
        ####
        self.waste_tab_6 = QWidget()
        self.waste_tab_6.setStyleSheet("")
        self.waste_tab_6.setObjectName("waste_tab_6")
        self.verticalLayout = QVBoxLayout(self.waste_tab_6)
        self.verticalLayout.setObjectName("verticalLayout")
        self.waste_detail_tabWidget = QTabWidget(self.waste_tab_6)
        self.waste_detail_tabWidget.setObjectName("waste_detail_tabWidget")
        self.add_tabs()
        self.verticalLayout.addWidget(self.waste_detail_tabWidget)

        ##signals and slotts && other stuffs
        # self.mainwindow = Ui_MainWindow  # just for the ease of finding the attributes in pycharm
        self.waste_detail_tabWidget.currentChanged.connect(self.change_focus)
        self.waste_tab_6.setFocusPolicy(Qt.StrongFocus)
        self.waste_tab_6.focusInEvent = self.change_focus

    def add_tabs(self):
        """
        :return: adds new tabs
        """
        dish = WasteDish()
        self.waste_detail_tabWidget.addTab(dish.wastedetail_tab_1,
                                           "Dish Waste")
        item = WasteItems()
        self.waste_detail_tabWidget.addTab(item.wastedetail_tab_1,
                                           "Item Waste")

    def change_focus(self, event=None):
        """captures focus to inititate the events for the coprresponding tab"""
        wid = self.waste_detail_tabWidget.currentWidget()
        if wid.isVisible():
            wid.setFocus()
示例#8
0
class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(598, 450)
        self.icon = QIcon(":/icons/uglytheme/48x48/polibeepsync.png")
        Form.setWindowIcon(self.icon)
        Form.setLocale(QLocale(QLocale.English, QLocale.UnitedStates))
        self.verticalLayout = QVBoxLayout(Form)
        self.verticalLayout.setObjectName("verticalLayout")

        self.tabWidget = QTabWidget(Form)
        self.tabWidget.setObjectName("tabWidget")

        # Tab General Settings
        self.tab = QWidget()
        self.tab.setObjectName("tab")
        self.horizontalLayout = QHBoxLayout(self.tab)
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.verticalLayout_2 = QVBoxLayout()
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        self.gridLayout = QGridLayout()
        self.gridLayout.setObjectName("gridLayout")
        self.label_2 = QLabel(self.tab)
        self.label_2.setObjectName("label_2")
        self.gridLayout.addWidget(self.label_2, 3, 0, 1, 1)
        self.label = QLabel(self.tab)
        self.label.setObjectName("label")
        self.gridLayout.addWidget(self.label, 1, 0, 1, 1)
        self.password = QLineEdit(self.tab)
        self.password.setMaximumSize(QSize(139, 16777215))
        self.password.setEchoMode(QLineEdit.Password)
        self.password.setObjectName("password")
        self.gridLayout.addWidget(self.password, 3, 1, 1, 1)
        self.userCode = QLineEdit(self.tab)
        self.userCode.setMaximumSize(QSize(139, 16777215))
        self.userCode.setText("")
        self.userCode.setObjectName("userCode")
        self.gridLayout.addWidget(self.userCode, 1, 1, 1, 1)
        spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                 QSizePolicy.Minimum)
        self.gridLayout.addItem(spacerItem, 1, 2, 1, 1)
        self.verticalLayout_2.addLayout(self.gridLayout)
        self.trylogin = QPushButton(self.tab)
        self.trylogin.setMaximumSize(QSize(154, 16777215))
        self.trylogin.setObjectName("trylogin")
        self.verticalLayout_2.addWidget(self.trylogin)
        self.login_attempt = QLabel(self.tab)
        self.login_attempt.setText("Logging in, please wait.")
        self.login_attempt.setStyleSheet("color: rgba(0, 0, 0, 0);")
        self.login_attempt.setObjectName("login_attempt")
        self.verticalLayout_2.addWidget(self.login_attempt)
        spacerItem1 = QSpacerItem(20, 40, QSizePolicy.Minimum,
                                  QSizePolicy.Expanding)
        self.verticalLayout_2.addItem(spacerItem1)
        self.horizontalLayout_3 = QHBoxLayout()
        self.horizontalLayout_3.setObjectName("horizontalLayout_3")
        self.label_4 = QLabel(self.tab)
        self.label_4.setObjectName("label_4")
        self.horizontalLayout_3.addWidget(self.label_4)
        self.rootfolder = QLineEdit(self.tab)
        self.rootfolder.setMinimumSize(QSize(335, 0))
        self.rootfolder.setMaximumSize(QSize(335, 16777215))
        self.rootfolder.setInputMask("")
        self.rootfolder.setReadOnly(True)
        self.rootfolder.setObjectName("rootfolder")
        self.horizontalLayout_3.addWidget(self.rootfolder)
        self.changeRootFolder = QPushButton(self.tab)
        self.changeRootFolder.setObjectName("changeRootFolder")
        self.horizontalLayout_3.addWidget(self.changeRootFolder)
        spacerItem2 = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                  QSizePolicy.Minimum)
        self.horizontalLayout_3.addItem(spacerItem2)
        self.verticalLayout_2.addLayout(self.horizontalLayout_3)
        self.horizontalLayout_5 = QHBoxLayout()
        self.horizontalLayout_5.setObjectName("horizontalLayout_5")
        self.label_5 = QLabel(self.tab)
        self.label_5.setObjectName("label_5")
        self.horizontalLayout_5.addWidget(self.label_5)
        self.timerMinutes = QSpinBox(self.tab)
        self.timerMinutes.setObjectName("timerMinutes")
        self.horizontalLayout_5.addWidget(self.timerMinutes)
        self.label_6 = QLabel(self.tab)
        self.label_6.setObjectName("label_6")
        self.horizontalLayout_5.addWidget(self.label_6)
        self.syncNow = QPushButton(self.tab)
        self.syncNow.setObjectName("syncNow")
        self.horizontalLayout_5.addWidget(self.syncNow)
        spacerItem3 = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                  QSizePolicy.Minimum)
        self.horizontalLayout_5.addItem(spacerItem3)
        self.verticalLayout_2.addLayout(self.horizontalLayout_5)
        self.addSyncNewCourses = QCheckBox(self.tab)
        self.addSyncNewCourses.setObjectName("addSyncNewCourses")
        self.verticalLayout_2.addWidget(self.addSyncNewCourses)
        self.horizontalLayout.addLayout(self.verticalLayout_2)
        self.tabWidget.addTab(self.tab, "")

        # Tab Courses
        self.tab_2 = QWidget()
        self.tab_2.setObjectName("tab_2")
        self.horizontalLayout_2 = QHBoxLayout(self.tab_2)
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.verticalLayout_3 = QVBoxLayout()
        self.verticalLayout_3.setObjectName("verticalLayout_3")
        self.horizontalLayout_6 = QHBoxLayout()
        self.horizontalLayout_6.setObjectName("horizontalLayout_6")
        self.refreshCourses = QPushButton(self.tab_2)
        self.refreshCourses.setObjectName("refreshCourses")
        self.horizontalLayout_6.addWidget(self.refreshCourses)
        spacerItem4 = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                  QSizePolicy.Minimum)
        self.horizontalLayout_6.addItem(spacerItem4)
        self.verticalLayout_3.addLayout(self.horizontalLayout_6)
        self.coursesView = CoursesListView(self.tab_2)
        self.coursesView.setObjectName("coursesView")
        self.verticalLayout_3.addWidget(self.coursesView)
        self.horizontalLayout_2.addLayout(self.verticalLayout_3)
        self.tabWidget.addTab(self.tab_2, "")

        # Tab Status
        self.tab_3 = QWidget()
        self.tab_3.setObjectName("tab_3")
        self.horizontalLayout_7 = QHBoxLayout(self.tab_3)
        self.horizontalLayout_7.setObjectName("horizontalLayout_7")
        self.verticalLayout_4 = QVBoxLayout()
        self.verticalLayout_4.setObjectName("verticalLayout_4")
        self.horizontalLayout_8 = QHBoxLayout()
        self.horizontalLayout_8.setObjectName("horizontalLayout_8")
        self.about = QPushButton(self.tab_3)
        self.about.setObjectName("about")
        self.horizontalLayout_8.addWidget(self.about)
        spacerItem5 = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                  QSizePolicy.Minimum)
        self.horizontalLayout_8.addItem(spacerItem5)
        self.verticalLayout_4.addLayout(self.horizontalLayout_8)
        self.status = QTextEdit(self.tab_3)
        self.status.setTextInteractionFlags(Qt.TextSelectableByKeyboard
                                            | Qt.TextSelectableByMouse)
        self.status.setObjectName("status")
        self.verticalLayout_4.addWidget(self.status)
        self.horizontalLayout_7.addLayout(self.verticalLayout_4)
        self.tabWidget.addTab(self.tab_3, "")

        self.tab_4 = QWidget()
        self.tab_4.setObjectName("tab_4")
        self.verticalLayout.addWidget(self.tabWidget)

        self.okButton = QDialogButtonBox(Form)
        self.okButton.setStandardButtons(QDialogButtonBox.Ok)
        self.okButton.setObjectName("okButton")
        self.okButton.clicked.connect(self.hide)
        self.verticalLayout.addWidget(self.okButton)

        self.statusLabel = QLabel(Form)
        self.statusLabel.setObjectName("statusLabel")
        self.verticalLayout.addWidget(self.statusLabel)

        self.retranslateUi(Form)
        self.tabWidget.setCurrentIndex(0)
        QMetaObject.connectSlotsByName(Form)

    def retranslateUi(self, Form):
        Form.setWindowTitle("poliBeePsync")
        if pysideVersion == '1.2.2':
            self.label_2.setText(
                QApplication.translate("Form", "Password", None,
                                       QApplication.UnicodeUTF8))
            self.label.setText(
                QApplication.translate("Form", "User code", None,
                                       QApplication.UnicodeUTF8))
            self.trylogin.setText(
                QApplication.translate("Form", "Try login credentials", None,
                                       QApplication.UnicodeUTF8))
            self.login_attempt.setText(
                QApplication.translate("Form", "Login successful", None,
                                       QApplication.UnicodeUTF8))
            self.label_4.setText(
                QApplication.translate("Form", "Root folder", None,
                                       QApplication.UnicodeUTF8))
            self.changeRootFolder.setText(
                QApplication.translate("Form", "Change", None,
                                       QApplication.UnicodeUTF8))
            self.label_5.setText(
                QApplication.translate("Form", "Sync every", None,
                                       QApplication.UnicodeUTF8))
            self.label_6.setText(
                QApplication.translate("Form", "minutes", None,
                                       QApplication.UnicodeUTF8))
            self.syncNow.setText(
                QApplication.translate("Form", "Sync now", None,
                                       QApplication.UnicodeUTF8))
            self.addSyncNewCourses.setText(
                QApplication.translate(
                    "Form", "Automatically add and sync new available courses",
                    None, QApplication.UnicodeUTF8))
            self.tabWidget.setTabText(
                self.tabWidget.indexOf(self.tab),
                QApplication.translate("Form", "General settings", None,
                                       QApplication.UnicodeUTF8))
            self.refreshCourses.setText(
                QApplication.translate("Form", "Refresh list", None,
                                       QApplication.UnicodeUTF8))
            self.tabWidget.setTabText(
                self.tabWidget.indexOf(self.tab_2),
                QApplication.translate("Form", "Courses", None,
                                       QApplication.UnicodeUTF8))
            self.about.setText(
                QApplication.translate("Form", "About", None,
                                       QApplication.UnicodeUTF8))
            self.tabWidget.setTabText(
                self.tabWidget.indexOf(self.tab_3),
                QApplication.translate("Form", "Status", None,
                                       QApplication.UnicodeUTF8))
        else:
            self.label_2.setText(
                QApplication.translate("Form", "Password", None))
            self.label.setText(
                QApplication.translate("Form", "User code", None))
            self.trylogin.setText(
                QApplication.translate("Form", "Try login credentials", None))
            self.login_attempt.setText(
                QApplication.translate("Form", "Login successful", None))
            self.label_4.setText(
                QApplication.translate("Form", "Root folder", None))
            self.changeRootFolder.setText(
                QApplication.translate("Form", "Change", None))
            self.label_5.setText(
                QApplication.translate("Form", "Sync every", None))
            self.label_6.setText(
                QApplication.translate("Form", "minutes", None))
            self.syncNow.setText(
                QApplication.translate("Form", "Sync now", None))
            self.addSyncNewCourses.setText(
                QApplication.translate(
                    "Form", "Automatically add and sync new available courses",
                    None))
            self.tabWidget.setTabText(
                self.tabWidget.indexOf(self.tab),
                QApplication.translate("Form", "General settings", None))
            self.refreshCourses.setText(
                QApplication.translate("Form", "Refresh list", None))
            self.tabWidget.setTabText(
                self.tabWidget.indexOf(self.tab_2),
                QApplication.translate("Form", "Courses", None))
            self.about.setText(QApplication.translate("Form", "About", None))
            self.tabWidget.setTabText(
                self.tabWidget.indexOf(self.tab_3),
                QApplication.translate("Form", "Status", None))
class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(583, 96)

        self.centralwidget = QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")

        self.verticalLayout = QVBoxLayout(self.centralwidget)
        self.verticalLayout.setObjectName("verticalLayout")

        self.gridLayout = QGridLayout()
        self.gridLayout.setObjectName("gridLayout")

        self.UI_label = QLabel(self.centralwidget)
        self.UI_label.setObjectName("UI_label")
        self.gridLayout.addWidget(self.UI_label, 0, 0, 1, 1)

        self.seleccionarUI_pushButton = QPushButton(self.centralwidget)
        self.seleccionarUI_pushButton.setObjectName("seleccionarUI_pushButton")
        self.gridLayout.addWidget(self.seleccionarUI_pushButton, 0, 2, 1, 1)

        self.Py_label = QLabel(self.centralwidget)
        self.Py_label.setObjectName("Py_label")
        self.gridLayout.addWidget(self.Py_label, 1, 0, 1, 1)

        self.rutaSalida_pushButton = QPushButton(self.centralwidget)
        self.rutaSalida_pushButton.setObjectName("rutaSalida_pushButton")
        self.gridLayout.addWidget(self.rutaSalida_pushButton, 1, 2, 1, 1)

        self.rutaEntrada_lineEdit = QLineEdit(self.centralwidget)
        self.rutaEntrada_lineEdit.setEnabled(False)
        self.rutaEntrada_lineEdit.setObjectName("rutaEntrada_lineEdit")
        self.gridLayout.addWidget(self.rutaEntrada_lineEdit, 0, 1, 1, 1)

        self.rutaSalida_lineEdit = QLineEdit(self.centralwidget)
        self.rutaSalida_lineEdit.setObjectName("rutaSalida_lineEdit")
        self.gridLayout.addWidget(self.rutaSalida_lineEdit, 1, 1, 1, 1)

        self.verticalLayout.addLayout(self.gridLayout)

        self.horizontalWidget = QWidget(self.centralwidget)
        self.horizontalWidget.setObjectName("horizontalWidget")

        self.horizontalLayout = QHBoxLayout(self.horizontalWidget)
        self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
        self.horizontalLayout.setObjectName("horizontalLayout")

        spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                    QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)

        self.convertir_pushButton = QPushButton(self.horizontalWidget)
        self.convertir_pushButton.setObjectName("convertir_pushButton")
        self.horizontalLayout.addWidget(self.convertir_pushButton)

        self.verticalLayout.addWidget(self.horizontalWidget)
        MainWindow.setCentralWidget(self.centralwidget)

        self.retranslateUi(MainWindow)
        QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle(
            QApplication.translate(
                "MainWindow",
                "Convertidor UI a Py",
                None,
                QApplication.UnicodeUTF8
                )
            )
        self.UI_label.setText(
            QApplication.translate(
                "MainWindow",
                "Seleccionar UI:",
                None,
                QApplication.UnicodeUTF8
                )
            )
        self.seleccionarUI_pushButton.setText(
            QApplication.translate(
                "MainWindow",
                "Abrir...",
                None,
                QApplication.UnicodeUTF8
                )
            )
        self.Py_label.setText(
            QApplication.translate(
                "MainWindow",
                "Archivo Py:",
                None,
                QApplication.UnicodeUTF8
                )
            )
        self.rutaSalida_pushButton.setText(
            QApplication.translate(
                "MainWindow",
                "...",
                None,
                QApplication.UnicodeUTF8
                )
            )
        self.convertir_pushButton.setText(
            QApplication.translate(
                "MainWindow",
                "Convertir",
                None,
                QApplication.UnicodeUTF8
                )
            )

        #Codigo agregado para ensamblar el GUI con el programa actual
        self.seleccionarUI_pushButton.clicked.connect(self.seleccionarUI)
        self.rutaSalida_pushButton.clicked.connect(self.seleccionarPY)
        self.convertir_pushButton.clicked.connect(convertir)


    #Funciones anexadas para la funcionalidad de los botones
    def seleccionarUI(self):
        dialogo = QFileDialog(None)
        dialogo.setFileMode(QFileDialog.ExistingFile)
        dialogo.setNameFilter('Interfaz(*.ui)')

        if dialogo.exec_():
            global Ruta_archivoUI
            Ruta_archivoUI = dialogo.selectedFiles()[0]
            self.rutaEntrada_lineEdit.setText(Ruta_archivoUI)

    def seleccionarPY(self):
        dialogo = QFileDialog(None)
        dialogo.setFileMode(QFileDialog.AnyFile)
        dialogo.setNameFilter('Archivo Python(*.py)')
        dialogo.setAcceptMode(QFileDialog.AcceptSave)
        dialogo.setDefaultSuffix('py')

        if dialogo.exec_():
            global Ruta_archivoPY
            Ruta_archivoPY = dialogo.selectedFiles()[0]
            self.rutaSalida_lineEdit.setText(Ruta_archivoPY)
示例#10
0
class NotificationTab():
    """ui class for new notification tab"""
    global logger

    def __init__(self):
        #####
        logger.info('Inside PurchaseSchedule')
        self.notificationTab_tab_4 = QWidget()
        self.notificationTab_tab_4.setObjectName("notificationTab_tab_4")
        self.gridLayout_19 = QGridLayout(self.notificationTab_tab_4)
        self.gridLayout_19.setObjectName("gridLayout_19")
        ##
        self.horizontalLayout = QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.title_label = QLabel(self.notificationTab_tab_4)
        self.title_label.setObjectName("title_label")
        self.horizontalLayout.addWidget(self.title_label)
        self.gridLayout_19.addLayout(self.horizontalLayout, 0, 0, 1, 1)
        ##
        self.horizontalLayout_6 = QHBoxLayout()
        self.horizontalLayout_6.setObjectName("horizontalLayout_6")
        self.id_label = QLabel(self.notificationTab_tab_4)
        self.id_label.setObjectName("id_label")
        self.horizontalLayout_6.addWidget(self.id_label)
        self.id_line = QLineEdit(self.notificationTab_tab_4)
        self.id_line.setObjectName("id_line")
        self.horizontalLayout_6.addWidget(self.id_line)
        self.notification_schedule_fromdate_label = QLabel(
            self.notificationTab_tab_4)
        self.notification_schedule_fromdate_label.setObjectName(
            "notification_schedule_fromdate_label")
        self.horizontalLayout_6.addWidget(
            self.notification_schedule_fromdate_label)
        self.notification_schedule_fromdate_dateedit = QDateEdit(
            self.notificationTab_tab_4)
        self.notification_schedule_fromdate_dateedit.setMaximumDate(
            QDate.currentDate())
        self.notification_schedule_fromdate_dateedit.setDate(
            QDate.currentDate())
        self.notification_schedule_fromdate_dateedit.setCalendarPopup(True)
        self.notification_schedule_fromdate_dateedit.setObjectName(
            "notification_schedule_fromdate_dateedit")
        self.horizontalLayout_6.addWidget(
            self.notification_schedule_fromdate_dateedit)
        self.notification_schedule_todate_label = QLabel(
            self.notificationTab_tab_4)
        self.notification_schedule_todate_label.setObjectName(
            "notification_schedule_todate_label")
        self.horizontalLayout_6.addWidget(
            self.notification_schedule_todate_label)
        self.notification_schedule_todate_dateedit = QDateEdit(
            self.notificationTab_tab_4)
        self.notification_schedule_todate_dateedit.setMaximumDate(
            QDate.currentDate())
        self.notification_schedule_todate_dateedit.setDate(QDate.currentDate())
        self.notification_schedule_todate_dateedit.setCalendarPopup(True)
        self.notification_schedule_todate_dateedit.setObjectName(
            "notification_schedule_todate_dateedit")
        self.horizontalLayout_6.addWidget(
            self.notification_schedule_todate_dateedit)
        self.type_label = QLabel(self.notificationTab_tab_4)
        self.type_label.setObjectName("type_label")
        self.horizontalLayout_6.addWidget(self.type_label)
        self.notification_states = QComboBox(self.notificationTab_tab_4)
        self.notification_states.setObjectName("notification_states")
        self.horizontalLayout_6.addWidget(self.notification_states)
        self.batch_label = QLabel(self.notificationTab_tab_4)
        self.batch_label.setObjectName("batch_label")
        self.horizontalLayout_6.addWidget(self.batch_label)
        self.notification_results = QComboBox(self.notificationTab_tab_4)
        self.notification_results.setObjectName("notification_results")
        self.horizontalLayout_6.addWidget(self.notification_results)
        self.gridLayout_19.addLayout(self.horizontalLayout_6, 1, 0, 1, 1)
        self.gridLayout_8 = QGridLayout()
        self.gridLayout_8.setObjectName("gridLayout_8")
        self.notification_schedule_table = QTableWidget(
            self.notificationTab_tab_4)
        self.notification_schedule_table.setObjectName(
            "notification_schedule_table")
        self.notification_schedule_table.setColumnCount(5)
        self.notification_schedule_table.setRowCount(0)
        self.notification_schedule_table.setWordWrap(True)
        item = QTableWidgetItem()
        self.notification_schedule_table.setHorizontalHeaderItem(0, item)
        item = QTableWidgetItem()
        self.notification_schedule_table.setHorizontalHeaderItem(1, item)
        item = QTableWidgetItem()
        self.notification_schedule_table.setHorizontalHeaderItem(2, item)
        item = QTableWidgetItem()
        self.notification_schedule_table.setHorizontalHeaderItem(3, item)
        item = QTableWidgetItem()
        self.notification_schedule_table.setHorizontalHeaderItem(4, item)
        self.notification_schedule_table.horizontalHeader(
        ).setCascadingSectionResizes(True)
        self.notification_schedule_table.horizontalHeader(
        ).setStretchLastSection(True)
        self.notification_schedule_table.verticalHeader().setVisible(False)
        self.notification_schedule_table.verticalHeader(
        ).setCascadingSectionResizes(True)
        self.notification_schedule_table.verticalHeader(
        ).setStretchLastSection(False)
        self.gridLayout_8.addWidget(self.notification_schedule_table, 0, 0, 1,
                                    5)
        self.notification_search_button = QPushButton(
            self.notificationTab_tab_4)
        self.notification_search_button.setObjectName(
            "notification_search_button")
        self.gridLayout_8.addWidget(self.notification_search_button, 1, 0, 1,
                                    1)
        spacerItem10 = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                   QSizePolicy.Minimum)
        self.gridLayout_8.addItem(spacerItem10, 1, 2, 1, 1)
        self.notification_reset_button = QPushButton(
            self.notificationTab_tab_4)
        self.notification_reset_button.setObjectName(
            "notification_reset_button")
        self.gridLayout_8.addWidget(self.notification_reset_button, 1, 3, 1, 1)
        self.notification_load_more_button = QPushButton(
            self.notificationTab_tab_4)
        self.notification_load_more_button.setObjectName(
            "notification_load_more_button")
        self.gridLayout_8.addWidget(self.notification_load_more_button, 1, 4,
                                    1, 1)
        self.gridLayout_19.addLayout(self.gridLayout_8, 2, 0, 1, 1)
        ###retranslate
        self.title_label.setText(
            QApplication.translate(
                "MainWindow", "<html><head/><body><p align=\"center\">"
                "<span style=\" font-weight:600;font-size:20px\">"
                "<u>All Notifications</u></span></p></body></html>", None,
                QApplication.UnicodeUTF8))
        self.id_label.setText(
            QApplication.translate("MainWindow", "Message Id", None,
                                   QApplication.UnicodeUTF8))
        self.notification_schedule_fromdate_label.setText(
            QApplication.translate("MainWindow", "From Date", None,
                                   QApplication.UnicodeUTF8))
        self.notification_schedule_fromdate_dateedit.setDisplayFormat(
            QApplication.translate("MainWindow", "dd/MM/yyyy", None,
                                   QApplication.UnicodeUTF8))
        self.notification_schedule_todate_label.setText(
            QApplication.translate("MainWindow", "To Date", None,
                                   QApplication.UnicodeUTF8))
        self.notification_schedule_todate_dateedit.setDisplayFormat(
            QApplication.translate("MainWindow", "dd/MM/yyyy", None,
                                   QApplication.UnicodeUTF8))
        self.type_label.setText(
            QApplication.translate("MainWindow", "Type", None,
                                   QApplication.UnicodeUTF8))
        self.batch_label.setText(
            QApplication.translate("MainWindow", "Number of Notifications",
                                   None, QApplication.UnicodeUTF8))
        self.notification_schedule_table.horizontalHeaderItem(0).setText(
            QApplication.translate("MainWindow", "Message Id", None,
                                   QApplication.UnicodeUTF8))
        self.notification_schedule_table.horizontalHeaderItem(1).setText(
            QApplication.translate("MainWindow", "Date", None,
                                   QApplication.UnicodeUTF8))
        self.notification_schedule_table.horizontalHeaderItem(2).setText(
            QApplication.translate("MainWindow", "From", None,
                                   QApplication.UnicodeUTF8))
        self.notification_schedule_table.horizontalHeaderItem(3).setText(
            QApplication.translate("MainWindow", "Message", None,
                                   QApplication.UnicodeUTF8))
        self.notification_schedule_table.horizontalHeaderItem(4).setText(
            QApplication.translate("MainWindow", "State", None,
                                   QApplication.UnicodeUTF8))
        self.notification_search_button.setText(
            QApplication.translate("MainWindow", "Search", None,
                                   QApplication.UnicodeUTF8))
        self.notification_reset_button.setText(
            QApplication.translate("MainWindow", "Reset All", None,
                                   QApplication.UnicodeUTF8))
        self.notification_load_more_button.setText(
            QApplication.translate("MainWindow", "Load More", None,
                                   QApplication.UnicodeUTF8))
        ##signals and slotts && other stuffs
        self.scheduletable_count = 0
        self.addtable_count = 0
        # self.mainwindow = Ui_MainWindow  # just for the ease of finding the attributes in pycharm
        self.notification_schedule_table.setEditTriggers(
            QAbstractItemView.NoEditTriggers)
        self.batch_number = None
        self.notification_results.addItems([str(i) for i in range(1, 50, 5)])
        self.notification_states.addItems(['All', 'New', 'To Do', 'Done'])
        self.message = Messaging()
        self.notification_load_more_button.clicked.connect(self.load_more)
        self.notification_search_button.clicked.connect(self.search_messages)
        self.notification_reset_button.clicked.connect(self.reset_all)
        self.notificationTab_tab_4.setFocusPolicy(Qt.StrongFocus)
        self.notificationTab_tab_4.focusInEvent = self.load_rows
        # self.assign_shortcuts()

        # def assign_shortcuts(self):
        # QShortcut(QKeySequence(settings.custom_shortcut['key_tabcon_inventorynotification_search']),
        # self.notificationTab_tab_4, self.search_messages)
        # QShortcut(QKeySequence(settings.custom_shortcut['key_tabcon_inventorynotification_additem']),
        # self.notificationTab_tab_4, self.add_new_blank_rows)
        # QShortcut(QKeySequence(settings.custom_shortcut['key_tabcon_inventorynotification_print']),
        # self.notificationTab_tab_4, self.commit_and_print)
        # QShortcut(QKeySequence(settings.custom_shortcut['key_tabcon_inventorynotification_today']),
        # self.notificationTab_tab_4, lambda: self.load_messages('today'))
        # QShortcut(QKeySequence(settings.custom_shortcut['key_tabcon_inventorynotification_tommorow']),
        # self.notificationTab_tab_4, lambda: self.load_messages('tomorrow'))
        # QShortcut(QKeySequence(settings.custom_shortcut['key_tabcon_inventorynotification_thismonth']),
        # self.notificationTab_tab_4, lambda: self.load_messages('month'))
        # QShortcut(QKeySequence(settings.custom_shortcut['key_tabcon_inventorynotification_thisweek']),
        # self.notificationTab_tab_4, lambda: self.load_messages('week'))
        # QShortcut(QKeySequence(settings.custom_shortcut['key_tabcon_inventorynotification_clear']),
        # self.notificationTab_tab_4, self.clear_table)

    def add_messages(self, *args):
        """
        Populates the Schedules when we load the tab
        """
        table = self.notification_schedule_table
        if args:
            if args[0] != 'new':
                table.clearContents()
                table.setRowCount(0)
                table.setRowCount(len(args))
                for i, j in enumerate(args):
                    item = QTableWidgetItem(j['msg_id'])
                    table.setItem(i, 0, item)
                    item = QTableWidgetItem(j['date'])
                    table.setItem(i, 1, item)
                    item = QTableWidgetItem(
                        'Name:{}\nDesignation:{}\nAddress:{}'.format(
                            j['name'], j['designation'], j['address']))
                    table.setItem(i, 2, item)
                    item = QTableWidgetItem(
                        'Message Type:{}\nMessage:{}'.format(
                            j['msg_type'].title(), j['msg_body']))
                    table.setItem(i, 3, item)
                    states = QComboBox()
                    self.populate_states(states, j['msg_state'].title())
                    states.currentIndexChanged.connect(
                        lambda index, row=i: self.changed_state(row, index))
                    table.setCellWidget(i, 4, states)
            elif args[0] == 'new':
                initial = table.rowCount()
                row = table.rowCount() + len(args[1])
                table.setRowCount(row)
                forward_range = range(initial, row)
                for i, j in zip(forward_range, args[1]):
                    item = QTableWidgetItem(j['msg_id'])
                    table.setItem(i, 0, item)
                    item = QTableWidgetItem(j['date'])
                    table.setItem(i, 1, item)
                    item = QTableWidgetItem(
                        'Name:{}\nDesignation:{}\nAddress:{}'.format(
                            j['name'], j['designation'], j['address']))
                    table.setItem(i, 2, item)
                    item = QTableWidgetItem(
                        'Message Type:{}\nMessage:{}'.format(
                            j['msg_type'].title(), j['msg_body']))
                    table.setItem(i, 3, item)
                    states = QComboBox()
                    self.populate_states(states, j['msg_state'].title())
                    states.currentIndexChanged.connect(
                        lambda index, row=i: self.changed_state(row, index))
                    table.setCellWidget(i, 4, states)
        table.setColumnWidth(0, (table.width() * 0.5) / 5)
        table.setColumnWidth(1, (table.width() * 0.5) / 5)
        table.setColumnWidth(2, table.width() / 5)
        table.setColumnWidth(3, (table.width() * 2) / 5)
        self.notification_schedule_table.resizeRowsToContents()

    def populate_states(self, combo, state):
        """
        fills the supplier list for each item line
        :param combo: the combo box of suppliers
        :return:none
        """
        combo.setStyleSheet("QAbstractItemView{" "background: #4B77BE;" "}")
        combo.addItems(['New', 'To Do', 'Done'])
        index = combo.findText(state)
        combo.setCurrentIndex(index)

    def changed_state(self, row, index):
        """
        fill the item combo box
        :param combo: the combobox object
        :return: none
        """
        table = self.notification_schedule_table
        data = {}
        data['message_id'] = table.item(row, 0).text()
        data['msg_state'] = table.cellWidget(row, 4).currentText()
        msg = QMessageBox.information(
            QMessageBox(), 'Alert!!',
            'Do you want to change the status of the Message??',
            QMessageBox.Yes | QMessageBox.No)
        if msg == QMessageBox.Yes:
            report = self.message.update_message(data)
            if report:
                _ = QMessageBox.information(QMessageBox(), 'Success!!',
                                            'The Message was updated',
                                            QMessageBox.Yes | QMessageBox.No)
            else:
                _ = QMessageBox.critical(QMessageBox(), 'Error!!',
                                         'The Message was not updated',
                                         QMessageBox.Yes | QMessageBox.No)

    def search_messages(self):
        """
        Searches for messages when search button is pressed
        """
        logger.info('Notifications searching messages initiated')
        from_date = self.notification_schedule_fromdate_dateedit.text()
        to_date = self.notification_schedule_todate_dateedit.text()
        limit = self.notification_results.currentText()
        msg_id = self.id_line.text()
        msg_state = self.notification_states.currentText()
        dataobj = self.message.load_message(limit=limit,
                                            from_date=from_date,
                                            to_date=to_date,
                                            msg_id=msg_id,
                                            msg_state=msg_state)
        if dataobj:
            self.add_messages(*dataobj)
        else:
            self.notification_schedule_table.clearContents()
            self.notification_schedule_table.setRowCount(0)

    def load_more(self):
        """
        Searches for messages when search button is pressed
        """
        logger.info('Notifications searching messages initiated')
        from_date = self.notification_schedule_fromdate_dateedit.text()
        to_date = self.notification_schedule_todate_dateedit.text()
        limit = self.notification_results.currentText()
        msg_id = self.id_line.text()
        msg_state = self.notification_states.currentText()
        offset = self.notification_schedule_table.rowCount()
        dataobj = self.message.load_message(limit=limit,
                                            from_date=from_date,
                                            to_date=to_date,
                                            msg_id=msg_id,
                                            msg_state=msg_state,
                                            offset=offset)
        if dataobj:
            self.add_messages('new', dataobj)
        else:
            self.notification_schedule_table.clearContents()
            self.notification_schedule_table.setRowCount(0)

    def load_single_message(self, msg_id):  # api
        """method to load a single message"""
        self.reset_all()
        dataobj = self.message.load_message(msg_id=msg_id)
        if dataobj:
            self.add_messages('new', dataobj)
            self.id_line.setText(str(msg_id))
        else:
            self.notification_schedule_table.clearContents()
            self.notification_schedule_table.setRowCount(0)

    def load_rows(self, event):
        """
        :return:loads the rows
        """
        self.add_messages()

    def reset_all(self):
        """
        :return: resets the the data in the search text
        """
        try:
            self.id_line.clear()
            self.notification_schedule_table.clearContents()
            self.notification_schedule_table.setRowCount(0)
        except Exception as _:
            if settings.level == 10:
                logger.exception('raised exception')
            return False
示例#11
0
文件: waste.py 项目: tinavas/FSERP
class WasteDish():
    """Dish waste management tab"""
    global logger

    def __init__(self):
        ###
        logger.info('Inside WasteDish')
        self.wastedetail_tab_1 = QWidget()
        self.wastedetail_tab_1.setObjectName("wastedetail_tab_1")
        self.verticalLayout_9 = QVBoxLayout(self.wastedetail_tab_1)
        self.verticalLayout_9.setObjectName("verticalLayout_9")
        self.verticalLayout_8 = QVBoxLayout()
        self.verticalLayout_8.setObjectName("verticalLayout_8")
        self.horizontalLayout_12 = QHBoxLayout()
        self.horizontalLayout_12.setObjectName("horizontalLayout_12")
        self.waste_fromdate_label = QLabel(self.wastedetail_tab_1)
        self.waste_fromdate_label.setObjectName('waste_fromdate_label')
        self.horizontalLayout_12.addWidget(self.waste_fromdate_label)
        self.waste_fromdate_dateedit = QDateEdit(self.wastedetail_tab_1)
        self.waste_fromdate_dateedit.setCalendarPopup(True)
        self.waste_fromdate_dateedit.setObjectName("waste_fromdate_dateedit")
        self.horizontalLayout_12.addWidget(self.waste_fromdate_dateedit)
        self.waste_todate_label = QLabel(self.wastedetail_tab_1)
        self.waste_todate_label.setObjectName('waste_todate_label')
        self.horizontalLayout_12.addWidget(self.waste_todate_label)
        self.waste_todate_dateedit = QDateEdit(self.wastedetail_tab_1)
        self.waste_todate_dateedit.setCalendarPopup(True)
        self.waste_todate_dateedit.setObjectName("waste_todate_dateedit")
        self.waste_todate_dateedit.setMaximumDate(QDate.currentDate())
        self.horizontalLayout_12.addWidget(self.waste_todate_dateedit)
        spacerItem28 = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                   QSizePolicy.Minimum)
        self.horizontalLayout_12.addItem(spacerItem28)
        self.waste_table_search_button = QPushButton(self.wastedetail_tab_1)
        self.waste_table_search_button.setObjectName(
            "waste_table_search_button")
        self.horizontalLayout_12.addWidget(self.waste_table_search_button)
        self.verticalLayout_8.addLayout(self.horizontalLayout_12)
        self.waste_table = QTableWidget(self.wastedetail_tab_1)
        self.waste_table.setObjectName("waste_table")
        self.waste_table.setColumnCount(5)
        self.waste_table.setRowCount(0)
        item = QTableWidgetItem()
        self.waste_table.setHorizontalHeaderItem(0, item)
        item = QTableWidgetItem()
        self.waste_table.setHorizontalHeaderItem(1, item)
        item = QTableWidgetItem()
        self.waste_table.setHorizontalHeaderItem(2, item)
        item = QTableWidgetItem()
        self.waste_table.setHorizontalHeaderItem(3, item)
        item = QTableWidgetItem()
        self.waste_table.setHorizontalHeaderItem(4, item)
        self.waste_table.horizontalHeader().setCascadingSectionResizes(False)
        self.waste_table.horizontalHeader().setStretchLastSection(True)
        self.waste_table.verticalHeader().setVisible(False)
        self.waste_table.verticalHeader().setCascadingSectionResizes(False)
        self.waste_table.setSortingEnabled(True)
        self.verticalLayout_8.addWidget(self.waste_table)
        self.horizontalLayout_13 = QHBoxLayout()
        self.horizontalLayout_13.setObjectName("horizontalLayout_13")
        self.waste_table_newrow_button = QPushButton(self.wastedetail_tab_1)
        self.waste_table_newrow_button.setObjectName(
            "waste_table_newrow_button")
        self.horizontalLayout_13.addWidget(self.waste_table_newrow_button)
        spacerItem29 = QSpacerItem(612, 20, QSizePolicy.Expanding,
                                   QSizePolicy.Minimum)
        self.horizontalLayout_13.addItem(spacerItem29)
        self.waste_table_discard_button = QPushButton(self.wastedetail_tab_1)
        self.waste_table_discard_button.setObjectName(
            "waste_table_discard_button")
        self.horizontalLayout_13.addWidget(self.waste_table_discard_button)
        self.verticalLayout_8.addLayout(self.horizontalLayout_13)
        self.verticalLayout_9.addLayout(self.verticalLayout_8)
        ##retranslate
        self.waste_fromdate_label.setText(
            QApplication.translate("MainWindow", "From Date", None,
                                   QApplication.UnicodeUTF8))
        self.waste_fromdate_dateedit.setDisplayFormat(
            QApplication.translate("MainWindow", "dd/MM/yyyy", None,
                                   QApplication.UnicodeUTF8))
        self.waste_todate_label.setText(
            QApplication.translate("MainWindow", "To Date", None,
                                   QApplication.UnicodeUTF8))
        self.waste_todate_dateedit.setDisplayFormat(
            QApplication.translate("MainWindow", "dd/MM/yyyy", None,
                                   QApplication.UnicodeUTF8))
        self.waste_table_search_button.setText(
            QApplication.translate("MainWindow", "Search", None,
                                   QApplication.UnicodeUTF8))
        self.waste_table.horizontalHeaderItem(0).setText(
            QApplication.translate("MainWindow", "Code", None,
                                   QApplication.UnicodeUTF8))
        self.waste_table.horizontalHeaderItem(1).setText(
            QApplication.translate("MainWindow", "Item", None,
                                   QApplication.UnicodeUTF8))
        self.waste_table.horizontalHeaderItem(2).setText(
            QApplication.translate("MainWindow", "Category", None,
                                   QApplication.UnicodeUTF8))
        self.waste_table.horizontalHeaderItem(3).setText(
            QApplication.translate("MainWindow", "Quantity", None,
                                   QApplication.UnicodeUTF8))
        self.waste_table.horizontalHeaderItem(4).setText(
            QApplication.translate("MainWindow", "Reason", None,
                                   QApplication.UnicodeUTF8))
        self.waste_table_newrow_button.setText(
            QApplication.translate("MainWindow", "New Row", None,
                                   QApplication.UnicodeUTF8))
        self.waste_table_discard_button.setText(
            QApplication.translate("MainWindow", "Discard Item", None,
                                   QApplication.UnicodeUTF8))
        self.wastedetail_tab_1.setTabOrder(self.waste_fromdate_dateedit,
                                           self.waste_todate_dateedit)
        self.wastedetail_tab_1.setTabOrder(self.waste_todate_dateedit,
                                           self.waste_table_search_button)
        ###signals and slots && other stuffs
        # self.mainwindow = Ui_MainWindow  # just for the ease of finding the attributes in pycharm
        self.schedule = SchedulePurchase()
        self.suplier = BusinessParty(category='Supplier')
        self.add = AddStockInventory()
        self.item = WasteMenu()
        self.waste_fromdate_dateedit.setDate(QDate.currentDate())
        self.waste_todate_dateedit.setDate(QDate.currentDate())
        self.waste_table.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.waste_table_newrow_button.clicked.connect(self.add_new_blank_rows)
        self.waste_table_discard_button.clicked.connect(self.discard)
        self.waste_table_search_button.clicked.connect(self.search_discard)
        self.wastedetail_tab_1.setFocusPolicy(Qt.StrongFocus)
        self.wastedetail_tab_1.focusInEvent = self.load_rows

    def load_rows(self, event=None):
        pass

    def add_new_blank_rows(self):
        """
        deletes the schedules in the database
        """
        table = self.waste_table
        item = table.item(0, 0)
        if item:
            message = QMessageBox.critical(QMessageBox(), 'Warning!',
                                           'This will remove all the entries',
                                           QMessageBox.Ok | QMessageBox.Cancel)
            if message == QMessageBox.Ok:
                table.setRowCount(0)
                table.clearContents()
                self.add_row_to_table('new')
                self.waste_table_discard_button.setVisible(True)
        elif not item:
            self.waste_table_discard_button.setVisible(True)
            self.add_row_to_table('new')

    def add_row_to_table(self, *args):
        """
        complex stuff of auto complete to be added to each combo box
        :return:
        """
        table = self.waste_table
        if args:
            if args[0] != 'new':
                table.clearContents()
                table.setRowCount(0)
                table.setRowCount(len(args))
                for i, j in enumerate(args):
                    code = QTableWidgetItem(j['code'])
                    table.setItem(i, 0, code)
                    item = QTableWidgetItem(j['item'])
                    table.setItem(i, 1, item)
                    category = QTableWidgetItem(j['category'])
                    table.setItem(i, 2, category)
                    quantity = QTableWidgetItem(str(j['quantity']))
                    table.setItem(i, 3, quantity)
                    reason = QTableWidgetItem(j['reason_for_discard'])
                    table.setItem(i, 4, reason)
            if args[0] == 'new':
                row = table.rowCount() + 1
                table.setRowCount(row)
                codeline = QLineEdit()
                codeline.editingFinished.connect(
                    lambda: self.get_details_of_code(row))
                table.setCellWidget(row - 1, 0, codeline)
                itemcombo = QComboBox()
                self.fill_item_list(itemcombo)
                itemcombo.currentIndexChanged.connect(
                    lambda: self.get_details_of_item(row))
                table.setCellWidget(row - 1, 1, itemcombo)
                category = QTableWidgetItem()
                table.setItem(row - 1, 2, category)
                quantity = QLineEdit()
                table.setCellWidget(row - 1, 3, quantity)
                combo = QComboBox()
                combo.addItem("Cancelled")
                combo.addItem("Mishandling")
                combo.addItem("Excess")
                table.setCellWidget(row - 1, 4, combo)
        table.setColumnWidth(0, (table.width() / 5))
        table.setColumnWidth(1, (table.width() / 5))
        table.setColumnWidth(2, (table.width() / 5))
        table.setColumnWidth(3, (table.width() / 5))
        table.horizontalHeader().setStretchLastSection(
            True
        )  # important to resize last section else blank space after last column

    def fill_item_list(self, combo):
        """
        fill the item combo box
        :param combo: the combobox object
        :return: none
        """
        itemfield = combo
        itemfield.setStyleSheet("QAbstractItemView{"
                                "background: #4B77BE;"
                                "}")
        self.item.populate_item(itemfield)

    def get_details_of_code(self, rowcount):
        """
        fills the item, category and units based on the code
        :param rowcount: the row count
        :return: none
        """
        row = rowcount - 1
        table = self.waste_table
        codeline = table.cellWidget(row, 0)
        data = self.item.get_details_of_code(codeline.text())
        item = table.cellWidget(row, 1)
        index = item.findText(data['item'])
        item.setCurrentIndex(index)
        category = table.item(row, 2)
        category.setText(data['category'])

    def get_details_of_item(self, rowcount):
        """
        fills the code, category and units based on the item
        :param rowcount: the row count
        :return: none
        """
        row = rowcount - 1
        table = self.waste_table
        itemcombo = table.cellWidget(row, 1)
        data = self.item.get_details_of_item(itemcombo.currentText())
        code = table.cellWidget(row, 0)
        code.setText(data['code'])
        category = table.item(row, 2)
        category.setText(data['category'])

    def discard(self):
        """
        saves the details in db before printing
        """
        logger.info('WasteDish discard initiated')
        table = self.waste_table
        data = self.get_data()
        if data:
            for i in data:
                status = self.item.discard(i)
                if status:
                    model_index = table.indexFromItem(i['model_item'])
                    row = model_index.row()
                    table.removeRow(row)
                else:
                    msg = QMessageBox.critical(QMessageBox(), "Error!!",
                                               "The item cannot be discarded",
                                               QMessageBox.Ok)
                    if msg == QMessageBox.Ok:
                        return False

    def search_discard(self):
        """
        searches the discard from_date and to_date
        :return:none
        """
        table = self.waste_table
        item = table.cellWidget(0, 0)
        if item:
            msg = QMessageBox.critical(QMessageBox(), 'Warning!',
                                       'This will delete all the rows added',
                                       QMessageBox.Ok | QMessageBox.Cancel)
            if msg == QMessageBox.Cancel:
                return False
        f_date = self.waste_fromdate_dateedit.text()
        from_date = datetime.strptime(f_date, '%d/%m/%Y')
        t_date = self.waste_todate_dateedit.text()
        to_date = datetime.strptime(t_date, '%d/%m/%Y')
        to_date = to_date + timedelta(hours=23, minutes=59, seconds=59)
        dataobj = self.item.find_itemdiscard(from_date=from_date,
                                             to_date=to_date)
        self.add_row_to_table(*dataobj)
        self.waste_table_discard_button.setVisible(False)

    def get_data(self):
        """
        :return: fetches all the data for printing
        """
        table = self.waste_table
        rows = table.rowCount()
        dataobj = []
        for i in range(rows):
            dictionary = {}
            item = table.cellWidget(i, 0) if table.cellWidget(
                i, 0) is not None else table.item(i, 0)
            dictionary['code'] = item.text()
            if dictionary['code'] == '':
                break
            item = table.cellWidget(i, 1).currentText() if table.cellWidget(
                i, 1) is not None else table.item(i, 1).text()
            dictionary['item'] = item
            item = table.cellWidget(i, 2) if table.cellWidget(
                i, 2) is not None else table.item(i, 2)
            dictionary['category'] = item.text()
            item = table.cellWidget(i, 3) if table.cellWidget(
                i, 3) is not None else table.item(i, 3)
            dictionary['quantity'] = item.text()
            if dictionary['quantity'] == '':
                self.show_error('Quantity')
                return False
            item = table.cellWidget(i, 4).currentText() if table.cellWidget(
                i, 4) is not None else table.item(i, 4).text()
            dictionary['reason_for_discard'] = item
            dictionary['model_item'] = table.item(i, 2)
            dataobj.append(dictionary)
        return dataobj

    def show_error(self, text):
        """
        :return: pops up an error
        """
        QMessageBox.critical(QMessageBox(), "Fail!!",
                             "Please Enter %s properly" % text, QMessageBox.Ok)
示例#12
0
文件: waste.py 项目: tinavas/FSERP
class WasteItems():
    """Item waste management tab"""
    global logger

    def __init__(self):
        ###
        logger.info('Inside WasteItems')
        self.wastedetail_tab_1 = QWidget()
        self.wastedetail_tab_1.setObjectName("wastedetail_tab_1")
        self.verticalLayout_9 = QVBoxLayout(self.wastedetail_tab_1)
        self.verticalLayout_9.setObjectName("verticalLayout_9")
        self.verticalLayout_8 = QVBoxLayout()
        self.verticalLayout_8.setObjectName("verticalLayout_8")
        self.horizontalLayout_12 = QHBoxLayout()
        self.horizontalLayout_12.setObjectName("horizontalLayout_12")
        self.waste_fromdate_label = QLabel(self.wastedetail_tab_1)
        self.waste_fromdate_label.setObjectName('waste_fromdate_label')
        self.horizontalLayout_12.addWidget(self.waste_fromdate_label)
        self.waste_fromdate_dateedit = QDateEdit(self.wastedetail_tab_1)
        self.waste_fromdate_dateedit.setCalendarPopup(True)
        self.waste_fromdate_dateedit.setObjectName("waste_fromdate_dateedit")
        self.horizontalLayout_12.addWidget(self.waste_fromdate_dateedit)
        self.waste_todate_label = QLabel(self.wastedetail_tab_1)
        self.waste_todate_label.setObjectName('waste_todate_label')
        self.horizontalLayout_12.addWidget(self.waste_todate_label)
        self.waste_todate_dateedit = QDateEdit(self.wastedetail_tab_1)
        self.waste_todate_dateedit.setCalendarPopup(True)
        self.waste_todate_dateedit.setObjectName("waste_todate_dateedit")
        self.waste_todate_dateedit.setMaximumDate(QDate.currentDate())
        self.horizontalLayout_12.addWidget(self.waste_todate_dateedit)
        spacerItem28 = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                   QSizePolicy.Minimum)
        self.horizontalLayout_12.addItem(spacerItem28)
        self.waste_table_search_button = QPushButton(self.wastedetail_tab_1)
        self.waste_table_search_button.setObjectName(
            "waste_table_search_button")
        self.horizontalLayout_12.addWidget(self.waste_table_search_button)
        self.verticalLayout_8.addLayout(self.horizontalLayout_12)
        self.waste_table = QTableWidget(self.wastedetail_tab_1)
        self.waste_table.setObjectName("waste_table")
        self.waste_table.setColumnCount(6)
        self.waste_table.setRowCount(0)
        item = QTableWidgetItem()
        self.waste_table.setHorizontalHeaderItem(0, item)
        item = QTableWidgetItem()
        self.waste_table.setHorizontalHeaderItem(1, item)
        item = QTableWidgetItem()
        self.waste_table.setHorizontalHeaderItem(2, item)
        item = QTableWidgetItem()
        self.waste_table.setHorizontalHeaderItem(3, item)
        item = QTableWidgetItem()
        self.waste_table.setHorizontalHeaderItem(4, item)
        item = QTableWidgetItem()
        self.waste_table.setHorizontalHeaderItem(5, item)
        self.waste_table.horizontalHeader().setCascadingSectionResizes(False)
        self.waste_table.horizontalHeader().setStretchLastSection(True)
        self.waste_table.verticalHeader().setVisible(False)
        self.waste_table.verticalHeader().setCascadingSectionResizes(False)
        self.waste_table.setSortingEnabled(True)
        self.verticalLayout_8.addWidget(self.waste_table)
        self.verticalLayout_9.addLayout(self.verticalLayout_8)
        ##retranslate
        self.waste_fromdate_label.setText(
            QApplication.translate("MainWindow", "From Date", None,
                                   QApplication.UnicodeUTF8))
        self.waste_fromdate_dateedit.setDisplayFormat(
            QApplication.translate("MainWindow", "dd/MM/yyyy", None,
                                   QApplication.UnicodeUTF8))
        self.waste_todate_label.setText(
            QApplication.translate("MainWindow", "To Date", None,
                                   QApplication.UnicodeUTF8))
        self.waste_todate_dateedit.setDisplayFormat(
            QApplication.translate("MainWindow", "dd/MM/yyyy", None,
                                   QApplication.UnicodeUTF8))
        self.waste_table_search_button.setText(
            QApplication.translate("MainWindow", "Search", None,
                                   QApplication.UnicodeUTF8))
        self.waste_table.horizontalHeaderItem(0).setText(
            QApplication.translate("MainWindow", "Code", None,
                                   QApplication.UnicodeUTF8))
        self.waste_table.horizontalHeaderItem(1).setText(
            QApplication.translate("MainWindow", "Item", None,
                                   QApplication.UnicodeUTF8))
        self.waste_table.horizontalHeaderItem(2).setText(
            QApplication.translate("MainWindow", "Category", None,
                                   QApplication.UnicodeUTF8))
        self.waste_table.horizontalHeaderItem(3).setText(
            QApplication.translate("MainWindow", "Units", None,
                                   QApplication.UnicodeUTF8))
        self.waste_table.horizontalHeaderItem(4).setText(
            QApplication.translate("MainWindow", "Quantity", None,
                                   QApplication.UnicodeUTF8))
        self.waste_table.horizontalHeaderItem(5).setText(
            QApplication.translate("MainWindow", "Reason", None,
                                   QApplication.UnicodeUTF8))

        ###signals and slots && other stuffs
        # self.mainwindow = Ui_MainWindow  # just for the ease of finding the attributes in pycharm
        self.item = WasteIngredients()
        self.waste_fromdate_dateedit.setDate(QDate.currentDate())
        self.waste_todate_dateedit.setDate(QDate.currentDate())
        self.waste_table.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.waste_table_search_button.clicked.connect(self.search_discard)
        self.wastedetail_tab_1.setFocusPolicy(Qt.StrongFocus)
        self.wastedetail_tab_1.focusInEvent = self.load_rows

    def load_rows(self, event=None):
        """calling add row to restructure the table every time container resizes"""
        self.add_row_to_table()

    def search_discard(self):
        """
        searches the discard from_date and to_date
        :return:none
        """
        f_date = self.waste_fromdate_dateedit.text()
        from_date = datetime.strptime(f_date, '%d/%m/%Y')
        t_date = self.waste_todate_dateedit.text()
        to_date = datetime.strptime(t_date, '%d/%m/%Y')
        to_date = to_date + timedelta(hours=23, minutes=59, seconds=59)
        dataobj = self.item.find_itemdiscard(from_date=from_date,
                                             to_date=to_date)
        self.add_row_to_table(*dataobj)

    def add_row_to_table(self, *args):
        """
        complex stuff of auto complete to be added to each combo box
        :return:
        """
        table = self.waste_table
        if args:
            table.clearContents()
            table.setRowCount(0)
            table.setRowCount(len(args))
            for i, j in enumerate(args):
                code = QTableWidgetItem(j['code'])
                table.setItem(i, 0, code)
                item = QTableWidgetItem(j['item'])
                table.setItem(i, 1, item)
                category = QTableWidgetItem(j['category'])
                table.setItem(i, 2, category)
                unit = QTableWidgetItem(str(j['units']))
                table.setItem(i, 3, unit)
                quantity = QTableWidgetItem(str(j['quantity']))
                table.setItem(i, 4, quantity)
                reason = QTableWidgetItem(j['reason_for_discard'])
                table.setItem(i, 5, reason)
        table.setColumnWidth(0, (table.width() / 6))
        table.setColumnWidth(1, (table.width() / 6))
        table.setColumnWidth(2, (table.width() / 6))
        table.setColumnWidth(3, (table.width() / 6))
        table.setColumnWidth(4, (table.width() / 6))
        table.horizontalHeader().setStretchLastSection(True)
示例#13
0
class Ui_MainWindow(object):
    
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.setFixedSize(800, 600)
        self.centralwidget = QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.FilterLbl = QLabel(self.centralwidget)
        self.FilterLbl.setGeometry(QtCore.QRect(30, 150, 60, 15))
        self.FilterLbl.setObjectName("FilterLbl")
        self.FilterCB = QComboBox(self.centralwidget)
        self.FilterCB.setGeometry(QtCore.QRect(450, 150, 100, 22))
        self.FilterCB.setObjectName("FilterCB")
        self.FilterCB.addItem("")
        self.FilterCB.addItem("")
        self.FilterCB.addItem("")
        self.FilterCB.addItem("")         
        self.FilterTF = QLineEdit(self.centralwidget)
        self.FilterTF.setGeometry(QtCore.QRect(100, 150, 320, 20))        
        self.tableView = QTableWidget(self.centralwidget)
        self.tableView.setGeometry(QtCore.QRect(10, 180, 781, 511))
        self.tableView.setObjectName("tableView")
        self.tableView.setColumnCount(4)
        self.tableView.setRowCount(0)
        item = QTableWidgetItem("Cena za kg/l")
        self.tableView.setHorizontalHeaderItem(0, item)
        item = QTableWidgetItem("Cena ze kus")
        self.tableView.setHorizontalHeaderItem(1, item)
        item = QTableWidgetItem(u"Gramaž")
        self.tableView.setHorizontalHeaderItem(2, item)
        item = QTableWidgetItem("Popis")
        item.setTextAlignment(QtCore.Qt.AlignHCenter|QtCore.Qt.AlignVCenter|QtCore.Qt.AlignCenter)
        font = QtGui.QFont()
        font.setPointSize(8)
        item.setFont(font)
        self.tableView.setHorizontalHeaderItem(3, item)
        self.tableView.horizontalHeader().setStretchLastSection(True)
        
        self.SaveBtn = QPushButton(self.centralwidget)
        self.SaveBtn.setGeometry(QtCore.QRect(30, 10, 100, 23))
        self.SaveBtn.setObjectName("SaveBtn")
        self.PrintSelectedToFileBtn = QPushButton(self.centralwidget)
        self.PrintSelectedToFileBtn.setGeometry(QtCore.QRect(225, 10, 100, 23))        
        self.PrintSelectedToFileBtn.setObjectName("PrintSelectedToFileBtn")
        self.PriceForUnitTF = QLineEdit(self.centralwidget)
        self.PriceForUnitTF.setGeometry(QtCore.QRect(100, 70, 113, 20))
        self.PriceForUnitTF.setObjectName("PriceForUnitTF")
        self.PriceForUnitLbl = QLabel(self.centralwidget)
        self.PriceForUnitLbl.setGeometry(QtCore.QRect(30, 70, 60, 13))
        self.PriceForUnitLbl.setObjectName("PriceForUnitLbl")
        self.ArtikelTF = QLineEdit(self.centralwidget)
        self.ArtikelTF.setGeometry(QtCore.QRect(100, 100, 113, 20))
        self.ArtikelTF.setObjectName("ArtikelTF")
        self.ArtikelLbl = QLabel(self.centralwidget)
        self.ArtikelLbl.setGeometry(QtCore.QRect(30, 100, 46, 13))
        self.ArtikelLbl.setObjectName("ArtikelLbl")
        self.DescriptionLbl = QLabel(self.centralwidget)
        self.DescriptionLbl.setGeometry(QtCore.QRect(455, 70, 75, 13))
        self.DescriptionLbl.setObjectName("DescriptionLbl")
        self.UnitLbl = QLabel(self.centralwidget)
        self.UnitLbl.setGeometry(QtCore.QRect(250, 70, 60, 15))
        self.UnitLbl.setObjectName("UnitLbl")
        self.WeightLbl = QLabel(self.centralwidget)
        self.WeightLbl.setGeometry(QtCore.QRect(250, 100, 60, 13))
        self.WeightLbl.setObjectName("UnitLbl")
        self.WeightTF = QLineEdit(self.centralwidget)
        self.WeightTF.setGeometry(QtCore.QRect(320, 100, 100, 20))
        self.WeightTF.setObjectName("WeightTF")        
        self.UnitCB = QComboBox(self.centralwidget)
        self.UnitCB.setGeometry(QtCore.QRect(320, 70, 100, 22))
        self.UnitCB.setObjectName("UnitCB")
        self.UnitCB.addItem("")
        self.UnitCB.addItem("")
        self.DescriptionTE = QPlainTextEdit(self.centralwidget)
        self.DescriptionTE.setGeometry(QtCore.QRect(540, 30, 241, 61))
        self.DescriptionTE.setObjectName("DescriptionTE")
        self.PrintToFileBtn = QPushButton(self.centralwidget)
        self.PrintToFileBtn.setGeometry(QtCore.QRect(140, 10, 75, 23))
        self.PrintToFileBtn.setObjectName("PrintToFileBtn")
        self.AddRecordBtn = QPushButton(self.centralwidget)
        self.AddRecordBtn.setGeometry(QtCore.QRect(450, 100, 75, 23))
        self.AddRecordBtn.setObjectName("AddRecordBtn")        
        self.SaveChangeBtn = QPushButton(self.centralwidget)
        self.SaveChangeBtn.setGeometry(QtCore.QRect(550, 100, 75, 23))
        self.SaveChangeBtn.setObjectName("SaveChangeBtn")
        self.DeleteRecordBtn = QPushButton(self.centralwidget)
        self.DeleteRecordBtn.setGeometry(QtCore.QRect(650, 100, 75, 23))
        self.DeleteRecordBtn.setObjectName("DeleteRecordBtn")
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 21))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
   
        self.FilterTF.textChanged.connect(self.on_lineEdit_textChanged)
        self.FilterCB.currentIndexChanged.connect(self.on_comboBox_currentIndexChanged)
        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def myFilter(self,col=None):
        filt = self.FilterTF.text()
        for ix in range(self.tableView.rowCount()):
            match = False
            if col == None:
                for jx in range(self.tableView.columnCount()):
                    item = self.tableView.item(ix,jx)
                    if filt in item.text():
                        match = True
                        break
                self.tableView.setRowHidden(ix, not match)
            else:
                item = self.tableView.item(ix, col)
                if filt in item.text():
                    match = True
                self.tableView.setRowHidden(ix, not match)

    #@QtCore.pyqtSlot(str)
    def on_lineEdit_textChanged(self, text):
        self.myFilter()

    #@QtCore.pyqtSlot(int)
    def on_comboBox_currentIndexChanged(self, index):
        self.myFilter(col=index)
        
    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "Stitky - {0}".format(__version__)))
        self.SaveBtn.setText(_translate("MainWindow", "Uloz stav tabulky"))
        self.PrintSelectedToFileBtn.setText(_translate("MainWindow", "Tisk vybranych"))
        self.PriceForUnitLbl.setText(_translate("MainWindow", "Cena za kus:"))
        self.ArtikelLbl.setText(_translate("MainWindow", "Artikl:"))
        self.DescriptionLbl.setText(_translate("MainWindow", "Popis produktu:"))
        self.UnitLbl.setText(_translate("MainWindow", "Jednotka:"))
        self.FilterLbl.setText(_translate("MainWindow", "Filtr:"))
        self.WeightLbl.setText(_translate("MainWindow", "Hmotnost:"))
        self.PrintToFileBtn.setText(_translate("MainWindow", "Vytvor txt"))
        self.SaveChangeBtn.setText(_translate("MainWindow", "Uloz zmeny"))
        self.AddRecordBtn.setText(_translate("MainWindow", "Pridej zaznam"))
        self.DeleteRecordBtn.setText(_translate("MainWindow", "Smaz zaznam"))
        self.UnitCB.setItemText(0, _translate("MainWindow", "g"))
        self.UnitCB.setItemText(1, _translate("MainWindow", "ml"))
        self.FilterCB.setItemText(0, _translate("MainWindow", "Cena za kg/l"))
        self.FilterCB.setItemText(1, _translate("MainWindow", "Cena ze kus"))
        self.FilterCB.setItemText(2, _translate("MainWindow", "Gramaz"))
        self.FilterCB.setItemText(3, _translate("MainWindow", "Popis"))
示例#14
0
文件: menu.py 项目: tinavas/FSERP
class MenuWeekday():
    """Tab to manage menu entry for each day"""
    global logger

    def __init__(self, day):
        ####
        logger.info('Inside MenuWeekday')
        self.menudetail_tab_1 = QWidget()
        self.menudetail_tab_1.setObjectName("menudetail_tab_1")
        self.gridLayout_20 = QGridLayout(self.menudetail_tab_1)
        self.gridLayout_20.setObjectName("gridLayout_20")
        self.menu_table = QTableWidget(self.menudetail_tab_1)
        self.menu_table.setSortingEnabled(True)
        self.menu_table.setObjectName("menu_table")
        self.menu_table.setColumnCount(6)
        self.menu_table.setRowCount(0)
        item = QTableWidgetItem()
        self.menu_table.setHorizontalHeaderItem(0, item)
        item = QTableWidgetItem()
        self.menu_table.setHorizontalHeaderItem(1, item)
        item = QTableWidgetItem()
        self.menu_table.setHorizontalHeaderItem(2, item)
        item = QTableWidgetItem()
        self.menu_table.setHorizontalHeaderItem(3, item)
        item = QTableWidgetItem()
        self.menu_table.setHorizontalHeaderItem(4, item)
        item = QTableWidgetItem()
        self.menu_table.setHorizontalHeaderItem(5, item)
        self.menu_table.horizontalHeader().setCascadingSectionResizes(False)
        self.menu_table.horizontalHeader().setStretchLastSection(True)
        self.menu_table.verticalHeader().setVisible(True)
        self.menu_table.verticalHeader().setCascadingSectionResizes(True)
        self.gridLayout_20.addWidget(self.menu_table, 0, 0, 1, 3)
        spacerItem22 = QSpacerItem(612, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
        self.gridLayout_20.addItem(spacerItem22, 1, 0, 1, 1)
        self.menu_table_refresh_button = QPushButton(self.menudetail_tab_1)
        self.menu_table_refresh_button.setObjectName("menu_table_refresh_button")
        self.gridLayout_20.addWidget(self.menu_table_refresh_button, 1, 1, 1, 1)
        self.menu_table_add_button = QPushButton(self.menudetail_tab_1)
        self.menu_table_add_button.setObjectName("menu_table_add_button")
        self.gridLayout_20.addWidget(self.menu_table_add_button, 1, 2, 1, 1)
        ####retranslate
        self.menu_table.horizontalHeaderItem(0).setText(
            QApplication.translate("MainWindow", "Code", None, QApplication.UnicodeUTF8))
        self.menu_table.horizontalHeaderItem(1).setText(
            QApplication.translate("MainWindow", "Item", None, QApplication.UnicodeUTF8))
        self.menu_table.horizontalHeaderItem(2).setText(
            QApplication.translate("MainWindow", "Category", None, QApplication.UnicodeUTF8))
        self.menu_table.horizontalHeaderItem(3).setText(
            QApplication.translate("MainWindow", "Rate", None, QApplication.UnicodeUTF8))
        self.menu_table.horizontalHeaderItem(4).setText(
            QApplication.translate("MainWindow", "Per Day", None, QApplication.UnicodeUTF8))
        self.menu_table.horizontalHeaderItem(5).setText(
            QApplication.translate("MainWindow", "Available", None, QApplication.UnicodeUTF8))
        self.menu_table_refresh_button.setText(
            QApplication.translate("MainWindow", "Refresh", None, QApplication.UnicodeUTF8))
        self.menu_table_add_button.setText(
            QApplication.translate("MainWindow", "Add Dish", None, QApplication.UnicodeUTF8))
        ###signals and slots && other stuffs
        # self.mainwindow = Ui_MainWindow  # just for the ease of finding the attributes in pycharm
        self.day = day
        self.menu_table_add_button.clicked.connect(self.add_menu)
        self.menu_table.itemDoubleClicked.connect(self.popup_edit)
        self.menu_table_refresh_button.clicked.connect(self.update_menu)
        self.menu_table.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.menu_table.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.menu_table.setShowGrid(False)
        self.menu_table.setAlternatingRowColors(True)
        self.update_menu()
        self.popup = object
        self.menudetail_tab_1.setFocusPolicy(Qt.StrongFocus)
        self.menudetail_tab_1.focusInEvent = self.load_rows
        self.assign_shortcuts()

    def assign_shortcuts(self):
        """assign shortcuts"""
        QShortcut(QKeySequence(settings.custom_shortcut['key_tabcon_menumgtmonsun_view']),
                  self.menudetail_tab_1, self.row_selected)
        QShortcut(QKeySequence(settings.custom_shortcut['key_tabcon_menumgtmonsun_refresh']),
                  self.menudetail_tab_1, self.update_menu)
        QShortcut(QKeySequence(settings.custom_shortcut['key_tabcon_menumgtmonsun_add']),
                  self.menudetail_tab_1, self.add_menu)

    def row_selected(self):
        """selets a row entry"""
        rows = sorted(set(index.row() for index in
                          self.menu_table.selectedIndexes()))
        if rows:
            code = self.menu_table.item(rows[0], 0).text()
            name = self.menu_table.item(rows[0], 1).text()
            quantity = self.menu_table.item(rows[0], 4).text()
            self.add_menu(code, name, quantity)

    def add_menu(self, *args):
        """
        :return: Pops up a new dialogue to add the menus
        """
        if not args:
            self.popup = AddMenuFromList(parent=self, day=self.day)
            self.popup.exec_()
        else:
            self.popup = MenuQuantityEditPopup(parent=self, day=self.day, code=args[0], name=args[1], quantity=args[2])
            self.popup.exec_()

    def update_menu(self):
        """
        :return:Populates the menu table
        """
        menu = WeeklyMenu(day=self.day)
        menulist = menu.load_dish_per_Day()
        if not menulist == []:
            self.add_row(*menulist)
        else:
            self.menu_table.clearContents()
            self.menu_table.setRowCount(0)

    def popup_edit(self, item):
        """
        Pops up the menu to be edited
        :param item: item clicked
        :return:none
        """
        model_index = self.menu_table.indexFromItem(item)
        row = model_index.row()
        code = self.menu_table.item(row, 0).text()
        name = self.menu_table.item(row, 1).text()
        quantity = self.menu_table.item(row, 4).text()
        self.add_menu(code, name, quantity)

    def add_row(self, *args):
        """creates a new row entry"""
        table = self.menu_table
        if args:
            table.setRowCount(len(args))
            for i, j in enumerate(args):
                item = QTableWidgetItem(j['item_no'])
                table.setItem(i, 0, item)
                item = QTableWidgetItem(j['item'])
                table.setItem(i, 1, item)
                item = QTableWidgetItem(j['category'])
                table.setItem(i, 2, item)
                item = QTableWidgetItem(j['rate'])
                table.setItem(i, 3, item)
                item = QTableWidgetItem(j['per_day'])
                table.setItem(i, 4, item)
                item = QTableWidgetItem(j['available'])
                table.setItem(i, 5, item)
        table.setColumnWidth(0, table.width() / 6)
        table.setColumnWidth(1, table.width() / 6)
        table.setColumnWidth(2, table.width() / 6)
        table.setColumnWidth(3, table.width() / 6)
        table.setColumnWidth(4, table.width() / 6)

    def load_rows(self, event):
        """
        :return:checks and adds new rows
        """
        self.add_row()
示例#15
0
文件: gui.py 项目: tinavas/FSERP
class Gui():
    """main gui class"""
    def __init__(self):
        self.mainwindow = QMainWindow()
        settings.get_settings()
        self.access = tuple(settings.access.items())
        self.progress = QProgressDialog("Setting up modules...", "cancel", 0,
                                        7, self.mainwindow)
        self.progress.setWindowTitle(
            QApplication.translate("MainWindow", str(settings.company), None,
                                   QApplication.UnicodeUTF8))

    def setup(self):
        """initializes the uio of the erp client"""
        self.progress.setFixedWidth(1000)
        self.progress.setCancelButton(None)
        # self.progress.setWindowModality(Qt.WindowModal)
        self.progress.setValue(1)
        self.mainwindow.setObjectName("MainWindow")
        self.mainwindow.resize(832, 668)
        self.mainwindow.setStyleSheet(
            "QToolBar{\n"
            "background: qlineargradient(x1:0, y1:0, x2:1, y2:1,\n"
            "stop:0 rgba(0,0,0),stop:1 rgb(162, 162, 162, 162));\n"
            "border: 0px;\n"
            "}\n"
            "QToolBar > QWidget{\n"
            "color:white;\n"
            "}\n"
            "QToolBar > QWidget:hover {\n"
            "background:transparent;\n"
            " }\n"
            "QToolBar > QWidget:checked {\n"
            "background:transparent;\n"
            " }\n"
            "#MainWindow{\n"
            "background: qlineargradient(x1:0, y1:0, x2:1, y2:1,\n"
            "stop:0 rgba(0,0,0),stop:1 rgb(162, 162, 162, 162));\n"
            "border: 0px;\n"
            "}\n"
            "")
        self.centralWidget = QWidget(self.mainwindow)
        self.centralWidget.setObjectName("centralWidget")
        self.gridLayout_2 = QGridLayout(self.centralWidget)
        self.gridLayout_2.setObjectName("gridLayout_2")
        self.stackedWidget = QStackedWidget(self.centralWidget)
        self.stackedWidget.setStyleSheet("")
        self.stackedWidget.setObjectName("stackedWidget")
        self.shortcut = NewShortcut()
        scroll = QScrollArea()
        scroll.setWidget(self.shortcut.shortcut_setting)
        self.stackedWidget.addWidget(self.shortcut.shortcut_setting)
        self.home_page = QWidget()
        self.home_page.setObjectName("home_page")
        self.gridLayout = QGridLayout(self.home_page)
        self.gridLayout.setObjectName("gridLayout")
        self.billing_frame_2 = QFrame(self.home_page)
        self.billing_frame_2.setStyleSheet(
            "background-image:url(:/images/billing_frame.png);\n"
            "background-repeat: no-repeat;\n"
            "background-position: center;\n"
            "background-color:#6CBED2;")
        self.billing_frame_2.setFrameShape(QFrame.StyledPanel)
        self.billing_frame_2.setFrameShadow(QFrame.Raised)
        self.billing_frame_2.setObjectName("billing_frame_2")
        self.verticalLayout_4 = QVBoxLayout(self.billing_frame_2)
        self.verticalLayout_4.setObjectName("verticalLayout_4")
        spacerItem = QSpacerItem(20, 217, QSizePolicy.Minimum,
                                 QSizePolicy.Expanding)
        self.verticalLayout_4.addItem(spacerItem)
        self.label_10 = QLabel(self.billing_frame_2)
        self.label_10.setStyleSheet("background:transparent;")
        self.label_10.setObjectName("label_10")
        self.verticalLayout_4.addWidget(self.label_10)
        self.gridLayout.addWidget(self.billing_frame_2, 0, 1, 1, 1)
        self.employee_frame_3 = QFrame(self.home_page)
        self.employee_frame_3.setStyleSheet(
            "background-image:url(:/images/employee_frame.png);\n"
            "background-repeat: no-repeat;\n"
            "background-position: center;\n"
            "background-color:#0099CC;")
        self.employee_frame_3.setFrameShape(QFrame.StyledPanel)
        self.employee_frame_3.setFrameShadow(QFrame.Raised)
        self.employee_frame_3.setObjectName("employee_frame_3")
        self.verticalLayout_5 = QVBoxLayout(self.employee_frame_3)
        self.verticalLayout_5.setObjectName("verticalLayout_5")
        spacerItem1 = QSpacerItem(20, 217, QSizePolicy.Minimum,
                                  QSizePolicy.Expanding)
        self.verticalLayout_5.addItem(spacerItem1)
        self.label_11 = QLabel(self.employee_frame_3)
        self.label_11.setStyleSheet("background:transparent;")
        self.label_11.setObjectName("label_11")
        self.verticalLayout_5.addWidget(self.label_11)
        self.gridLayout.addWidget(self.employee_frame_3, 0, 2, 1, 1)
        self.menu_frame_4 = QFrame(self.home_page)
        self.menu_frame_4.setStyleSheet(
            "background-image:url(:/images/menu_frame.png);\n"
            "background-repeat: no-repeat;\n"
            "background-position: center;\n"
            "background-color:#297ACC;")
        self.menu_frame_4.setFrameShape(QFrame.StyledPanel)
        self.menu_frame_4.setFrameShadow(QFrame.Raised)
        self.menu_frame_4.setObjectName("menu_frame_4")
        self.verticalLayout_3 = QVBoxLayout(self.menu_frame_4)
        self.verticalLayout_3.setObjectName("verticalLayout_3")
        spacerItem2 = QSpacerItem(20, 216, QSizePolicy.Minimum,
                                  QSizePolicy.Expanding)
        self.verticalLayout_3.addItem(spacerItem2)
        self.label_12 = QLabel(self.menu_frame_4)
        self.label_12.setStyleSheet("background:transparent;")
        self.label_12.setObjectName("label_12")
        self.verticalLayout_3.addWidget(self.label_12)
        self.gridLayout.addWidget(self.menu_frame_4, 1, 0, 1, 1)
        self.report_frame_5 = QFrame(self.home_page)
        self.report_frame_5.setStyleSheet(
            "background-image:url(:/images/report_frame.png);\n"
            "background-repeat: no-repeat;\n"
            "background-position: center;\n"
            "background-color:#006BB2;")
        self.report_frame_5.setFrameShape(QFrame.StyledPanel)
        self.report_frame_5.setFrameShadow(QFrame.Raised)
        self.report_frame_5.setObjectName("report_frame_5")
        self.verticalLayout_6 = QVBoxLayout(self.report_frame_5)
        self.verticalLayout_6.setObjectName("verticalLayout_6")
        spacerItem3 = QSpacerItem(20, 216, QSizePolicy.Minimum,
                                  QSizePolicy.Expanding)
        self.verticalLayout_6.addItem(spacerItem3)
        self.label_13 = QLabel(self.report_frame_5)
        self.label_13.setStyleSheet("background:transparent;")
        self.label_13.setObjectName("label_13")
        self.verticalLayout_6.addWidget(self.label_13)
        self.gridLayout.addWidget(self.report_frame_5, 1, 1, 1, 1)
        self.waste_frame_6 = QFrame(self.home_page)
        self.waste_frame_6.setStyleSheet(
            "background-image:url(:/images/waste_frame.png);\n"
            "background-repeat: no-repeat;\n"
            "background-position: center;\n"
            "background-color:#003D7A;")
        self.waste_frame_6.setFrameShape(QFrame.StyledPanel)
        self.waste_frame_6.setFrameShadow(QFrame.Raised)
        self.waste_frame_6.setObjectName("waste_frame_6")
        self.verticalLayout_7 = QVBoxLayout(self.waste_frame_6)
        self.verticalLayout_7.setObjectName("verticalLayout_7")
        spacerItem4 = QSpacerItem(20, 216, QSizePolicy.Minimum,
                                  QSizePolicy.Expanding)
        self.verticalLayout_7.addItem(spacerItem4)
        self.label_14 = QLabel(self.waste_frame_6)
        self.label_14.setStyleSheet("background:transparent;")
        self.label_14.setObjectName("label_14")
        self.verticalLayout_7.addWidget(self.label_14)
        self.gridLayout.addWidget(self.waste_frame_6, 1, 2, 1, 1)
        self.inventory_frame_1 = QFrame(self.home_page)
        self.inventory_frame_1.setStyleSheet(
            "background-image:url(:/images/inventory_frame.png);\n"
            "background-repeat: no-repeat;\n"
            "background-position: center;\n"
            "background-color:#ADEBFF;")
        self.inventory_frame_1.setFrameShape(QFrame.StyledPanel)
        self.inventory_frame_1.setFrameShadow(QFrame.Raised)
        self.inventory_frame_1.setObjectName("inventory_frame_1")
        self.verticalLayout_2 = QVBoxLayout(self.inventory_frame_1)
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        spacerItem5 = QSpacerItem(20, 217, QSizePolicy.Minimum,
                                  QSizePolicy.Expanding)
        self.verticalLayout_2.addItem(spacerItem5)
        self.label_9 = QLabel(self.inventory_frame_1)
        self.label_9.setStyleSheet("background:transparent;")
        self.label_9.setObjectName("label_9")
        self.verticalLayout_2.addWidget(self.label_9)
        self.gridLayout.addWidget(self.inventory_frame_1, 0, 0, 1, 1)
        self.stackedWidget.addWidget(self.home_page)
        self.detail_page = QWidget()
        self.detail_page.setObjectName("detail_page")
        self.horizontalLayout_2 = QHBoxLayout(self.detail_page)
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.main_tabWidget = QTabWidget(self.detail_page)
        self.main_tabWidget.setAutoFillBackground(False)
        self.main_tabWidget.setStyleSheet("")
        self.main_tabWidget.setTabPosition(QTabWidget.West)
        self.main_tabWidget.setIconSize(QSize(60, 60))
        self.main_tabWidget.setElideMode(Qt.ElideNone)
        self.main_tabWidget.setObjectName("main_tabWidget")
        ##initializes the tabs
        self.add_tabs()
        self.main_tabWidget.setFocusPolicy(Qt.StrongFocus)
        self.main_tabWidget.focusInEvent = self.change_focus
        self.main_tabWidget.currentChanged.connect(self.change_focus)
        self.stackedWidget.currentChanged.connect(self.change_focus)
        ######
        self.horizontalLayout_2.addWidget(self.main_tabWidget)
        self.stackedWidget.addWidget(self.detail_page)
        if ('Admin', True) in self.access:
            self.stackedWidget.addWidget(Admin(self.mainwindow))
        notification = NotificationTab()
        tab = notification.notificationTab_tab_4
        tab.custom_class_object = notification  # class_object is used to access the api through the
        self.stackedWidget.addWidget(tab)
        self.gridLayout_2.addWidget(self.stackedWidget, 0, 0, 1, 1)
        self.mainwindow.setCentralWidget(self.centralWidget)
        self.menuBar = QMenuBar(self.mainwindow)
        self.menuBar.setGeometry(QRect(0, 0, 832, 29))
        self.menuBar.setObjectName("menuBar")
        self.mainwindow.setMenuBar(self.menuBar)
        self.mainToolBar = QToolBar(self.mainwindow)
        self.mainToolBar.setLayoutDirection(Qt.RightToLeft)
        self.mainToolBar.setStyleSheet("")
        self.mainToolBar.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
        self.mainToolBar.setObjectName("mainToolBar")
        self.mainwindow.addToolBar(Qt.TopToolBarArea, self.mainToolBar)
        self.statusBar = QStatusBar(self.mainwindow)
        self.statusBar.setObjectName("statusBar")
        self.mainwindow.setStatusBar(self.statusBar)
        self.toolBar = QToolBar(self.mainwindow)
        self.toolBar.setLayoutDirection(Qt.RightToLeft)
        self.toolBar.setStyleSheet("")
        self.toolBar.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
        self.toolBar.setObjectName("toolBar")
        self.mainwindow.addToolBar(Qt.TopToolBarArea, self.toolBar)
        self.actionNotification = QAction(self.mainwindow)
        self.actionNotification.setCheckable(True)
        self.actionNotification.setChecked(False)
        self.actionNotification.setEnabled(True)
        icon6 = QIcon()
        icon6.addPixmap(QPixmap(":/images/notification.png"), QIcon.Normal,
                        QIcon.Off)
        self.actionNotification.setIcon(icon6)
        self.actionNotification.setAutoRepeat(True)
        self.actionNotification.setVisible(True)
        self.actionNotification.setIconVisibleInMenu(False)
        self.actionNotification.setObjectName("actionNotification")
        self.actionNotification
        self.actionAdmin = QAction(self.mainwindow)
        # self.actionAdmin.setCheckable(True)
        icon7 = QIcon()
        icon7.addPixmap(QPixmap(":/images/admin.png"), QIcon.Normal, QIcon.Off)
        self.actionAdmin.setIcon(icon7)
        self.actionAdmin.setObjectName("actionAdmin")
        self.actionRefresh = QAction(self.mainwindow)
        icon8 = QIcon()
        icon8.addPixmap(QPixmap(":/images/refresh.png"), QIcon.Normal,
                        QIcon.Off)
        self.actionRefresh.setIcon(icon8)
        self.actionRefresh.setObjectName("actionRefresh")
        self.actionHome = QAction(self.mainwindow)
        # self.actionHome.setCheckable(True)
        icon9 = QIcon()
        icon9.addPixmap(QPixmap(":/images/home.png"), QIcon.Normal, QIcon.Off)
        self.actionHome.setIcon(icon9)
        self.actionHome.setObjectName("actionHome")
        self.actionSettings = QAction(self.mainwindow)
        icon10 = QIcon()
        icon10.addPixmap(QPixmap(":/images/settings.png"), QIcon.Normal,
                         QIcon.Off)
        self.actionSettings.setIcon(icon10)
        self.actionSettings.setObjectName("actionRefresh")
        self.toolBar.addAction(self.actionNotification)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.actionAdmin)
        if ('Admin', True) in self.access:
            self.toolBar.addSeparator()
        else:
            self.actionAdmin.setVisible(False)
        self.toolBar.addAction(self.actionHome)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.actionRefresh)
        self.toolBar.addSeparator()
        self.toolBar.addAction(self.actionSettings)
        ##retranslates
        self.mainwindow.setWindowTitle(
            QApplication.translate("MainWindow", settings.company, None,
                                   QApplication.UnicodeUTF8))
        self.label_10.setText(
            QApplication.translate(
                "MainWindow",
                "<html><head/><body><p align=\"center\">BILLING</p></body></html>",
                None, QApplication.UnicodeUTF8))
        self.label_11.setText(
            QApplication.translate(
                "MainWindow",
                "<html><head/><body><p align=\"center\">EMPLOYEE</p></body></html>",
                None, QApplication.UnicodeUTF8))
        self.label_12.setText(
            QApplication.translate(
                "MainWindow",
                "<html><head/><body><p align=\"center\">MENU</p></body></html>",
                None, QApplication.UnicodeUTF8))
        self.label_13.setText(
            QApplication.translate(
                "MainWindow",
                "<html><head/><body><p align=\"center\">REPORT</p></body></html>",
                None, QApplication.UnicodeUTF8))
        self.label_14.setText(
            QApplication.translate(
                "MainWindow",
                "<html><head/><body><p align=\"center\">WASTE</p></body></html>",
                None, QApplication.UnicodeUTF8))
        self.label_9.setText(
            QApplication.translate(
                "MainWindow",
                "<html><head/><body><p align=\"center\">INVENTORY</p></body></html>",
                None, QApplication.UnicodeUTF8))
        self.inventory_frame_1.setToolTip(
            QApplication.translate("MainWindow", "Go to the Inventory Tab",
                                   None, QApplication.UnicodeUTF8))
        self.billing_frame_2.setToolTip(
            QApplication.translate("MainWindow", "Go to the Billing Tab", None,
                                   QApplication.UnicodeUTF8))
        self.employee_frame_3.setToolTip(
            QApplication.translate("MainWindow", "Go to the Employee Tab",
                                   None, QApplication.UnicodeUTF8))
        self.menu_frame_4.setToolTip(
            QApplication.translate("MainWindow", "Go to the Menu Tab", None,
                                   QApplication.UnicodeUTF8))
        self.report_frame_5.setToolTip(
            QApplication.translate("MainWindow", "Go to the Report Tab", None,
                                   QApplication.UnicodeUTF8))
        self.waste_frame_6.setToolTip(
            QApplication.translate("MainWindow", "Go to the Waste Tab", None,
                                   QApplication.UnicodeUTF8))
        self.toolBar.setWindowTitle(
            QApplication.translate("MainWindow", "toolBar", None,
                                   QApplication.UnicodeUTF8))
        self.actionNotification.setText("&&Notification")
        # QApplication.translate("MainWindow", "&Notification", None, QApplication.UnicodeUTF8))
        self.actionNotification.setToolTip(
            QApplication.translate("MainWindow",
                                   "Click to see new notifications", None,
                                   QApplication.UnicodeUTF8))
        # self.actionNotification.setShortcut(
        # QApplication.translate("MainWindow", "Ctrl+Shift+N", None, QApplication.UnicodeUTF8))
        self.actionAdmin.setText('&&Admin')
        # QApplication.translate("MainWindow", "Admin", None, QApplication.UnicodeUTF8))
        self.actionAdmin.setToolTip(
            QApplication.translate("MainWindow",
                                   "Click to go to admin interface", None,
                                   QApplication.UnicodeUTF8))
        # self.actionAdmin.setShortcut(
        # QApplication.translate("MainWindow", "Ctrl+Shift+A", None, QApplication.UnicodeUTF8))
        self.actionRefresh.setText("&&Refresh")
        # QApplication.translate("MainWindow", "Refresh", None, QApplication.UnicodeUTF8))
        self.actionRefresh.setToolTip(
            QApplication.translate("MainWindow",
                                   "refreshes the data from the server", None,
                                   QApplication.UnicodeUTF8))
        # self.actionRefresh.setShortcut(
        # QApplication.translate("MainWindow", "Ctrl+Shift+R", None, QApplication.UnicodeUTF8))
        self.actionHome.setText('&&Home')
        # QApplication.translate("MainWindow", "Home", None, QApplication.UnicodeUTF8))
        self.actionHome.setToolTip(
            QApplication.translate("MainWindow", "Go back to the home screen",
                                   None, QApplication.UnicodeUTF8))
        self.actionSettings.setText('&&Settings')
        # QApplication.translate("MainWindow", "Settings", None, QApplication.UnicodeUTF8))
        self.actionSettings.setToolTip(
            QApplication.translate("MainWindow", "Go to the settings panel",
                                   None, QApplication.UnicodeUTF8))
        # self.actionHome.setShortcut(
        #     QApplication.translate("MainWindow", "Ctrl+Shift+H", None, QApplication.UnicodeUTF8))
        self.stackedWidget.setCurrentIndex(1)
        self.main_tabWidget.setCurrentIndex(0)

        self.ob = self.main_tabWidget.tabBar()
        # self.add_tool_tip(self.ob) todo avoided due to segmentation fault error, left for future fixes
        self.tb = EventHandlerForTabBar()
        self.ob.installEventFilter(self.tb)

        QMetaObject.connectSlotsByName(self.mainwindow)

    def add_tabs(self):
        """
        adds new tabs
        """
        global logger
        if ('Inventory', True) in self.access:
            logger.info('initiating Inventory')
            icon = QIcon()
            icon.addPixmap(QPixmap(":/images/inventory.png"), QIcon.Normal,
                           QIcon.Off)
            from inventory.inventory import Inventory

            inventory = Inventory()
            # inventory.inventory_tab_1.setToolTip("Inventory Section")
            self.main_tabWidget.addTab(inventory.inventory_tab_1, icon, "")
            inventory.inventory_detail_tabWidget.setCurrentIndex(0)
        else:
            self.inventory_frame_1.setVisible(False)
        self.progress.setLabelText('Inventory Done....')
        self.progress.setValue(2)

        if ('Billing', True) in self.access:
            logger.info('initiating Billing')
            icon1 = QIcon()
            icon1.addPixmap(QPixmap(":/images/billing.png"), QIcon.Normal,
                            QIcon.Off)
            from billing.billing import Billing

            bill = Billing()
            # bill.billing_tab_2.setToolTip("Billing Section")
            self.main_tabWidget.addTab(bill.billing_tab_2, icon1, "")
            bill.billing_detail_tabWidget.setCurrentIndex(0)
        else:
            self.billing_frame_2.setVisible(False)
        self.progress.setLabelText('Billing Done...')
        self.progress.setValue(3)

        if ('Employee', True) in self.access:
            logger.info('initiating Employee')
            icon2 = QIcon()
            icon2.addPixmap(QPixmap(":/images/employee.png"), QIcon.Normal,
                            QIcon.Off)
            from employee.employee import Employee

            employee = Employee()
            # employee.employee_tab_3.setToolTip("Employee Section")
            self.main_tabWidget.addTab(employee.employee_tab_3, icon2, "")
            employee.employee_detail_tabWidget.setCurrentIndex(0)
        else:
            self.employee_frame_3.setVisible(False)
        self.progress.setLabelText('Employee Done...')
        self.progress.setValue(4)

        if ('Menu', True) in self.access:
            logger.info('initiating Menu')
            icon3 = QIcon()
            icon3.addPixmap(QPixmap(":/images/menu.png"), QIcon.Normal,
                            QIcon.Off)
            from menu.menu import Menu

            menu = Menu()
            # menu.menu_tab_4.setToolTip("Menu Section")
            self.main_tabWidget.addTab(menu.menu_tab_4, icon3, "")
            menu.menu_detail_tabWidget.setCurrentIndex(0)
        else:
            self.menu_frame_4.setVisible(False)
        self.progress.setLabelText('Menu Done....')
        self.progress.setValue(5)

        if ('Report', True) in self.access:
            logger.info('initiating Report')
            icon4 = QIcon()
            icon4.addPixmap(QPixmap(":/images/report.png"), QIcon.Normal,
                            QIcon.Off)
            from report.report import Report

            report = Report()
            # report.report_tab_5.setToolTip("Report Section")
            self.main_tabWidget.addTab(report.report_tab_5, icon4, "")
            report.report_detail_tabWidget.setCurrentIndex(0)
        else:
            self.report_frame_5.setVisible(False)
        self.progress.setLabelText('Report Done....')
        self.progress.setValue(6)

        if ('Waste', True) in self.access:
            logger.info('initiating Waste')
            icon5 = QIcon()
            icon5.addPixmap(QPixmap(":/images/waste.png"), QIcon.Normal,
                            QIcon.Off)
            from waste.waste import Waste

            waste = Waste()
            # waste.waste_tab_6.setToolTip("Waste Section")
            self.main_tabWidget.addTab(waste.waste_tab_6, icon5, "")
            waste.waste_detail_tabWidget.setCurrentIndex(0)
        else:
            self.waste_frame_6.setVisible(False)
        self.progress.setLabelText('Waste Done....')
        self.progress.setValue(7)

    def change_focus(self, event=None):
        """
        focus method to set focus to a tab to initialize the corresponding events of the tab
        """
        wid = self.main_tabWidget.currentWidget()
        if wid:
            if wid.isVisible():
                # print wid.objectName()
                # print '1y'
                wid.setFocus()

    def add_tool_tip(
        self, ob
    ):  # todo not working causing segmentation fault, avoided calling this function
        """
        method to add tool tip to the tabs
        :param ob: Tab bar
        """
        obj = ob
        count = obj.count()
        hardcode = {
            0: 'Inventory Section',
            1: "Billing Section",
            2: "Employee Section",
            3: "Menu Section",
            4: "Report Section",
            5: "Waste Section"
        }
        for i in range(count):
            obj.setTabToolTip(i, hardcode[i])
示例#16
0
文件: report.py 项目: tinavas/FSERP
class Hygiene():
    """ The Hygiene Tab
    """
    global logger

    def __init__(self):
        ####
        logger.info('Inside Hygiene')
        self.reporthygiene_tab_2 = QWidget()
        self.reporthygiene_tab_2.setObjectName("reporthygiene_tab_2")
        self.vertical_23 = QVBoxLayout(self.reporthygiene_tab_2)
        self.vertical_23.setObjectName("vertical_23")
        self.label_1 = QLabel(self.reporthygiene_tab_2)
        self.vertical_23.addWidget(self.label_1)
        self.report_hyginepest_table = QTableWidget(self.reporthygiene_tab_2)
        self.report_hyginepest_table.setObjectName("report_hyginepest_table")
        self.report_hyginepest_table.setColumnCount(5)
        self.report_hyginepest_table.setRowCount(0)
        self.report_hyginepest_table.setSelectionBehavior(
            QAbstractItemView.SelectRows)
        item = QTableWidgetItem()
        self.report_hyginepest_table.setHorizontalHeaderItem(0, item)
        item = QTableWidgetItem()
        self.report_hyginepest_table.setHorizontalHeaderItem(1, item)
        item = QTableWidgetItem()
        self.report_hyginepest_table.setHorizontalHeaderItem(2, item)
        item = QTableWidgetItem()
        self.report_hyginepest_table.setHorizontalHeaderItem(3, item)
        item = QTableWidgetItem()
        self.report_hyginepest_table.setHorizontalHeaderItem(4, item)
        self.report_hyginepest_table.horizontalHeader(
        ).setCascadingSectionResizes(True)
        self.report_hyginepest_table.horizontalHeader().setStretchLastSection(
            True)
        self.report_hyginepest_table.verticalHeader(
        ).setCascadingSectionResizes(True)
        self.vertical_23.addWidget(self.report_hyginepest_table)
        self.horizontal_21 = QHBoxLayout()
        self.report_hyginepest_newrow_buttuon = QPushButton(
            self.reporthygiene_tab_2)
        self.report_hyginepest_newrow_buttuon.setObjectName(
            "report_hyginepest_newrow_buttuon")
        self.horizontal_21.addWidget(self.report_hyginepest_newrow_buttuon)
        spacerItem23 = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                   QSizePolicy.Minimum)
        self.horizontal_21.addItem(spacerItem23)
        # self.report_hyginepest_save_button = QPushButton(self.reporthygiene_tab_2)
        # self.report_hyginepest_save_button.setObjectName("report_hyginepest_save_button")
        # self.horizontal_21.addWidget(self.report_hyginepest_save_button)
        self.vertical_23.addLayout(self.horizontal_21)
        self.label_2 = QLabel(self.reporthygiene_tab_2)
        self.vertical_23.addWidget(self.label_2)
        self.report_hyginewater_table = QTableWidget(self.reporthygiene_tab_2)
        self.report_hyginewater_table.setObjectName("report_hyginewater_table")
        self.report_hyginewater_table.setColumnCount(5)
        self.report_hyginewater_table.setRowCount(0)
        self.report_hyginewater_table.setSelectionBehavior(
            QAbstractItemView.SelectRows)
        item = QTableWidgetItem()
        self.report_hyginewater_table.setHorizontalHeaderItem(0, item)
        item = QTableWidgetItem()
        self.report_hyginewater_table.setHorizontalHeaderItem(1, item)
        item = QTableWidgetItem()
        self.report_hyginewater_table.setHorizontalHeaderItem(2, item)
        item = QTableWidgetItem()
        self.report_hyginewater_table.setHorizontalHeaderItem(3, item)
        item = QTableWidgetItem()
        self.report_hyginewater_table.setHorizontalHeaderItem(4, item)
        self.report_hyginewater_table.horizontalHeader(
        ).setCascadingSectionResizes(True)
        self.report_hyginewater_table.horizontalHeader().setStretchLastSection(
            True)
        self.report_hyginewater_table.verticalHeader(
        ).setCascadingSectionResizes(True)
        self.vertical_23.addWidget(self.report_hyginewater_table)
        self.horizontal_22 = QHBoxLayout()
        self.report_hyginewater_newrow_buttuon = QPushButton(
            self.reporthygiene_tab_2)
        self.report_hyginewater_newrow_buttuon.setObjectName(
            "report_hyginewater_newrow_buttuon")
        self.horizontal_22.addWidget(self.report_hyginewater_newrow_buttuon)
        spacerItem24 = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                   QSizePolicy.Minimum)
        self.horizontal_22.addItem(spacerItem24)
        # self.report_hyginewater_save_button = QPushButton(self.reporthygiene_tab_2)
        # self.report_hyginewater_save_button.setObjectName("report_hyginewater_save_button")
        # self.horizontal_22.addWidget(self.report_hyginewater_save_button)
        self.vertical_23.addLayout(self.horizontal_22)
        ### retanslate
        self.label_1.setText(
            QApplication.translate("MainWindow", "Pest Test Report", None,
                                   QApplication.UnicodeUTF8))
        self.report_hyginepest_table.horizontalHeaderItem(0).setText(
            QApplication.translate("MainWindow", "Code", None,
                                   QApplication.UnicodeUTF8))
        self.report_hyginepest_table.horizontalHeaderItem(1).setText(
            QApplication.translate("MainWindow", "Date", None,
                                   QApplication.UnicodeUTF8))
        self.report_hyginepest_table.horizontalHeaderItem(2).setText(
            QApplication.translate("MainWindow", "Organization Name", None,
                                   QApplication.UnicodeUTF8))
        self.report_hyginepest_table.horizontalHeaderItem(3).setText(
            QApplication.translate("MainWindow", "Test", None,
                                   QApplication.UnicodeUTF8))
        self.report_hyginepest_table.horizontalHeaderItem(4).setText(
            QApplication.translate("MainWindow", "Description", None,
                                   QApplication.UnicodeUTF8))
        self.report_hyginepest_newrow_buttuon.setText(
            QApplication.translate("MainWindow", "New Row", None,
                                   QApplication.UnicodeUTF8))
        # self.report_hyginepest_save_button.setText(
        # QApplication.translate("MainWindow", "Save", None, QApplication.UnicodeUTF8))
        self.label_2.setText(
            QApplication.translate("MainWindow", "Water Test Report", None,
                                   QApplication.UnicodeUTF8))
        self.report_hyginewater_table.horizontalHeaderItem(0).setText(
            QApplication.translate("MainWindow", "Code", None,
                                   QApplication.UnicodeUTF8))
        self.report_hyginewater_table.horizontalHeaderItem(1).setText(
            QApplication.translate("MainWindow", "Date", None,
                                   QApplication.UnicodeUTF8))
        self.report_hyginewater_table.horizontalHeaderItem(2).setText(
            QApplication.translate("MainWindow", "Organization Name", None,
                                   QApplication.UnicodeUTF8))
        self.report_hyginewater_table.horizontalHeaderItem(3).setText(
            QApplication.translate("MainWindow", "Test", None,
                                   QApplication.UnicodeUTF8))
        self.report_hyginewater_table.horizontalHeaderItem(4).setText(
            QApplication.translate("MainWindow", "Description", None,
                                   QApplication.UnicodeUTF8))
        self.report_hyginewater_newrow_buttuon.setText(
            QApplication.translate("MainWindow", "New Row", None,
                                   QApplication.UnicodeUTF8))
        # self.report_hyginewater_save_button.setText(
        #     QApplication.translate("MainWindow", "Save", None, QApplication.UnicodeUTF8))
        ###signals and slots && other stuffs
        self.pest = Pest()
        self.water = Water()
        self.report_hyginepest_table.setEditTriggers(
            QAbstractItemView.NoEditTriggers)
        self.report_hyginewater_table.setEditTriggers(
            QAbstractItemView.NoEditTriggers)
        self.load_table_rows()
        self.report_hyginepest_table.itemDoubleClicked.connect(
            self.popup_pest_edit)
        self.report_hyginewater_table.itemDoubleClicked.connect(
            self.popup_water_edit)
        self.reporthygiene_tab_2.focusInEvent = self.load_rows  # very important for focus
        self.report_hyginepest_newrow_buttuon.clicked.connect(
            self.new_pestTest)  # if no focus available then we need lambda
        self.report_hyginewater_newrow_buttuon.clicked.connect(
            self.new_waterTest)

    def new_pestTest(self, code=None):
        """
        The pest report popup generator
        :param code: The code of the pest report
        """
        pop = HygieneReportPop(parent=self, table='pest_table', code=code)
        pop.setWindowFlags(Qt.WindowTitleHint)
        pop.exec_()
        self.load_table_rows()

    def new_waterTest(self, code=None):
        """
        The water report popup generator
        :param code: The code of the water report
        """
        pop = HygieneReportPop(parent=self, table='water_table', code=code)
        pop.setWindowFlags(Qt.WindowTitleHint)
        pop.exec_()
        self.load_table_rows()

    def load_table_rows(self):
        """
        Populates the rows for both the table
        """
        logger.info('Hygiene save table initiated')
        try:
            data = self.pest.load_report()
            if data[0]:
                self.add_table_rows('pest_table', *data[1])
                if not data[1]:
                    self.report_hyginepest_table.clearContents()
                    self.report_hyginepest_table.setRowCount(0)
            data = self.water.load_report()
            if data[0]:
                self.add_table_rows('water_table', *data[1])
                if not data[1]:
                    self.report_hyginewater_table.clearContents()
                    self.report_hyginewater_table.setRowCount(0)
        except Exception:
            if settings.level == 10:
                logger.exception('raised exception')
            return False, 'Some Internal Error'

    def popup_pest_edit(self, item):
        """
        Pops up the menu to be edited
        :param item: item clicked
        """
        table = self.report_hyginepest_table
        model_index = table.indexFromItem(item)
        row = model_index.row()
        self.new_pestTest(table.item(row, 0).text())

    def popup_water_edit(self, item):
        """
        Pops up the menu to be edited
        :param item: item clicked
        """
        table = self.report_hyginewater_table
        model_index = table.indexFromItem(item)
        row = model_index.row()
        self.new_waterTest(table.item(row, 0).text())

    def add_table_rows(self, tablename, *args):
        """
        adds a new row to the pes table
        """
        if tablename == 'pest_table':
            table = self.report_hyginepest_table
        else:
            table = self.report_hyginewater_table
        if args:
            table.setRowCount(len(args))
            for row, data in enumerate(args):
                table.setItem(row, 0, QTableWidgetItem(data['code']))
                table.setItem(row, 1, QTableWidgetItem(data['date']))
                table.setItem(row, 2, QTableWidgetItem(data['organization']))
                table.setItem(row, 3, QTableWidgetItem(data['test']))
                table.setItem(row, 4, QTableWidgetItem(data['description']))
        table.setColumnWidth(0, (table.width() / 5) * 0.5)
        table.setColumnWidth(1, (table.width() / 5) * 0.5)
        table.setColumnWidth(2, table.width() / 5)
        table.setColumnWidth(3, table.width() / 5)

    def load_rows(self, event):
        """
        loads the rows of the tables
        """
        self.add_table_rows(tablename='pest_table')
        self.add_table_rows(tablename='water_table')