Esempio n. 1
0
    def __init__(self, master, q_visibility):
        master.title('Login')
        self.master = master
        self.pin_entry = None
        self.q_visibility = q_visibility
        self.statusbar = StatusBar(self.master,
                                   bd=1,
                                   relief=SUNKEN,
                                   anchor=CENTER)
        self.statusbar.pack(side=BOTTOM, fill=X)

        # Setup GPIO
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(LED_LAUNCHREADY, GPIO.OUT)
    def __init__(self, master, q_visibility):
        master.title('Login')
        self.master = master
        self.pin_entry = None
        self.q_visibility = q_visibility
        self.statusbar = StatusBar(self.master, bd=1, relief=SUNKEN, anchor=CENTER)
        self.statusbar.pack(side=BOTTOM, fill=X)

        # Setup GPIO
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(LED_LAUNCHREADY, GPIO.OUT)
Esempio n. 3
0
    def __init__(self, model):
        """Inits the class."""
        Subject.__init__(self)
        QMainWindow.__init__(self)

        # Set model
        self.model = model

        # Create interface elements
        self.menu_bar = MenuBar(self)
        self.tool_bar = ToolBar(self)
        self.exif_area = ExifWidget(self)
        self.image_area = ImageWidget(self)
        self.status_bar = StatusBar()
        about_text = 'IEViewer 1.0' \
                     '<br><br>' \
                     'Copyright © 2021 by' \
                     '<br>' \
                     'Paula Mihalcea' \
                     '<br>' \
                     '<a href="mailto:[email protected]">[email protected]</a>' \
                     '<br><br>' \
                     'This program uses PyQt5, a comprehensive set of Python bindings for Qt v5. Qt is a set of cross-platform C++ libraries that implement high-level APIs for accessing many aspects of modern desktop and mobile systems.\n' \
                     '<br><br>' \
                     'PyQt5 is copyright © Riverbank Computing Limited. Its homepage is <a href="https://www.riverbankcomputing.com/software/pyqt/">https://www.riverbankcomputing.com/software/pyqt/</a>.' \
                     '<br><br>' \
                     'No genasi were harmed in the making of this application. <a href="https://www.dndbeyond.com/races/genasi#WaterGenasi">#GenasiLivesMatter#NereisThalian</a>'
        self.about = AboutWidget('About IEViewer',
                                 about_text,
                                 image_path='icons/about_img.png')

        # Disable GUI elements that are unavailable when no image is opened
        self.menu_bar.disable_widgets()
        self.exif_area.hide()

        # Set layout
        self.setCentralWidget(Layout(self).central_widget)

        # Set window properties
        self.set_window_properties()

        # Install additional event filters
        self.image_area.installEventFilter(self)
Esempio n. 4
0
class ScreenLogin(Tk):
    def __init__(self, master, q_visibility):
        master.title('Login')
        self.master = master
        self.pin_entry = None
        self.q_visibility = q_visibility
        self.statusbar = StatusBar(self.master,
                                   bd=1,
                                   relief=SUNKEN,
                                   anchor=CENTER)
        self.statusbar.pack(side=BOTTOM, fill=X)

        # Setup GPIO
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(LED_LAUNCHREADY, GPIO.OUT)

    def refresh_timer(self):

        self.statusbar.set('Local IP: %s', get_ip_address('eth0'))
        status = self.q_visibility.get()

        if status == 'SHOW':
            self.master.deiconify()
        elif status == 'HIDE':
            self.master.withdraw()

        # Call reload_timer after 1sec
        self.master.after(1000, self.refresh_timer)

    def process_key(self, key):
        logging.debug('Button Pressed: ' + key)

        if (key == 'Clear'):
            self.pin_entry.delete(0, END)
            return None

        if (key == 'Login'):
            if self.pin_entry.get() == '2117':
                tkMessageBox.showinfo(title="Welcome", message="Launch Ready")
                GPIO.output(LED_LAUNCHREADY, GPIO.HIGH)
            else:
                tkMessageBox.showwarning(title="Invalid attempt",
                                         message="Incorrect!")
                GPIO.output(LED_LAUNCHREADY, GPIO.LOW)

            self.pin_entry.delete(0, END)
            return None

        self.pin_entry.insert(END, key)

    def show(self):

        buttons_frame = Frame(self.master)
        buttons_frame.pack(side=TOP, fill=Y)

        btn_list = [
            '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'Clear', 'Login'
        ]

        # this also shows the calculator's button layout
        rel = 'ridge'

        # Draw the butons pad
        row = 1
        col = 0
        for b in btn_list:
            cmd = partial(self.process_key, b)

            # partial takes care of function and argument
            Button(buttons_frame,
                   command=cmd,
                   text=b,
                   width=5,
                   height=2,
                   relief=rel).grid(row=row, column=col)

            col += 1
            if col >= 3:
                col = 0
                row += 1

        pinentry_form = Frame(self.master)
        pinentry_form.pack(side=TOP, fill=BOTH)
        self.pin_entry = Entry(pinentry_form,
                               show="•",
                               font="Helvetica 24 bold",
                               justify="center")
        self.pin_entry.pack(side=BOTTOM)

        self.refresh_timer()
