Beispiel #1
0
 def on_actionSetting_triggered(self):
     """
     Slot documentation goes here.
     """
     settingsDialog = SettingsDialog(self)
     if settingsDialog.exec_() == QDialog.Accepted:
         print 'ok'
    def __init__(self, master: tk.Tk):
        """Instantiate a new application window"""
        super().__init__(master)
        self.master = master
        self.place(x=0, y=0, relwidth=1, relheight=1)

        self.configuration = ConfigManager.load(
            os.path.realpath(os.path.dirname(__file__) + '/settings.json'),
            ExpectedConfigKeys)
        self.settings_dialog = SettingsDialog(self, self.configuration)

        self.master.protocol('WM_DELETE_WINDOW', self.quit)
        self.master.tk.call(
            'wm', 'iconphoto', self.master._w,
            ImageTk.PhotoImage(
                Image.open(
                    os.path.realpath(
                        os.path.dirname(__file__) + '/../' +
                        self.configuration.getConfig()['icon']))))

        self.is_fullscreen = False
        self.master.bind('<F11>', lambda e: self.fullscreen('toggle'))
        self.master.bind('<Escape>', lambda e: self.fullscreen('off'))

        self.current_file = {}
        self.file = None
        self.progress = False

        self.createWidgets()

        self.master.update()
        self.focus_set()
Beispiel #3
0
	def openSettings(self):
		dialogWindow = SettingsDialog()
		QtCore.QObject.connect(dialogWindow, QtCore.SIGNAL('web_view_status'), self.dropLogView.changeWebServerStatus)
		QtCore.QObject.connect(dialogWindow, QtCore.SIGNAL('toggle_sys_tray_notification'), self.dropLogView.toggleSysTrayNotifications)
		QtCore.QObject.connect(dialogWindow, QtCore.SIGNAL('toggle_item_values_display'), self.dropLogView.toggleItemValues)
		dialogWindow.setModal(True)
		dialogWindow.exec_()
		self.accountsView.updateAccountBoxes()
		self.dropLogView.updateLogDisplay()
Beispiel #4
0
def main():
    os.chdir(os.path.dirname(sys.argv[0]))

    app = QApplication(sys.argv)
    QApplication.setQuitOnLastWindowClosed(False)

    settings = Settings('facelock')

    aboutDialog = AboutDialog()
    settingsDialog = SettingsDialog(settings)

    ConfigurationChecker(settingsDialog).fixConfiguration()

    cameraProbe = CameraProbe()

    faceRecognitionBuilder=FaceRecognitionBuilder()\
      .withSettings(settings)\
      .withCameraProperties(cameraProbe.getFps(),
                            cameraProbe.getWidth(),
                            cameraProbe.getHeight())


    trayIconGUI = SystemTrayGUIBuilder().\
      withSettings(settings).\
      withAboutDialog(aboutDialog).\
      withSettingsDialog(settingsDialog).\
      withFaceRecognitionBuilder(faceRecognitionBuilder).\
      build()

    trayIconGUI.show()
    app.exec_()
Beispiel #5
0
 def settingsDialog(self):
     """Launch settings dialog"""
     from SettingsDialog import SettingsDialog
     settingsDialog = SettingsDialog(parent=self)
     settingsDialog.setAttribute(QtCore.Qt.WA_DeleteOnClose)
     settingsDialog.finished.connect(self.updateSettings)
     settingsDialog.exec_()
Beispiel #6
0
 def openSettings(self):
     dialogWindow = SettingsDialog()
     QtCore.QObject.connect(dialogWindow, QtCore.SIGNAL('web_view_status'),
                            self.dropLogView.changeWebServerStatus)
     QtCore.QObject.connect(dialogWindow,
                            QtCore.SIGNAL('toggle_sys_tray_notification'),
                            self.dropLogView.toggleSysTrayNotifications)
     QtCore.QObject.connect(dialogWindow,
                            QtCore.SIGNAL('toggle_item_values_display'),
                            self.dropLogView.toggleItemValues)
     dialogWindow.setModal(True)
     dialogWindow.exec_()
     self.accountsView.updateAccountBoxes()
     self.dropLogView.updateLogDisplay()
    def Activated(self):
        win = SettingsDialog()

        win.exec_()
Beispiel #8
0
    def __init__(self, parent = None):
        QMainWindow.__init__(self, parent)
        self.setWindowTitle("FeedLol")
        
        self.aboutAction = QAction(QIcon("data/icons/help-about.svg"), "&About FeedLol...", self)
        self.connect(self.aboutAction, SIGNAL("triggered()"), self.slotAbout)
        
        self.reloadAction = QAction(QIcon("data/icons/view-refresh.svg"), "&Reload", self)
        self.reloadAction.setShortcut(QKeySequence.Refresh)
        
        self.homeAction = QAction(QIcon("data/icons/go-home.svg"), "Go &Home", self)
        self.homeAction.setShortcut("Alt+Home")
        
        self.userAction = QAction(QIcon("data/icons/user-identity.svg"), "&Me", self)
        self.userAction.setShortcut("Ctrl+M")
        
        self.logoutAction = QAction(QIcon("data/icons/dialog-close.svg"), "Log&out", self)
        self.logoutAction.setShortcut(QKeySequence.Close)
        
        self.settingsAction = QAction(QIcon("data/icons/configure.svg"), "&Preferences...", self)
        self.connect(self.settingsAction, SIGNAL("triggered()"), self.slotSettings)

        self.toolbar = QToolBar("Toolbar", self)
        self.toolbar.setObjectName("toolbar")
        self.toolbar.addAction(self.homeAction)
        self.toolbar.addAction(self.userAction)
        self.toolbar.addAction(self.reloadAction)
        self.toolbar.addSeparator()
        self.toolbar.addAction(self.logoutAction)
        self.toolbar.addSeparator()
        self.toolbar.addAction(self.settingsAction)
        self.toolbar.addAction(self.aboutAction)
        self.addToolBar(self.toolbar)
        
        self.loadStatus = QProgressBar(self)
        self.loadStatus.setRange(0, 100)
        self.loadStatus.setMaximumWidth(200)
        self.loadStatus.setTextVisible(False)
        self.loadStatus.hide()
        self.statusBar().addPermanentWidget(self.loadStatus)

        self.feedView = FeedView(self)
        self.setCentralWidget(self.feedView)
        self.connect(self.feedView, SIGNAL("titleChanged(const QString&)"), self.slotSetTitle)
        self.connect(self.feedView, SIGNAL("statusBarMessage(const QString&)"), self.statusBar(), SLOT("showMessage(const QString&)"))
        self.connect(self.feedView, SIGNAL("loadStarted()"), self.loadStart)
        self.connect(self.feedView, SIGNAL("loadFinished(bool)"), self.loadStop)
        self.connect(self.feedView, SIGNAL("loadProgress(int)"), self.loadProgress)
        self.connect(self.reloadAction, SIGNAL("triggered()"), self.feedView.reload)
        self.connect(self.homeAction, SIGNAL("triggered()"), self.feedView.goHome)
        self.connect(self.userAction, SIGNAL("triggered()"), self.feedView.goToUserPage)
        self.connect(self.logoutAction, SIGNAL("triggered()"), self.feedView.logout)
        self.connect(self.feedView.page(), SIGNAL("linkHovered(const QString&, const QString&, const QString&)"), self.linkHovered)
        
        self.settingsDialog = SettingsDialog(self.feedView, self)

        settings = QSettings()
        
        if settings.contains("proxy/type"):
            proxy = QNetworkProxy()
            proxyType = settings.value("proxy/type").toInt()[0]
            proxy.setType( (proxyType == 2) and QNetworkProxy.Socks5Proxy or ( (proxyType == 1) and QNetworkProxy.HttpProxy or QNetworkProxy.NoProxy ) )
            if proxy.type() != QNetworkProxy.NoProxy:
                proxy.setHostName(settings.value("proxy/host").toString())
                proxy.setPort(settings.value("proxy/port").toInt()[0])
                if settings.value("proxy/user").toString():
                    proxy.setUser(settings.value("proxy/user").toString())
                    proxy.setPassword(settings.value("proxy/password").toString())
            QNetworkProxy.setApplicationProxy(proxy)

        if settings.contains("mainWindow/geometry"):
            self.restoreGeometry(settings.value("mainWindow/geometry").toByteArray())
        else:
            self.resize(320,480)
        if settings.contains("mainWindow/state"):
            self.restoreState(settings.value("mainWindow/state").toByteArray())
        
        self.feedView.goHome()
Beispiel #9
0
 def __settings(self) :
     settingsDialog = SettingsDialog(self)
     settingsDialog.setVisible(True)
Beispiel #10
0
 def showSettings(self):
     diag = QtWidgets.QDialog(self.parent)
     sd = SettingsDialog()
     sd.setupUi(diag)
     diag.exec_()
 def handle_settings(self):
     self.mSettingsDialog = SettingsDialog(self)
     self.mSettingsDialog.exec_()
class ThermalScanDialog(QtWidgets.QDialog, Ui_ThermalScanDialog):

    def __init__(self, parent=None):
        super().__init__()
        self.setupUi(self)
        self.pushButton_Calibrate.clicked.connect(self.handle_calibrate)
        self.pushButton_Close.clicked.connect(self.handle_close)
        self.pushButton_Scan.clicked.connect(self.handle_scan)
        self.pushButton_Settings.clicked.connect(self.handle_settings)
        self.list_images.itemDoubleClicked.connect(self.handle_show_image)

        self.mQPixmap = QPixmap()
        self.mainImage.resizeEvent = self.image_resize_event


        self.mMatrix = None

        # read settings
        loaded_settings = {}
        if (os.path.isfile('settings.json')):
            with open('settings.json', 'r') as f:
                loaded_settings = json.load(f)

        Settings.settings.update(loaded_settings)

        self.sb_minTemp.setValue(Settings.settings['minTemp'])
        self.sb_maxTemp.setValue(Settings.settings['maxTemp'])

        self.mSettingsDialog = None

        self.directory = "images"
        if not os.path.exists(self.directory):
            os.makedirs(self.directory)
        self.fill_images_list()

    def fill_images_list(self):
        self.list_images.clear()
        images = glob.glob(self.directory + '/*.jpg')
        for image in images:
            self.list_images.addItem(os.path.basename(image))

    def update_picture_from_matrix(self):

        max_x = self.mMatrix.shape[0]
        max_y = self.mMatrix.shape[1]

        min_temp = self.mMatrix.min()
        max_temp = self.mMatrix.max()

        colorTable = [ qRgb(x, 0, 255-x) for x in np.linspace(0,255,128) ]

        matr = interp(self.mMatrix, [min_temp, max_temp], [0, 127]).astype(np.uint8)

        self.mQImage = QImage(matr.data, matr.shape[1], matr.shape[0], matr.strides[0], QImage.Format_Indexed8)
        self.mQImage.setColorTable(colorTable)

        self.mQPixmap = QPixmap.fromImage(self.mQImage)
        self.update_picture_from_pixmap()
        return

    def update_picture_from_pixmap(self):
        ww = self.mainImage.width() - 2
        hh = self.mainImage.height() - 2
        self.mainImage.setPixmap(
            self.mQPixmap.scaled(ww, hh, Qt.KeepAspectRatio))
        self.mainImage.repaint()

    def load_and_show_image(self, image_file):
        self.cvImage = cv2.imread(self.directory + '/' + image_file)
        height, width, bytes_per_component = self.cvImage.shape
        bytes_per_line = bytes_per_component * width

        cv2.cvtColor(self.cvImage, cv2.COLOR_BGR2RGB, self.cvImage)
        self.mQImage = QImage(self.cvImage, width, height,
                              bytes_per_line, QImage.Format_RGB888)
        self.mQPixmap = QPixmap.fromImage(self.mQImage)
        self.update_picture_from_pixmap()

    def image_resize_event(self, event):
        ww = self.mainImage.width() - 2
        hh = self.mainImage.height() - 2
        self.mainImage.setPixmap(
            self.mQPixmap.scaled(ww, hh, Qt.KeepAspectRatio))

    def test_camera(self):
        ret, frame = self.cap.read()
        self.cvImage = frame

        height, width, bytes_per_component = self.cvImage.shape
        bytes_per_line = bytes_per_component * width

        cv2.cvtColor(self.cvImage, cv2.COLOR_BGR2RGB, self.cvImage)
        self.mQImage = QImage(self.cvImage, width, height,
                              bytes_per_line, QImage.Format_RGB888)
        self.mQPixmap = QPixmap.fromImage(self.mQImage)
        self.update_picture_from_pixmap()
        pass

    def handle_scan(self, param):

        ox_len = int(abs(Settings.settings['lrServoMax'] - Settings.settings['lrServoMin']) / Settings.settings['lrStep'])+1
        oy_len = int(abs(Settings.settings['udServoMax'] - Settings.settings['udServoMin']) / Settings.settings['udStep'])+1

        arduinoCtrl.set_lr_servo(Settings.settings['lrServoMin'])
        arduinoCtrl.set_ud_servo(Settings.settings['udServoMin'])

        total_points = ox_len * oy_len
        progress = QProgressDialog('Scanning thermal image', 'Stop', 0, total_points)

        self.mMatrix = np.zeros((oy_len, ox_len))+23

        self.mQPixmap = QPixmap(ox_len, oy_len)
        self.mQPixmap.fill()

        rectangleScanJob = RectangleScanJob()
        rectangleScanJob.new_value.connect(self.handle_temperature)
        rectangleScanJob.progress.connect(progress.setValue)
        rectangleScanJob.start()

        #rectangleScanJob.run()

        progress.exec_()

        if progress.wasCanceled():
            rectangleScanJob.terminate()
            return

        self.update_picture_from_matrix()

    def handle_temperature(self, xpos, ypos, temp):

        #print( '({0},{1}) : {2}'.format(xpos,ypos, temp))
        self.mMatrix[self.mMatrix.shape[0] - 1 - ypos][xpos] = temp

        if xpos is 0:
            self.update_picture_from_matrix()

        return

    @pyqtSlot()
    def handle_calibrate(self):
        return

    @pyqtSlot()
    def handle_settings(self):
        self.mSettingsDialog = SettingsDialog(self)
        self.mSettingsDialog.exec_()

    @pyqtSlot(QListWidgetItem)
    def handle_show_image(self, item):
        image_file = item.text()
        self.load_and_show_image(image_file)
        return

    @pyqtSlot()
    def handle_close(self):
        exit()