Esempio n. 5
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setWindowIcon(QIcon(":/small_icons/cryotec_logo.png"))
        self.setWindowTitle(u"Криотек Клиент")
        self.resize(1024,768)
        from views import FixWithButtonsView, ReportWithButtonsView, \
                MaintenanceWithButtonsView, CheckupWithButtonsView, MachinePanel

        from widgets import ServerResponceDock, ShowModelInfoDock, StatusBar

        from models import models
        self.machine_tree = MachinePanel()


        self.info_dock = ShowModelInfoDock(u"Информация", self)
        self.info_dock.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea |\
                                Qt.BottomDockWidgetArea)

        self.machine_tree.view.modelSelectionChanged.connect(self.info_dock.view.modelChanged)
        self.machine_tree.view.modelSelectionCleared.connect(self.info_dock.view.modelCleared)



        self.note_views = {
                u"Неисправности":ReportWithButtonsView(None),
                u"Ремонты":FixWithButtonsView(None),
                u"Техобслуживания":MaintenanceWithButtonsView(None),
                u"Контроли моточасов":CheckupWithButtonsView(None),
                }
        #self.machine_tree.setSelectionMode(QAbstractItemView.MultiSelection)
        self.notebook = CentralNotebook(self.machine_tree, self.info_dock, self.note_views)

        self.setCentralWidget(self.notebook)
        
        
        
        machineDockWidget = QDockWidget(u"Оборудование", self)
        machineDockWidget.setObjectName("machine_dock")

        machineDockWidget.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
        machineDockWidget.setWidget(self.machine_tree)

        self.responce_dock = ServerResponceDock(u"Ответ от сервера", self)
        self.responce_dock.setAllowedAreas(Qt.RightDockWidgetArea|Qt.BottomDockWidgetArea)


        self.settings_dialog = SettingsDialog(models_manager=models)
        settingsAction = QAction(QIcon(":/icons/setting_tools.png"), u"Настройки", self)
        settingsAction.triggered.connect(self.settings_dialog.exec_)

        self.about_dialog = AboutDialog(self)
        aboutAction = QAction(QIcon(":/icons/information.png"), u"О программе...", self)
        aboutAction.triggered.connect(self.about_dialog.exec_)
        helpAction = QAction(u"Справка", self)
        helpAction.triggered.connect(lambda: QDesktopServices.openUrl(QUrl("doc/index.html")))

        saveAction = QAction(QIcon(":/icons/save_as.png"), u"Сохранить", self)
        saveAction.triggered.connect(self.save_to_file)

        openAction = QAction(QIcon(":/icons/folder.png"), u"Открыть", self)
        openAction.triggered.connect(self.load_from_file)


        self.syncAction = QAction(QIcon(":/icons/update.png"), u"Синхронизировать", self)
        self.syncAction.triggered.connect(self.synchronize)
        syncButton = QToolButton()
        syncButton.setDefaultAction(self.syncAction)
        syncButton.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
#        syncStatusBarButton = QToolButton()
#        syncStatusBarButton.setDefaultAction(self.syncAction)



        machinetreepanelAction = machineDockWidget.toggleViewAction()
        machinetreepanelAction.setIcon(QIcon(":/icons/application_side_tree.png"))

        responcedockAction = self.responce_dock.toggleViewAction()

        infodockAction = self.info_dock.toggleViewAction()