Beispiel #13
0
 def show_settings_dialog(self):
     settings_dialog = SettingsDialog(parent=self)
     settings_dialog.set_modal(True)
     settings_dialog.run()
     settings_dialog.destroy()
Beispiel #14
0
 def on_settingsAction_triggered(self):
     settingsDialog = SettingsDialog(self)
     if settingsDialog.exec_():
         self.ui.imageLabel.reset()
class CrimpOrganizer(CrimpOrganizerGUI):
    def __init__(self, *args, **kwds):
        CrimpOrganizerGUI.__init__(self, *args, **kwds)
        self.data_directory = os.getcwd()

        self.crimptools = self.loadCrimptools()
        self.crimpcontacts = self.loadCrimpcontacts()
        self.fillCrimpInstructions(init=True)
        self.selected_instruction = []
        self.full_instructions = {}
        self.fillContacts()

        self.tcSearchContact.Bind(wx.EVT_TEXT, self. onSearchChanged)

        self.lcContacts.Bind(wx.EVT_LIST_ITEM_SELECTED,
                             self.onContactSelected)
        self.lcContacts.Bind(wx.EVT_LIST_ITEM_DESELECTED,
                             self.onContactSelected)
        self.lcContacts.Bind(wx.EVT_LIST_ITEM_ACTIVATED,
                             self.onEditContactClicked)
        self.lcContacts.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK,
                             self.onContactRClicked)

        self.lcToolSummary.Bind(wx.EVT_LIST_ITEM_SELECTED,
                                self.onToolSelected)
        self.lcToolSummary.Bind(wx.EVT_LIST_ITEM_DESELECTED,
                                self.onToolSelected)
        self.lcToolSummary.Bind(wx.EVT_LIST_ITEM_ACTIVATED,
                                self.onUseToolsClicked)
        self.lcToolSummary.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK,
                                self.onToolsRClicked)

        self.lcCrimpInstructions.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK,
                                      self.onInstructionRClicked)

        self.btnCreateInstructions.Bind(wx.EVT_BUTTON, self.onCreateClicked)
        self.tcSchemeNr.Bind(wx.EVT_TEXT, self.onSchemeNrChanged)
        self.tcSchemeRev.Bind(wx.EVT_TEXT, self.onSchemeNrChanged)

        self.treeInstructions.Bind(wx.EVT_TREE_SEL_CHANGED,
                                   self.treeItemSelected)
        self.treeInstructions.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK,
                                   self.treeItemRClicked)

        self.optFile.Bind(wx.EVT_MENU, self.onSettingsClicked)
        self.optOrder.Bind(wx.EVT_MENU, self.onOpenOrdersClicked)

        self.btnNewContact.Bind(wx.EVT_BUTTON, self.onNewContactClicked)
        self.btnManageTools.Bind(wx.EVT_BUTTON, self.onManageToolsClicked)



        settings_path = os.path.join(self.data_directory, "settings.json")
        if not os.path.exists(settings_path):
            self.onSettingsClicked(None)

    def onCrimpContactsClicked(self, event):
        print(event.GetId())
        event.Skip()

    def onSettingsClicked(self, event):
        self.SettingsDialog = SettingsDialog(self)
        # self.SettingsDialog.Bind(wx.EVT_CLOSE, self.onContactsAnnotated)
        self.SettingsDialog.Show()

    def onOpenOrdersClicked(self, event):
        print("order")
        event.Skip()

    def onContactRClicked(self, event):
        contactID = self.lcContacts.GetFirstSelected()
        if contactID == -1:
            return
        menus = [(wx.NewIdRef(count=1), "Bearbeiten",
                  self.onEditContactClicked),
                 (wx.NewIdRef(count=1), u"Löschen",
                  self.onDeleteContactClicked)]

        popup_menu = wx.Menu()
        for menu in menus:
            if menu is None:
                popup_menu.AppendSeparator()
                continue
            popup_menu.Append(menu[0], menu[1])
            self.Bind(wx.EVT_MENU, menu[2], id=menu[0])

        self.PopupMenu(popup_menu, self.ScreenToClient(wx.GetMousePosition()))
        popup_menu.Destroy()
        return

    def onNewContactClicked(self, event):
        self.CrimpcontactEditor = CrimpcontactEditor(self, preload="")
        self.CrimpcontactEditor.Bind(wx.EVT_CLOSE, self.onContaktEditorClose)
        self.CrimpcontactEditor.Show()

    def onEditContactClicked(self, event):
        contactID = self.lcContacts.GetFirstSelected()
        contactRef = self.lcContacts.GetItem(contactID, 0).GetText()
        self.CrimpcontactEditor = CrimpcontactEditor(self, preload=contactRef)
        self.CrimpcontactEditor.Bind(wx.EVT_CLOSE, self.onContaktEditorClose)
        self.CrimpcontactEditor.Show()

    def onDeleteContactClicked(self, event):
        contactID = self.lcContacts.GetFirstSelected()
        contactRef = self.lcContacts.GetItem(contactID, 0).GetText()

        msg = 'Really?! Soll Kontakt "{0}"'.format(contactRef)
        msg += 'unwiderruflich gelöscht werden?'
        response = wx.MessageBox(msg, 'Info', wx.YES_NO | wx.ICON_WARNING)

        if contactID > -1 and response == wx.YES:
            self.crimpcontacts = self.loadCrimpcontacts()
            self.crimpcontacts.pop(contactRef)
            self.saveCrimpcontacts()
            self.fillContacts()

    def onContaktEditorClose(self, event):
        self.crimpcontacts = self.loadCrimpcontacts()
        self.fillContacts()
        self.lcToolSummary.DeleteAllItems()
        event.Skip()

    def onSearchChanged(self, event):
        self.fillContacts(searchpattern=self.tcSearchContact.GetValue())

    def onManageToolsClicked(self, event):
        self.CrimptoolEditor = CrimptoolEditor(self)
        self.CrimptoolEditor.Bind(wx.EVT_CLOSE, self.onToolEditorClose)
        self.CrimptoolEditor.Show()

    def onToolEditorClose(self, event):
        self.crimptools = self.loadCrimptools()
        self.fillContacts()
        self.lcToolSummary.DeleteAllItems()
        event.Skip()

    def onContactSelected(self, event):
        contactID = self.lcContacts.GetFirstSelected()
        if contactID > -1:
            contactRef = self.lcContacts.GetItem(contactID, 0).GetText()
            self.lcToolSummary.DeleteAllItems()
            contact = self.crimpcontacts[contactRef]
            for xs in sorted(contact["crosssection"].keys()):
                slot = contact["crosssection"][xs]["slot"]
                tool = contact["crosssection"][xs]["tool"]
                IDs = ", ".join(self.crimptools[tool]["IDs"])
                self.lcToolSummary.Append([xs, IDs, slot])

        else:
            self.lcToolSummary.DeleteAllItems()

    def onToolSelected(self, event):
        self.selected_instruction = []
        if self.lcToolSummary.GetFirstSelected() > -1:

            contactID = self.lcContacts.GetFirstSelected()
            contactRef = self.lcContacts.GetItem(contactID, 0).GetText()

            sel = self.lcToolSummary.GetNextSelected(-1)
            while sel > -1:
                xs = self.lcToolSummary.GetItem(sel, 0).GetText()
                instruction_key = "#".join([xs, contactRef])
                if instruction_key not in self.full_instructions:
                    self.selected_instruction.append(instruction_key)

                sel = self.lcToolSummary.GetNextSelected(sel)

    def onToolsRClicked(self, event):
        selTools = self.lcToolSummary.GetFirstSelected()
        if selTools == -1:
            return
        menus = [(wx.NewIdRef(count=1), u"Hinzufügen",
                  self.onUseToolsClicked)]

        popup_menu = wx.Menu()
        for menu in menus:
            if menu is None:
                popup_menu.AppendSeparator()
                continue
            popup_menu.Append(menu[0], menu[1])
            self.Bind(wx.EVT_MENU, menu[2], id=menu[0])

        self.PopupMenu(popup_menu, self.ScreenToClient(wx.GetMousePosition()))
        popup_menu.Destroy()
        return

    def onUseToolsClicked(self, event):
        identifiers = self.selected_instruction
        self.AnnotateContacts = AnnotateContacts(self, identifiers=identifiers)
        self.AnnotateContacts.Bind(wx.EVT_CLOSE, self.onContactsAnnotated)
        self.AnnotateContacts.Show()

    def onContactsAnnotated(self, event):
        if self.AnnotateContacts.annotated_data:
            self.lcContacts.Select(-1, 0)
            self.lcToolSummary.Select(-1, 0)
            self.lcToolSummary.DeleteAllItems()
            self.lcCrimpInstructions.DeleteAllItems()

            for entry in self.selected_instruction:
                annotated_data = self.AnnotateContacts.annotated_data[entry]
                self.full_instructions[entry] = annotated_data

            for instruction in self.full_instructions:
                xs, contact = instruction.split("#")
                pos = self.full_instructions[instruction]["pos"]
                name = self.full_instructions[instruction]["name"]
                info = [pos, contact, xs, name]
                self.lcCrimpInstructions.Append(info)

            schemeNr = self.tcSchemeNr.GetValue() != ""
            schemeRev = self.tcSchemeRev.GetValue() != ""
            nameGiven = all([schemeNr, schemeRev])
            if self.lcCrimpInstructions.GetItemCount() > 0 and nameGiven:
                self.btnCreateInstructions.Enable()
            else:
                self.btnCreateInstructions.Disable()

        event.Skip()

    def onInstructionRClicked(self, event):
        selContact = self.lcCrimpInstructions.GetFirstSelected()
        if selContact == -1:
            return
        menus = [(wx.NewIdRef(count=1), u"Kontakt entfernen",
                  self.onRemoveInstructionClicked)]

        popup_menu = wx.Menu()
        for menu in menus:
            if menu is None:
                popup_menu.AppendSeparator()
                continue
            popup_menu.Append(menu[0], menu[1])
            self.Bind(wx.EVT_MENU, menu[2], id=menu[0])

        self.PopupMenu(popup_menu, self.ScreenToClient(wx.GetMousePosition()))
        popup_menu.Destroy()
        return

    def onRemoveInstructionClicked(self, event):
        instruction_id = self.lcCrimpInstructions.GetFirstSelected()
        contact = self.lcCrimpInstructions.GetItem(instruction_id, 1).GetText()
        xs = self.lcCrimpInstructions.GetItem(instruction_id, 2).GetText()
        entry = "#".join([xs, contact])
        self.lcCrimpInstructions.DeleteAllItems()
        self.full_instructions.pop(entry)

        for instruction in self.full_instructions:
            xs, contact = instruction.split("#")
            pos = self.full_instructions[instruction]["pos"]
            name = self.full_instructions[instruction]["name"]
            info = [pos, contact, xs, name]
            self.lcCrimpInstructions.Append(info)

        if self.lcCrimpInstructions.GetItemCount() > 0:
            self.btnCreateInstructions.Enable()
        else:
            self.btnCreateInstructions.Disable()

    def onReannotateClicked(self, event):
        self.selected_instruction = []
        for instruction in self.full_instructions.keys():
            self.selected_instruction.append(instruction)

        identifiers = self.full_instructions.keys()
        self.AnnotateContacts = AnnotateContacts(self, identifiers=identifiers)
        self.AnnotateContacts.Bind(wx.EVT_CLOSE, self.onContactsAnnotated)
        self.AnnotateContacts.Show()

    def onDeleteSchemeClicked(self, event):
        schemeNr = self.tcSchemeNr.GetValue()
        schemeRev = self.tcSchemeRev.GetValue()

        scheme = "-".join([schemeNr, schemeRev]) + ".json"
        folder = os.path.join(self.data_directory, "data", "instructions")
        filename = os.path.join(folder, scheme)

        if os.path.exists(filename):
            msg = 'Really?! Soll die Anweisung für'
            msg += ' "{0}-{1}" '.format(schemeNr, schemeRev)
            msg += 'unwiderruflich gelöscht werden?'
            response = wx.MessageBox(msg, 'Info', wx.YES_NO | wx.ICON_WARNING)
            if response == wx.YES:
                os.remove(filename)
                self.tcSchemeNr.SetValue("")
                self.tcSchemeRev.SetValue("")
                self.lcCrimpInstructions.DeleteAllItems()
                self.fillCrimpInstructions()
                self.full_instructions = {}

    def onSchemeNrChanged(self, event):
        schemeNr = self.tcSchemeNr.GetValue() == ""
        schemeRev = self.tcSchemeRev.GetValue() == ""
        self.fillCrimpInstructions(searchpattern=self.tcSchemeNr.GetValue())
        if any([schemeNr, schemeRev]):
            self.btnCreateInstructions.Disable()
        else:
            self.btnCreateInstructions.Enable()

    def onCreateClicked(self, event):
        self.OrderDetails = OrderDetails(self)
        self.OrderDetails.Bind(wx.EVT_CLOSE, self.onOrderDetailsGiven)
        self.OrderDetails.Show()

    def onOrderDetailsGiven(self, event):
        schemeNr = self.tcSchemeNr.GetValue()
        schemeRev = self.tcSchemeRev.GetValue()
        scheme = "-".join([schemeNr, schemeRev])
        details = self.OrderDetails.readInfoScreen()
        self.saveCrimpInstructions(scheme, self.OrderDetails.override)
        if self.OrderDetails.details_given:
            protocolNr = details[2]
            outdir = os.path.join(self.data_directory, "data",
                                  "orders", protocolNr)
            if not os.path.exists(outdir):
                os.makedirs(outdir)

            details.append(scheme)
            pdfcreator = CrimpInstructionPDF(outdir=outdir,
                                             outfile="{0}.pdf".format(scheme))
            pdfcreator.createPDF(order_details=details,
                                 instructions=self.buildInstructions())

            pdfcreator.showPDF()

        event.Skip()

    def buildInstructions(self):
        instructions = copy.deepcopy(self.full_instructions)
        for entry in self.full_instructions:
            xs, contactRef = entry.split("#")
            contact = self.crimpcontacts[contactRef]
            instructions[entry]["series"] = contact["series"]
            instructions[entry]["producer"] = contact["producer"]

            slot = contact["crosssection"][xs]["slot"]
            soll = contact["crosssection"][xs]["soll"]
            instructions[entry]["slot"] = splitReadableSlot(slot)
            instructions[entry]["soll"] = soll

            tool = contact["crosssection"][xs]["tool"]
            IDs = self.crimptools[tool]["IDs"]
            instructions[entry]["IDs"] = IDs

            producer = self.crimptools[tool]["producer"]
            instructions[entry]["producer"] = producer
        return instructions

    def treeItemRClicked(self, event):
        schemeNr = self.tcSchemeNr.GetValue()
        schemeRev = self.tcSchemeRev.GetValue()
        scheme = "-".join([schemeNr, schemeRev]) + ".json"
        folder = os.path.join(self.data_directory, "data", "instructions")
        filename = os.path.join(folder, scheme)
        if not os.path.exists(filename):
            return

        menus = [(wx.NewIdRef(count=1), u"Zeichnung löschen",
                  self.onDeleteSchemeClicked),
                 (wx.NewIdRef(count=1), u"Pos./Gehäuse neu zuweisen",
                  self.onReannotateClicked)]

        popup_menu = wx.Menu()
        for menu in menus:
            popup_menu.Append(menu[0], menu[1])
            self.Bind(wx.EVT_MENU, menu[2], id=menu[0])

        self.PopupMenu(popup_menu, self.ScreenToClient(wx.GetMousePosition()))
        popup_menu.Destroy()
        return

    def treeItemSelected(self, event):
        obj = event.GetEventObject()
        instructions = obj.GetItemData(obj.GetSelection())
        self.lcContacts.Select(-1, 0)
        self.lcToolSummary.Select(-1, 0)
        self.lcToolSummary.DeleteAllItems()
        self.lcCrimpInstructions.DeleteAllItems()
        if instructions is not None:
            parent = obj.GetItemParent(obj.GetSelection())
            schemeNr = obj.GetItemText(parent)
            schemeRev = obj.GetItemText(obj.GetSelection())
            self.tcSchemeNr.SetValue(schemeNr)
            self.tcSchemeRev.SetValue(schemeRev)
            for instruction in instructions:
                xs, contact = instruction.split("#")
                pos = instructions[instruction]["pos"]
                name = instructions[instruction]["name"]
                info = [pos, contact, xs, name]
                self.lcCrimpInstructions.Append(info)

            self.full_instructions = copy.deepcopy(instructions)
        else:
            self.full_instructions = {}
            self.tcSchemeNr.SetValue("")
            self.tcSchemeRev.SetValue("")

    def fillContacts(self, searchpattern=""):
        contacts = list(self.crimpcontacts.keys())
        contacts.sort()
        self.lcContacts.DeleteAllItems()
        for contact in contacts:
            producer = self.crimpcontacts[contact]["producer"]
            series = self.crimpcontacts[contact]["series"]

            searchresult = any([searchpattern.lower() in contact.lower(),
                                searchpattern.lower() in producer.lower(),
                                searchpattern.lower() in series.lower()
                                ])
            if searchresult:
                self.lcContacts.Append([contact, producer, series])

    # This has to go in a separate class
    # It is redundant
    def loadCrimptools(self):
        outfile = self.getFullPath("crimptools.json")
        if os.path.exists(outfile):
            with open(outfile, "r") as FSO:
                return json.load(FSO)

    def loadCrimpcontacts(self):
        outfile = self.getFullPath("crimpcontacts.json")
        if os.path.exists(outfile):
            with open(outfile, "r") as FSO:
                return json.load(FSO)
        return {}

    def saveCrimpcontacts(self):
        outfile = self.getFullPath("crimpcontacts.json")
        if os.path.exists(outfile):
            with open(outfile, "w") as FSO:
                json.dump(self.crimpcontacts, FSO)

    def getFullPath(self, file):
        folder = file.replace(".json", "")
        outdir = os.path.join(self.data_directory, "data", folder)
        if not os.path.exists(outdir):
            os.makedirs(outdir)
        return os.path.join(outdir, file)

    def fillCrimpInstructions(self, init=False, searchpattern=""):
        instructions = self.loadCrimpInstructions()
        self.treeInstructions.DeleteAllItems()
        root = self.treeInstructions.AddRoot("Crimpanweisungen")
        found_match = False
        for schemeNr in sorted(list(instructions.keys())):
            if searchpattern and (searchpattern not in schemeNr):
                continue
            elif searchpattern and (searchpattern in schemeNr):
                found_match = True
            nr = self.treeInstructions.AppendItem(root, schemeNr)
            for schemeRev in sorted(list(instructions[schemeNr].keys())):
                rev = self.treeInstructions.AppendItem(nr, schemeRev)
                data = instructions[schemeNr][schemeRev]
                self.treeInstructions.SetItemData(rev, data)
        if found_match:
            self.treeInstructions.ExpandAll()
        else:
            self.treeInstructions.Expand(root)

    def loadCrimpInstructions(self):
        outdir = os.path.join(self.data_directory, "data", "instructions")
        instructions = {}
        if os.path.exists(outdir):
            for d in os.listdir(outdir):
                schemeNr, schemeRev = d.replace(".json", "").split("-")
                if schemeNr not in instructions:
                    instructions[schemeNr] = {}
                with open(os.path.join(outdir, d), "r") as FSO:
                    instructions[schemeNr][schemeRev] = json.load(FSO)
        return instructions

    def saveCrimpInstructions(self, scheme, override=False):
        outdir = os.path.join(self.data_directory, "data", "instructions")
        if not os.path.exists(outdir):
            os.makedirs(outdir)
        outfile = os.path.join(outdir, "{0}.json".format(scheme))
        response = wx.NO
        if not os.path.exists(outfile):
            msg = '"{0}" ist eine neue Zeichnung. '.format(scheme)
            msg += 'Soll sie gespeichert werden?'
            btns = wx.YES_NO | wx.ICON_INFORMATION | wx.CANCEL
            dial = wx.MessageDialog(None, msg, 'Info', btns)
            response = dial.ShowModal()
        if (response == wx.ID_YES or override) and self.full_instructions:
            with open(outfile, "w") as FSO:
                json.dump(self.full_instructions, FSO, indent=4)
        self.fillCrimpInstructions()