#        self.statusBar().addPermanentWidget(syncStatusBarButton)

        quitAction = QAction(u"Выход", self)
        quitAction.triggered.connect(self.close)

        self.status_bar = StatusBar(parent=self)
        self.setStatusBar(self.status_bar)

        self.mm = models
        self.mm.add_notify_dumped(self.synced)
        self.mm.add_notify_undumped(self.unsynced)
        self.mm.add_notify_dumped(self.status_bar.synced)
        self.mm.add_notify_undumped(self.status_bar.unsynced)
        self.mm.add_notify_dumped(self.responce_dock.show_responce)
        self.mm.add_notify_change_user(self.status_bar.userChanged)
        self.status_bar.userChanged(self.mm.get_current_user())
        self.status_bar.clicked.connect(\
                lambda: self.info_dock.view.modelChanged(self.mm.get_current_user()))

        self.addDockWidget(Qt.LeftDockWidgetArea, machineDockWidget)
        self.addDockWidget(Qt.BottomDockWidgetArea, self.info_dock)
        self.addDockWidget(Qt.BottomDockWidgetArea, self.responce_dock)
        self.setCorner(Qt.BottomLeftCorner, Qt.LeftDockWidgetArea)


        mainmenu = self.menuBar()
        filemenu = mainmenu.addMenu(u"Файл")
        viewmenu = mainmenu.addMenu(u"Вид")
        connmenu = mainmenu.addMenu(u"Соединение")
        helpmenu = mainmenu.addMenu(u"Справка")

        viewmenu.addAction(machinetreepanelAction)
        viewmenu.addAction(responcedockAction)
        viewmenu.addAction(infodockAction)
        connmenu.addAction(self.syncAction)
        filemenu.addAction(settingsAction)
        filemenu.addAction(saveAction)
        filemenu.addAction(openAction)
        filemenu.addAction(quitAction)
        helpmenu.addAction(aboutAction)
        helpmenu.addAction(helpAction)

        toolbar = self.addToolBar("main")
        toolbar.setObjectName("main_toolbar")
        toolbar.addAction(machinetreepanelAction)
        toolbar.addWidget(syncButton)
        toolbar.addAction(settingsAction)

        settings = QSettings()
        self.restoreGeometry(settings.value("geometry").toByteArray());
        self.restoreState(settings.value("windowState").toByteArray());
        for widget in self.note_views.values():
            table_name = widget.view.__class__.__name__+"State"
            widget.view.horizontalHeader().restoreState(settings.value(table_name, "").toByteArray())
class ScreenLogin(Tk):
    def __init__(self, master, q_visibility):
        master.title('Login')
        self.master = master
        self.pin_entry = None
        self.q_visibility = q_visibility
        self.statusbar = StatusBar(self.master, bd=1, relief=SUNKEN, anchor=CENTER)
        self.statusbar.pack(side=BOTTOM, fill=X)

        # Setup GPIO
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(LED_LAUNCHREADY, GPIO.OUT)
    
    def refresh_timer(self):

        self.statusbar.set('Local IP: %s', get_ip_address('eth0'))
        status = self.q_visibility.get()

        if status == 'SHOW':
            self.master.deiconify()
        elif status == 'HIDE':
            self.master.withdraw()

        # Call reload_timer after 1sec
        self.master.after(1000, self.refresh_timer)

    def process_key(self, key):
        logging.debug('Button Pressed: ' + key)

        if (key == 'Clear'):
            self.pin_entry.delete(0, END)
            return None

        if (key == 'Login'):
            if self.pin_entry.get() == '2117':
                tkMessageBox.showinfo(title="Welcome", message="Launch Ready")
                GPIO.output(LED_LAUNCHREADY, GPIO.HIGH)
            else:
                tkMessageBox.showwarning(title="Invalid attempt", message="Incorrect!")
                GPIO.output(LED_LAUNCHREADY, GPIO.LOW)

            self.pin_entry.delete(0, END)
            return None

        self.pin_entry.insert(END, key)

    def show(self):

        buttons_frame = Frame(self.master)
        buttons_frame.pack(side=TOP, fill=Y)

        btn_list = [
            '1', '2', '3',
            '4', '5', '6',
            '7', '8', '9',
            '0', 'Clear', 'Login'
        ]

        # this also shows the calculator's button layout
        rel = 'ridge'

        # Draw the butons pad
        row = 1
        col = 0
        for b in btn_list:
            cmd = partial(self.process_key, b)

            # partial takes care of function and argument
            Button(buttons_frame, command=cmd, text=b,
                   width=5, height=2, relief=rel).grid(row=row, column=col)

            col += 1
            if col >= 3:
                col = 0
                row += 1

        pinentry_form = Frame(self.master)
        pinentry_form.pack(side=TOP, fill=BOTH)
        self.pin_entry = Entry(pinentry_form, show="•", font="Helvetica 24 bold", justify="center")
        self.pin_entry.pack(side=BOTTOM)

        self.refresh_timer()