Beispiel #16
0
 def settings(self):
     settingGui = SettingsDialog(self, self.settings)
     settingGui.exec_()
Beispiel #17
0
class FeedLol(QMainWindow):
    def __init__(self, parent = None):
        QMainWindow.__init__(self, parent)
        self.setWindowTitle("FeedLol")
        
        self.aboutAction = QAction(QIcon("data/icons/help-about.svg"), "&About FeedLol...", self)
        self.connect(self.aboutAction, SIGNAL("triggered()"), self.slotAbout)
        
        self.reloadAction = QAction(QIcon("data/icons/view-refresh.svg"), "&Reload", self)
        self.reloadAction.setShortcut(QKeySequence.Refresh)
        
        self.homeAction = QAction(QIcon("data/icons/go-home.svg"), "Go &Home", self)
        self.homeAction.setShortcut("Alt+Home")
        
        self.userAction = QAction(QIcon("data/icons/user-identity.svg"), "&Me", self)
        self.userAction.setShortcut("Ctrl+M")
        
        self.logoutAction = QAction(QIcon("data/icons/dialog-close.svg"), "Log&out", self)
        self.logoutAction.setShortcut(QKeySequence.Close)
        
        self.settingsAction = QAction(QIcon("data/icons/configure.svg"), "&Preferences...", self)
        self.connect(self.settingsAction, SIGNAL("triggered()"), self.slotSettings)

        self.toolbar = QToolBar("Toolbar", self)
        self.toolbar.setObjectName("toolbar")
        self.toolbar.addAction(self.homeAction)
        self.toolbar.addAction(self.userAction)
        self.toolbar.addAction(self.reloadAction)
        self.toolbar.addSeparator()
        self.toolbar.addAction(self.logoutAction)
        self.toolbar.addSeparator()
        self.toolbar.addAction(self.settingsAction)
        self.toolbar.addAction(self.aboutAction)
        self.addToolBar(self.toolbar)
        
        self.loadStatus = QProgressBar(self)
        self.loadStatus.setRange(0, 100)
        self.loadStatus.setMaximumWidth(200)
        self.loadStatus.setTextVisible(False)
        self.loadStatus.hide()
        self.statusBar().addPermanentWidget(self.loadStatus)

        self.feedView = FeedView(self)
        self.setCentralWidget(self.feedView)
        self.connect(self.feedView, SIGNAL("titleChanged(const QString&)"), self.slotSetTitle)
        self.connect(self.feedView, SIGNAL("statusBarMessage(const QString&)"), self.statusBar(), SLOT("showMessage(const QString&)"))
        self.connect(self.feedView, SIGNAL("loadStarted()"), self.loadStart)
        self.connect(self.feedView, SIGNAL("loadFinished(bool)"), self.loadStop)
        self.connect(self.feedView, SIGNAL("loadProgress(int)"), self.loadProgress)
        self.connect(self.reloadAction, SIGNAL("triggered()"), self.feedView.reload)
        self.connect(self.homeAction, SIGNAL("triggered()"), self.feedView.goHome)
        self.connect(self.userAction, SIGNAL("triggered()"), self.feedView.goToUserPage)
        self.connect(self.logoutAction, SIGNAL("triggered()"), self.feedView.logout)
        self.connect(self.feedView.page(), SIGNAL("linkHovered(const QString&, const QString&, const QString&)"), self.linkHovered)
        
        self.settingsDialog = SettingsDialog(self.feedView, self)

        settings = QSettings()
        
        if settings.contains("proxy/type"):
            proxy = QNetworkProxy()
            proxyType = settings.value("proxy/type").toInt()[0]
            proxy.setType( (proxyType == 2) and QNetworkProxy.Socks5Proxy or ( (proxyType == 1) and QNetworkProxy.HttpProxy or QNetworkProxy.NoProxy ) )
            if proxy.type() != QNetworkProxy.NoProxy:
                proxy.setHostName(settings.value("proxy/host").toString())
                proxy.setPort(settings.value("proxy/port").toInt()[0])
                if settings.value("proxy/user").toString():
                    proxy.setUser(settings.value("proxy/user").toString())
                    proxy.setPassword(settings.value("proxy/password").toString())
            QNetworkProxy.setApplicationProxy(proxy)

        if settings.contains("mainWindow/geometry"):
            self.restoreGeometry(settings.value("mainWindow/geometry").toByteArray())
        else:
            self.resize(320,480)
        if settings.contains("mainWindow/state"):
            self.restoreState(settings.value("mainWindow/state").toByteArray())
        
        self.feedView.goHome()
        
    def saveConfig(self):
        settings = QSettings()
        settings.setValue("mainWindow/geometry", QVariant(self.saveGeometry()))
        settings.setValue("mainWindow/state", QVariant(self.saveState()))
        session = self.feedView.siteServer.session
        from cPickle import dumps
        session = dumps(session)
        settings.setValue("session", QVariant(session))
        proxy = QNetworkProxy.applicationProxy()
        proxyType = (proxy.type() == QNetworkProxy.Socks5Proxy) and 2 or ( (proxy.type() == QNetworkProxy.HttpProxy) and 1 or 0 )
        settings.setValue("proxy/type", QVariant(proxyType))
        settings.setValue("proxy/host", QVariant(proxy.hostName()))
        settings.setValue("proxy/port", QVariant(proxy.port()))
        settings.setValue("proxy/user", QVariant(proxy.user()))
        settings.setValue("proxy/password", QVariant(proxy.password()))

    def slotAbout(self):
        from PyQt4.QtGui import QMessageBox
        QMessageBox.about(self, "FeedLol", "<h2>FeedLol 0.1</h2><p>Copyright &copy; 2008 <a href=\"mailto:[email protected]\">Bodil Stokke</a></p>")
        
    def slotSettings(self):
        self.settingsDialog.updateSettings()
        if self.settingsDialog.exec_() == QDialog.Accepted:
            self.settingsDialog.applySettings()

    def slotSetTitle(self, title):
        self.setWindowTitle("FeedLol: " + title)
        
    def loadStart(self):
        self.loadStatus.show()
    
    def loadStop(self):
        self.loadStatus.hide()
        
    def loadProgress(self, progress):
        self.loadStatus.setValue(progress)
    
    def linkHovered(self, url, title, text):
        if url and QUrl(url).scheme() != "chrome":
            self.statusBar().showMessage(url)
        else:
            self.statusBar().clearMessage()
Beispiel #18
0
 def __settings(self):
     settingsDialog = SettingsDialog(self)
     settingsDialog.setVisible(True)
class Application(tk.Frame):
    """Application window"""
    def __init__(self, master: tk.Tk):
        """Instantiate a new application window"""
        super().__init__(master)
        self.master = master
        self.place(x=0, y=0, relwidth=1, relheight=1)

        self.configuration = ConfigManager.load(
            os.path.realpath(os.path.dirname(__file__) + '/settings.json'),
            ExpectedConfigKeys)
        self.settings_dialog = SettingsDialog(self, self.configuration)

        self.master.protocol('WM_DELETE_WINDOW', self.quit)
        self.master.tk.call(
            'wm', 'iconphoto', self.master._w,
            ImageTk.PhotoImage(
                Image.open(
                    os.path.realpath(
                        os.path.dirname(__file__) + '/../' +
                        self.configuration.getConfig()['icon']))))

        self.is_fullscreen = False
        self.master.bind('<F11>', lambda e: self.fullscreen('toggle'))
        self.master.bind('<Escape>', lambda e: self.fullscreen('off'))

        self.current_file = {}
        self.file = None
        self.progress = False

        self.createWidgets()

        self.master.update()
        self.focus_set()

    def createWidgets(self):
        """Creates all widgets in the window"""
        # Top menu
        self.menu = tk.Menu(self.master)
        self.menu_file = tk.Menu(self.menu, tearoff=0)
        self.menu.add_cascade(
            label=self.configuration.getLang()['topmenu']['file'],
            menu=self.menu_file)

        self.menu_file.add_command(
            label=self.configuration.getLang()['topmenu']['newfile'],
            accelerator='Ctrl+N',
            command=self.newFile)
        self.master.bind_all('<Control-n>', self.newFile)
        self.menu_file.add_separator()
        self.menu_file.add_command(
            label=self.configuration.getLang()['topmenu']['openfile'],
            accelerator='Ctrl+O',
            command=self.openFile)
        self.master.bind_all('<Control-o>', self.openFile)
        self.menu_file.add_separator()
        self.menu_file.add_command(
            label=self.configuration.getLang()['topmenu']['savefile'],
            accelerator='Ctrl+S',
            command=self.saveFile)
        self.master.bind_all('<Control-s>', self.saveFile)
        self.menu_file.add_command(
            label=self.configuration.getLang()['topmenu']['savefileas'],
            accelerator='Ctrl+Shift+S',
            command=self.saveFileAs)
        self.master.bind_all('<Control-S>', self.saveFileAs)
        self.menu_file.add_separator()
        self.menu_file.add_command(
            label=self.configuration.getLang()['topmenu']['settings'],
            accelerator='Ctrl+,',
            command=self.openSettings)
        self.master.bind_all('<Control-comma>', self.openSettings)

        self.menu_edit = tk.Menu(self.menu, tearoff=0)
        self.menu.add_cascade(
            label=self.configuration.getLang()['topmenu']['edit'],
            menu=self.menu_edit)

        self.menu_edit.add_command(
            label=self.configuration.getLang()['topmenu']['undo'],
            accelerator='Ctrl+Z',
            command=self.undo)
        self.master.bind_all('<Control-z>', self.undo)
        self.menu_edit.add_command(
            label=self.configuration.getLang()['topmenu']['redo'],
            accelerator='Ctrl+Y',
            command=self.redo)
        self.master.bind_all('<Control-y>', self.redo)

        self.menu_help = tk.Menu(self.menu, tearoff=0)
        self.menu.add_cascade(
            label=self.configuration.getLang()['topmenu']['help'],
            menu=self.menu_help)

        self.menu_help.add_command(
            label=self.configuration.getLang()['topmenu']['manual'],
            accelerator='F1',
            command=self.help)
        self.master.bind_all('<F1>', self.help)

        self.master.config(menu=self.menu)

    def quit(self, evt: tk.Event = None):
        """Kills the window and all of its subprocesses"""
        if self.progress:
            if not messagebox.askokcancel(
                    self.configuration.getLang()['discardChanges']['title'],
                    self.configuration.getLang()['discardChanges']['message']):
                return

        if os.path.exists(
                os.path.realpath(
                    os.path.dirname(__file__) + '/tmp/current.wav')):
            os.remove(
                os.path.realpath(
                    os.path.dirname(__file__) + '/tmp/current.wav'))

        self.master.destroy()

    def newFile(self, evt: tk.Event = None):
        """Creates a new file"""
        proceed = messagebox.askokcancel(
            self.configuration.getLang()['discardChanges']['title'],
            self.configuration.getLang()['discardChanges']
            ['message']) if self.progress else True
        if not proceed: return

        if os.path.exists(
                os.path.realpath(
                    os.path.dirname(__file__) + '/tmp/current.wav')):
            os.remove(
                os.path.realpath(
                    os.path.dirname(__file__) + '/tmp/current.wav'))

        self.current_file = {}
        self.master.wm_title('Sound Editor')

    def openFile(self, evt: tk.Event = None):
        """Open a sound file"""
        proceed = messagebox.askokcancel(
            self.configuration.getLang()['discardChanges']['title'],
            self.configuration.getLang()['discardChanges']
            ['message']) if self.progress else True
        if not proceed: return

        path = filedialog.askopenfilename(
            initialdir=os.path.expanduser('~'),
            title='Open Sound File',
            filetypes=[('Sound files', ' '.join(
                self.configuration.getConfig()['supported_extensions']))])

        if path:
            path = os.path.realpath(path)
            self.current_file['path'] = path

            if os.path.exists(
                    os.path.realpath(
                        os.path.dirname(__file__) + '/tmp/current.wav')):
                os.remove(
                    os.path.realpath(
                        os.path.dirname(__file__) + '/tmp/current.wav'))

            ffmpeg = run([
                'ffmpeg', '-y', '-loglevel', 'error', '-i', path,
                os.path.realpath(
                    os.path.dirname(__file__) + '/tmp/current.wav')
            ],
                         stdout=PIPE,
                         stderr=STDOUT)

            if ffmpeg.returncode == 1:
                self.current_file = {}
                messagebox.showerror(
                    'Error',
                    f'Could not open \'{path}\', because the file is possibly corrupt:\n\n{ffmpeg.stdout.decode()}'
                )
                return

            try:
                self.current_file['rate'], self.current_file[
                    'data'] = wavfile.read(
                        os.path.realpath(
                            os.path.dirname(__file__) + '/tmp/current.wav'))
            except FileNotFoundError:
                self.current_file = {}
                print('Sound file is corrupt or could not be opened')
                raise
            except ValueError:
                self.current_file = {}
                print('Sound file is corrupt')
                raise
            else:
                self.master.wm_title(
                    f'Sound Editor - {os.path.basename(path)}')
                self.progress = False

    def saveFile(self, evt: tk.Event = None):
        """Save the current sound file"""
        if 'path' in self.current_file.keys():
            wavfile.write(
                os.path.realpath(
                    os.path.dirname(__file__) + '/tmp/current.wav'),
                self.current_file['rate'], self.current_file['data'])

            ffmpeg = run([
                'ffmpeg', '-y', '-loglevel', 'error', '-i',
                os.path.realpath(
                    os.path.dirname(__file__) + '/tmp/current.wav'),
                self.current_file['path']
            ],
                         stdout=PIPE,
                         stderr=STDOUT)

            if ffmpeg.returncode == 1:
                messagebox.showerror(
                    'Error',
                    f'Could not save file to \'{self.current_file["path"]}\':\n\n{ffmpeg.stdout.decode()}'
                )
                return

            self.master.wm_title(
                f'Sound Editor - {os.path.basename(self.current_file["path"])}'
            )
            self.progress = False
        else:
            self.saveFileAs()

    def saveFileAs(self, e: tk.Event = None):
        """Save the current sound file, specifying its location"""
        path = filedialog.asksaveasfilename(
            initialdir=os.path.expanduser('~'),
            title='Save Sound File',
            filetypes=[('Sound files', ' '.join(
                self.configuration.getConfig()['supported_extensions']))])

        if path:
            valid_extension = []
            for ext in self.configuration.getConfig()['supported_extensions']:
                valid_extension.append(path.endswith(ext))

            if not True in valid_extension: path += '.mp3'

            if not 'data' in self.current_file:
                self.current_file['rate'] = 44100
                self.current_file['data'] = np.array([[0, 0]] * 1)

            wavfile.write(
                os.path.realpath(
                    os.path.dirname(__file__) + '/tmp/current.wav'),
                self.current_file['rate'], self.current_file['data'])
            ffmpeg = run([
                'ffmpeg', '-y', '-loglevel', 'error', '-i',
                os.path.realpath(
                    os.path.dirname(__file__) + '/tmp/current.wav'), path
            ],
                         stdout=PIPE,
                         stderr=STDOUT)

            if ffmpeg.returncode == 1:
                messagebox.showerror(
                    'Error',
                    f'Could not save file to \'{path}\':\n\n{ffmpeg.stdout.decode()}'
                )
                return

            self.current_file['path'] = path

            self.master.wm_title(f'Sound Editor - {os.path.basename(path)}')
            self.progress = False

    def openSettings(self, evt: tk.Event = None):
        """Opens the settings dialog"""
        if not self.settings_dialog.isVisible:
            self.settings_dialog.show()

    def help(self, evt: tk.Event = None):
        """Opens the manual"""
        webbrowser.open_new('file:///' + os.path.realpath(
            os.path.join(os.path.dirname(__file__), '../docs/docs-page.html')))

    def undo(self, evt: tk.Event = None):
        """Undoes last action"""
        pass

    def redo(self, evt: tk.Event = None):
        """Redoes last undone action"""
        pass

    def fullscreen(self, mode):
        """Toggle fullscreen, or windowify (when pressing Esc)"""
        if mode == 'toggle':
            self.is_fullscreen = not self.is_fullscreen
            self.master.attributes('-fullscreen', self.is_fullscreen)
        elif mode == 'off':
            self.is_fullscreen = False
            self.master.attributes('-fullscreen', False)
Beispiel #20
0
def show_settings():
    logging.info("Show Settings dialog")
    settings_dialog = SettingsDialog(config, language,
                                     Utility.read_lang_files(), save_settings,
                                     settings_dialog_glade)
    settings_dialog.show()
    def Activated(self):
        win = SettingsDialog()

        win.exec_()
 def onSettingsClicked(self, event):
     self.SettingsDialog = SettingsDialog(self)
     # self.SettingsDialog.Bind(wx.EVT_CLOSE, self.onContactsAnnotated)
     self.SettingsDialog.Show()
 def settingsButton(self, event):
     SettingsDialog(self.GetParent(), wx.ID_ANY)