def findDataDir(self,name): if not len(QApplication.applicationName()): print "QApplication.applicationName() is not set" return '' s = QSettings() if s.contains('datadir'): datadir = unicode(s.value('datadir')) imagepath = os.path.join(datadir,name) if os.path.exists(imagepath): return imagepath else: dirname = os.path.dirname(name) datadirsuffix = os.path.join( 'share',unicode(QApplication.applicationName())) dirpath = os.path.normpath(os.path.join(datadirsuffix,dirname)) for root, dirs, files in os.walk('/usr', None, True): if not root.endswith(dirpath): continue for f in files: filepath = os.path.join(root,f) if filepath.endswith(name): pos = filepath.find(name) if pos == -1: continue datadir = os.path.normpath(root[:pos]) s.setValue('datadir',datadir) return filepath return ''
def main(): """Function, executed on start """ # create application app = QApplication (sys.argv) app.setApplicationName( "fresh-examples" ) qsrand( QTime( 0, 0, 0 ).secsTo( QTime.currentTime() ) ) pSettings.setDefaultProperties(pSettings.Properties(app.applicationName(), \ "1.0.0", pSettings.Portable)) window = MainWindow() window.setWindowTitle( app.applicationName() ) window.show() # connection app.lastWindowClosed.connect(app.quit) # start application result = app.exec_() del window return result
def __init__(self): QWidget.__init__(self) self.resize(350, 225) self.setMinimumSize(QSize(350, 225)) self.setMaximumSize(QSize(400, 250)) self.setWindowTitle(QApplication.applicationName() + " " + QApplication.applicationVersion()) icon = QIcon() icon.addPixmap(QPixmap(":/resim/parcala.png")) self.setWindowIcon(icon) self.gridLayout = QGridLayout(self) self.parcalaButton = QPushButton(self) self.parcalaButton.setMinimumSize(QSize(150, 50)) self.parcalaButton.setText(self.trUtf8("Parçala")) self.parcalaButton.clicked.connect(self.parcala) self.gridLayout.addWidget(self.parcalaButton, 3, 0, 1, 1) self.birlestirButton = QPushButton(self) self.birlestirButton.setMinimumSize(QSize(150, 50)) self.birlestirButton.setText(self.trUtf8("Birleştir")) self.birlestirButton.clicked.connect(self.birlestir) self.gridLayout.addWidget(self.birlestirButton, 3, 2, 1, 1) self.dogrulaButton = QPushButton(self) self.dogrulaButton.setMinimumSize(QSize(150, 50)) self.dogrulaButton.setText(self.trUtf8("Doğrula")) self.dogrulaButton.clicked.connect(self.dogrula) self.gridLayout.addWidget(self.dogrulaButton, 7, 0, 1, 1) self.hakkindaButton = QPushButton(self) self.hakkindaButton.setMinimumSize(QSize(150, 50)) self.hakkindaButton.setText(self.trUtf8("Hakkında")) self.hakkindaButton.clicked.connect(self.hakkinda) self.gridLayout.addWidget(self.hakkindaButton, 7, 2, 1, 1) self.bilgiLabel = QLabel(self) self.bilgiLabel.setText( self.trUtf8(u"%s %s \u00a9 2011 - www.metehan.us" % (QApplication.applicationName(), QApplication.applicationVersion()))) self.bilgiLabel.setAlignment(Qt.AlignCenter) self.gridLayout.addWidget(self.bilgiLabel, 9, 0, 1, 3) spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.gridLayout.addItem(spacerItem, 3, 1, 1, 1) spacerItem1 = QSpacerItem(0, 20, QSizePolicy.Minimum, QSizePolicy.Expanding) self.gridLayout.addItem(spacerItem1, 4, 1, 1, 1) spacerItem2 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.gridLayout.addItem(spacerItem2, 2, 1, 1, 1) spacerItem3 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.gridLayout.addItem(spacerItem3, 8, 1, 1, 1)
def clear_project_save_file(self): """ Resets the save file name and window title. """ self._saveFilePath = None self._recoveryFilePath = None self.setWindowTitle(QApplication.applicationName() + ": "\ + misc.get_random_knitting_quote() + "[*]")
def initGUI(self): self.setWindowTitle(QApplication.applicationName()) layout = QVBoxLayout() headerlayout = QHBoxLayout() homeBtn = QToolButton() homeBtn.setIcon(self.ih.homeButton) homeBtn.setFixedSize(64,64) homeBtn.clicked.connect(self.home) headerlayout.addWidget(homeBtn) label = QLabel("<b>Location</b>") label.setMargin(10) label.setFixedSize(label.sizeHint()) headerlayout.addWidget(label) self.currentLocation = ClickableLabel("") self.currentLocation.setAlignment(Qt.AlignLeft | Qt.AlignVCenter) self.currentLocation.setWordWrap(True) self.currentLocation.setFixedSize(400,64) self.currentLocation.clicked.connect(self.back) headerlayout.addWidget(self.currentLocation) headerlayout.addStretch() layout.addLayout(headerlayout) self.view = QListView() self.view.setSelectionMode( QAbstractItemView.SingleSelection) self.view.setEditTriggers(QAbstractItemView.NoEditTriggers) self.view.setContextMenuPolicy(Qt.CustomContextMenu) self.view.customContextMenuRequested.connect(self.contextMenu) self.view.setModel(self.model) self.view.setModelColumn(0) #self.view.doubleClicked.connect(self.doubleClicked) self.view.activated.connect(self.activated) layout.addWidget(self.view) self.setLayout(layout)
def initializing(self): """ Initialisiert das Programm mit den Startwerten. """ self.ui.action_quit.setIcon(QIcon(":/icons/actions/exit.png")) self.ui.action_about.setIcon(QIcon(":/icons/logo/WoD.png")) self.ui.pushButton_quit.setIcon(self.ui.action_quit.icon()) self.ui.pushButton_roll.setIcon(QIcon(":icons/W10_0.svg")) self.ui.action_quit.setMenuRole(QAction.QuitRole) self.ui.action_about.setText(self.tr("About %1...").arg(QApplication.applicationName())) self.ui.action_about.setMenuRole(QAction.AboutRole) self.ui.spinBox_pool.setValue(2) self.ui.checkBox_rote.setChecked(False) self.ui.comboBox_xAgain.setCurrentIndex(0) self.ui.spinBox_target.setValue(1) self.changeText() self.ui.radioButton_target.setChecked(True) self.ui.groupBox_extended.setChecked(False) self.ui.checkBox_rollsLimited.setChecked(True) self.dice = [] for i in xrange(10): self.W10_x = QGraphicsSvgItem() self.W10_x.setSharedRenderer(self.svgRenderer) self.W10_x.setElementId("layer" + str(i)) #self.W10_x.setVisible(False) # Ich lege diese Liste an, da ich auf die Liste in self.scene irgendwie nicht zugreifen kann. self.dice.append(self.W10_x)
def show_about_sconcho(self): """ Show the about sconcho dialog. """ QMessageBox.about( self, QApplication.applicationName(), msg.sconchoDescription % (__version__, platform.python_version(), qVersion(), PYQT_VERSION_STR, platform.system()))
def __init__(self, page, parent=None): super(HelpForm, self).__init__(parent) self.setAttribute(Qt.WA_DeleteOnClose) self.setAttribute(Qt.WA_GroupLeader) backAction = QAction(QIcon(":/back.png"), "&Back", self) backAction.setShortcut(QKeySequence.Back) homeAction = QAction(QIcon(":/home.png"), "&Home", self) homeAction.setShortcut("Home") self.pageLabel = QLabel() toolBar = QToolBar() toolBar.addAction(backAction) toolBar.addAction(homeAction) toolBar.addWidget(self.pageLabel) self.textBrowser = QTextBrowser() layout = QVBoxLayout() layout.addWidget(toolBar) layout.addWidget(self.textBrowser, 1) self.setLayout(layout) self.connect(backAction, SIGNAL("triggered()"), self.textBrowser, SLOT("backward()")) self.connect(homeAction, SIGNAL("triggered()"), self.textBrowser, SLOT("home()")) self.connect(self.textBrowser, SIGNAL("sourceChanged(QUrl)"), self.updatePageTitle) self.textBrowser.setSearchPaths([":/help"]) self.textBrowser.setSource(QUrl(page)) self.resize(400, 600) self.setWindowTitle("{0} Help".format(QApplication.applicationName()))
def __init__(self, page, parent=None): super(HelpForm, self).__init__(parent) self.setAttribute(Qt.WA_DeleteOnClose) self.setAttribute(Qt.WA_GroupLeader) backAction = QAction(QIcon(":/back.png"), "&Back", self) backAction.setShortcut(QKeySequence.Back) homeAction = QAction(QIcon(":/home.png"), "&Home", self) homeAction.setShortcut("Home") self.pageLabel = QLabel() toolBar = QToolBar() toolBar.addAction(backAction) toolBar.addAction(homeAction) toolBar.addWidget(self.pageLabel) self.textBrowser = QTextBrowser() layout = QVBoxLayout() layout.addWidget(toolBar) layout.addWidget(self.textBrowser, 1) self.setLayout(layout) self.connect(backAction, SIGNAL("triggered()"), self.textBrowser, SLOT("backward()")) self.connect(homeAction, SIGNAL("triggered()"), self.textBrowser, SLOT("home()")) self.connect(self.textBrowser, SIGNAL("sourceChanged(QUrl)"), self.updatePageTitle) self.textBrowser.setSearchPaths([":/help"]) self.textBrowser.setSource(QUrl(page)) self.resize(400, 600) self.setWindowTitle("{0} Help".format( QApplication.applicationName()))
def _updateTitle(self): subWidget = self.tabsWidget.currentWidget() if subWidget is not None: self.setWindowTitle('') self.setWindowFilePath(subWidget.title) self.setWindowModified(subWidget.hexWidget.isModified) else: self.setWindowTitle(QApplication.applicationName())
def show_about_sconcho(self): """ Show the about sconcho dialog. """ QMessageBox.about(self, QApplication.applicationName(), msg.sconchoDescription % (__version__, platform.python_version(), qVersion(), PYQT_VERSION_STR, platform.system()))
def __init__(self, files_to_load): QMainWindow.__init__(self) self._inited = False self._currentMatcher = None self._lastMatch = None global globalMainWindow globalMainWindow = self self.setWindowTitle(QApplication.applicationName()) self.setWindowIcon(QIcon(':/main/images/hex.png')) self.subWidgets = [] self._activeSubWidget = None self.tabsWidget = QTabWidget(self) self.tabsWidget.setDocumentMode(True) self.tabsWidget.setTabsClosable(True) self.tabsWidget.setFocusPolicy(Qt.StrongFocus) self.tabsWidget.currentChanged.connect(self._onTabChanged) self.tabsWidget.tabCloseRequested.connect(self.closeTab) self.setCentralWidget(self.tabsWidget) self.setFocusProxy(self.tabsWidget) self.setFocus() QApplication.instance().focusChanged.connect(self._onGlobalFocusChanged) self.createActions() self.buildMenus() self.buildStatusbar() self.buildToolbar() self.dockSearch = SearchDockWidget(self) self.dockSearch.hide() self.addDockWidget(Qt.BottomDockWidgetArea, self.dockSearch) geom = globalQuickSettings['mainWindow.geometry'] if geom and isinstance(geom, str): self.restoreGeometry(QByteArray.fromHex(geom)) else: self.resize(800, 600) state = globalQuickSettings['mainWindow.state'] if state and isinstance(state, str): self.restoreState(QByteArray.fromHex(state)) app = QApplication.instance() for file_to_load in files_to_load: load_options = documents.FileLoadOptions() load_options.readOnly = app.args.readOnly load_options.freezeSize = app.args.freezeSize if app.args.noLoadDialog: self.openFile(file_to_load, load_options) else: self.openFileWithOptionsDialog(file_to_load, load_options)
def __init__(self, page, parent=None): super(HelpForm, self).__init__(parent) self.setAttribute(Qt.WA_DeleteOnClose) self.setAttribute(Qt.WA_GroupLeader) self.create_widgets() self.layout_widgets() self.create_connections() self.textBrowser.setSearchPaths([":/help"]) self.textBrowser.setSource(QUrl(page)) self.resize(400, 600) self.setWindowTitle("{0} Help".format(QApplication.applicationName()))
def set_project_save_file(self, fileName): """ Stores the name of the currently operated on file. """ self._saveFilePath = fileName self.setWindowTitle(QApplication.applicationName() + ": " \ + QFileInfo(fileName).fileName() + "[*]") self.exportBitmapDialog.update_export_path(fileName) # store location as export path self.settings.export_path = QFileInfo(fileName).absolutePath() # generate recovery file path self._recoveryFilePath = generate_recovery_filepath(fileName)
def initGUI(self): self.setWindowTitle(QApplication.applicationName()) # set background image p = self.palette() p.setBrush(QPalette.Background, QBrush(self.bg)) self.setPalette(p) layout = QVBoxLayout() layout.setContentsMargins(0,0,0,50) layout.addStretch(1) self.label = QLabel() self.updateLabel(False) layout.addWidget( self.label, 0, Qt.AlignCenter) self.setLayout(layout)
def createGUI(self): ## help tool bar self.toolBar = QToolBar(self) ## help text Browser self.textBrowser = QTextBrowser(self) layout = QVBoxLayout(self) layout.addWidget(self.toolBar) layout.addWidget(self.textBrowser, 1) self.setLayout(layout) self.textBrowser.setSearchPaths([":/help"]) self.textBrowser.setSource(QUrl(self._page)) self.resize(660, 700) self.setWindowTitle("%s Help" % (QApplication.applicationName()))
def __init__(self, config): QObject.__init__(self) self.config = config self._currentSong = None if dbus is None: self.config.showNotification = False return self.notificationId = dbus.UInt32(0) self.appName = unicode(QApplication.applicationName().toUtf8()) self.appIcon = os.path.abspath(DATA_DIR+'icons/Pythagora.png') self.notificationSummary = '%s, now playing:' % self.appName self.notificationHints = dbus.Dictionary( {'suppress-sound': True, 'desktop-entry': 'pythagora', 'image_path': ''}, 'sv') self._connect()
def startmain(): """ Initialise the application and display the main window. """ app = QApplication(sys.argv) app.cleanup_files = [] QApplication.setStyle(QStyleFactory.create('CleanLooks')) QApplication.setPalette(QApplication.style().standardPalette()) QApplication.setApplicationName('Bing Wallpaper Changer') QApplication.setApplicationVersion(VERSION) QApplication.setOrganizationName('overThere.co.uk') QApplication.setWindowIcon(QIcon(':/icons/ui/ot_icon.svg')) print 'AppName: %s' % QApplication.applicationName() print 'AppVersion: %s' % QApplication.applicationVersion() print 'Company Name: %s' % QApplication.organizationName() QLocale.setDefault(QLocale(QLocale.English, QLocale.UnitedKingdom)) # Add passed arguments to app. app.args = parse_arguments() print 'Args:', app.args # Check to see if application already running. existing_pid = instance_check(app) if existing_pid: print existing_pid if app.args.quit_existing: # Command line argument passed to close existing program. Do that, then quit. if platform.system() == "Windows": subprocess.Popen("taskkill /F /T /PID %i" % existing_pid, shell=True) else: os.killpg(existing_pid, signal.SIGKILL) else: message_box_error('Program already running.', 'You can only have one copy of the Bing Wallpaper Changer running at once.') sys.exit() mainwindow = MainWindow() # mainwindow.show() sys.exit(app.exec_())
def start_main(): app = QApplication(sys.argv) icon = QIcon(':/icons/application.png') app.setWindowIcon(icon) # If compiled as a one-file PyInstaller package look for Qt4 Plugins in the TEMP folder. try: extra_path = [os.path.join(sys._MEIPASS, 'qt4_plugins')] app.setLibraryPaths(app.libraryPaths() + extra_path) app.utils_path = os.path.join(sys._MEIPASS, 'utils') except AttributeError: app.utils_path = os.path.join(os.getcwd(), 'utils') # Error handling stuff. if hasattr(sys, 'frozen'): sys.excepthook = except_hook app.setApplicationName('ABBYY Automator') app.setApplicationVersion(VERSION) app.setOrganizationName('Pearl Scan Solutions') print 'AppName: %s' % app.applicationName() print 'AppVersion: %s' % app.applicationVersion() print 'Company Name: %s' % app.organizationName() app.setStyle(QStyleFactory.create('Cleanlooks')) app.setPalette(QApplication.style().standardPalette()) if not instance_check(app): message_box_error('Program already running.', 'You can only have one copy of ABBYY Automator running at once.') sys.exit() mainwindow = MainWindow() mainwindow.show() app.exec_() app.closeAllWindows() app.quit()
def __setup_ui(self): self.setWindowTitle(QApplication.applicationName()) self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowMinMaxButtonsHint) self.setWindowModality(Qt.WindowModal) self.setAttribute(Qt.WA_TranslucentBackground) self.setMouseTracking(True) self.setAnimated(True) self.setMinimumSize( self.WIDTH_MIN + self.OFFSET_BORDER_RIGHT + self.OFFSET_BORDER_LEFT, self.HEIGHT_MIN + self.OFFSET_BORDER_TOP + self.OFFSET_BORDER_BOTTOM) self.resize( self.WIDTH_DEFAULT + self.OFFSET_BORDER_RIGHT + self.OFFSET_BORDER_LEFT, self.HEIGHT_DEFAULT + self.OFFSET_BORDER_TOP + self.OFFSET_BORDER_BOTTOM) self.setWindowIcon(QIcon(':logo')) # Title bar initialization start. self.__btn_title_close = MButton(self, MButton.Type.Close) self.__btn_title_close.setGeometry(14, 11, 12, 13) self.__btn_title_close.setToolTip('退出') self.__btn_title_maximize = MButton(self, MButton.Type.Maximize) self.__btn_title_maximize.setGeometry(self.__btn_title_close.x() + 16, 11, 12, 13) self.__btn_title_maximize.setToolTip('最大化') self.__btn_title_minimize = MButton(self, MButton.Type.Minimize) self.__btn_title_minimize.setGeometry( self.__btn_title_maximize.x() + 16, 11, 12, 13) self.__btn_title_minimize.setToolTip('最小化') self.frame = MFrame(self) horizontal_layout = QHBoxLayout(self.frame) horizontal_layout.setContentsMargins(0, 0, 4, 0) horizontal_layout.setSpacing(5) # Left panel initialization start. frame_main_panel = MFrame(self.frame) size_policy_v_expand = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding) size_policy_v_expand.setHorizontalStretch(0) size_policy_v_expand.setVerticalStretch(0) size_policy_v_expand.setHeightForWidth( frame_main_panel.sizePolicy().hasHeightForWidth()) frame_main_panel.setSizePolicy(size_policy_v_expand) frame_main_panel.setMinimumSize(self.WIDTH_FRAME_LEFT, 0) horizontal_layout.addWidget(frame_main_panel) verticalLayout = QVBoxLayout(frame_main_panel) verticalLayout.setContentsMargins(0, 0, 0, 0) verticalLayout.setSpacing(0) self.__action_bar = MActionBar(frame_main_panel) size_policy_h_expand = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) size_policy_h_expand.setHorizontalStretch(0) size_policy_h_expand.setVerticalStretch(0) size_policy_h_expand.setHeightForWidth( self.__action_bar.sizePolicy().hasHeightForWidth()) self.__action_bar.setSizePolicy(size_policy_h_expand) self.__action_bar.setMinimumSize(0, 136) verticalLayout.addWidget(self.__action_bar) frame_music_list = MFrame(frame_main_panel) size_policy_all_expand = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) size_policy_all_expand.setHorizontalStretch(0) size_policy_all_expand.setVerticalStretch(0) size_policy_all_expand.setHeightForWidth( frame_music_list.sizePolicy().hasHeightForWidth()) frame_music_list.setSizePolicy(size_policy_all_expand) verticalLayout.addWidget(frame_music_list) gridLayout = QGridLayout(frame_music_list) gridLayout.setContentsMargins(9, 2, 9, 5) self.__music_table = QTableWidget(0, 2, frame_music_list) self.__music_table.setFrameShape(QFrame.StyledPanel) self.__music_table.setHorizontalHeaderLabels(('标题', '时长')) self.__music_table.setSelectionMode(QAbstractItemView.SingleSelection) self.__music_table.setSelectionBehavior(QAbstractItemView.SelectRows) self.__music_table.horizontalHeader().setVisible(False) self.__music_table.verticalHeader().setVisible(False) self.__music_table.setColumnWidth(0, 290) self.__music_table.setColumnWidth(1, 50) MStyleSetter.setStyle(self.__music_table, ':qss_tbl_music_list') gridLayout.addWidget(self.__music_table, 0, 0, 1, 1) # Lyric panel initialization start. self.lyric_panel = MLyricPanel(self.frame) size_policy_all_expand.setHeightForWidth( self.lyric_panel.sizePolicy().hasHeightForWidth()) self.lyric_panel.setSizePolicy(size_policy_all_expand) horizontal_layout.addWidget(self.lyric_panel)
def __init__(self, parent): QDialog.__init__(self, parent) self.resize(500, 350) self.setMaximumSize(500, 350) self.gLayout = QGridLayout(self) self.logo = QLabel(self) self.logo.setPixmap(QPixmap(":/resim/parcala.png")) self.gLayout.addWidget(self.logo, 0, 0, 2, 1) self.appName = QLabel(self) font = QFont() font.setPointSize(32) font.setWeight(50) self.appName.setFont(font) self.gLayout.addWidget(self.appName, 0, 1, 1, 2) self.appVersion = QLabel(self) font = QFont() font.setPointSize(9) font.setWeight(75) font.setBold(True) self.appVersion.setFont(font) self.appVersion.setAlignment(Qt.AlignHCenter|Qt.AlignTop) self.gLayout.addWidget(self.appVersion, 1, 1, 1, 2) self.gBox = QGroupBox(self) font = QFont() font.setPointSize(12) font.setWeight(75) font.setBold(True) self.gBox.setFont(font) self.gLayout2 = QGridLayout(self.gBox) self.scrollArea = QScrollArea(self.gBox) self.scrollArea.setFrameShape(QFrame.NoFrame) self.scrollArea.setWidgetResizable(True) self.scrollAreaWidgetContents = QWidget() self.scrollAreaWidgetContents.setGeometry(0, 0, 476, 199) self.gLayout3 = QGridLayout(self.scrollAreaWidgetContents) self.appHakkinda = QLabel(self.scrollAreaWidgetContents) font = QFont() font.setPointSize(9) font.setWeight(50) font.setBold(False) self.appHakkinda.setFont(font) self.appHakkinda.setWordWrap(True) self.gLayout3.addWidget(self.appHakkinda, 0, 0, 1, 1) self.scrollArea.setWidget(self.scrollAreaWidgetContents) self.gLayout2.addWidget(self.scrollArea, 0, 0, 1, 1) self.gLayout.addWidget(self.gBox, 2, 0, 2, 4) spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.gLayout.addItem(spacerItem, 0, 3, 1, 1) spacerItem1 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.gLayout.addItem(spacerItem1, 2, 1, 1, 2) self.setWindowTitle(self.trUtf8(u"%s Hakkında"%QApplication.applicationName())) self.appName.setText(self.trUtf8(u"%s"%QApplication.applicationName())) self.appVersion.setText(self.trUtf8(u"Sürüm %s"%QApplication.applicationVersion())) self.gBox.setTitle(self.trUtf8("Hakkında")) self.appHakkinda.setText(self.trUtf8(""" <p>Parçala, Hj-Split ile aynı işi yapan dosya parçalama ve birleştirme yazılımıdır.</p> <p>Parçala, büyük boyutlu dosyaları parçalara böldüğü gibi parçalanmış dosyaları birleştirme ve dosyaların doğrulamasını yapabilmektedir.</p> <p><b>Geliştirici:</b> Metehan Özbek - <a href='mailto:[email protected]'>[email protected]</a></p> <p><b>Görsel Çalışma:</b> Yasin Özcan - <a href='mailto:[email protected]'>[email protected]</a></p> <p><b>Lisans:</b> GPL v3</p> <p></p>"""))
def saveEvaluationAs(self): filename = str(QFileDialog.getSaveFileName(self, caption=("%s - Save current evaluation"%QApplication.applicationName()), directory = str("."), filter=str("XML files (*.xml)"))) if not filename: return misc.saveAsXML(self.evaluation, filename) self.filename = filename self.updateStatus("Saved evaluation to file %s"%filename)
def loadEvaluation(self): thedir = str(".") filename = str(QFileDialog.getOpenFileName(self, caption=("%s - Load an evaluation"%QApplication.applicationName()), directory=thedir, filter=str("XML files (*.xml)"))) if filename: try: ev = IPETEvaluation.fromXMLFile(filename) message = "Loaded evaluation from %s"%filename self.setEvaluation(ev) except Exception: message = "Error: Could not load evaluation from file %s"%filename self.updateStatus(message) pass
def onAboutAppAction(self): QMessageBox.about(self, self.tr("&about"), self.tr("%1 version %2").arg(QApplication.applicationName()).arg(QApplication.applicationVersion()))
def __init__(self): QMainWindow.__init__(self) self.sync_delay = 5 self.sync_active = False self.verbose = False self.timePattern = re.compile('\.[0-9]+$') self.setWindowTitle('%s %s' % (QApplication.applicationName(), QApplication.applicationVersion())); self.widget = QWidget() self.setCentralWidget(self.widget) self.statusBar = QStatusBar(self) self.setStatusBar(self.statusBar) self.mAction = self.menuBar().addMenu(self.tr("&Action")) #self.mAction.addAction(self.tr("&update"), self.updateTplTable(), QKeySequence('F5')) self.mAction.addAction(self.tr('&import records'), self.onImport, QKeySequence('F6')) self.mAction.addAction(self.tr('edit &settings'), self.onSettings, QKeySequence('F8')) self.mAction.addAction(self.tr("e&xit"), self.onExit, 'Ctrl+Q') self.mAbout = self.menuBar().addMenu(self.tr("&about")) self.mAbout.addAction(QApplication.applicationName(), self.onAboutAppAction) self.mAbout.addAction("Qt", self.onAboutQtAction) self.pageForwardButton = QPushButton(self) self.pageForwardButton.setText('>') self.connect(self.pageForwardButton, SIGNAL('clicked()'), self.pageForward) self.pageBackwardButton = QPushButton(self) self.pageBackwardButton.setText('<') self.connect(self.pageBackwardButton, SIGNAL('clicked()'), self.pageBackward) self.timer = QTimer(self) self.timer.setInterval(1000) self.connect(self.timer, SIGNAL('timeout()'), self, SLOT('onTimer()')) self.time_begin = datetime.now() self.time_end = datetime.now() self.db_path = os.path.join(os.path.dirname(sys.argv[0]) if os.name != 'posix' else os.path.expanduser('~'), '.tt2.db') self.db = sqlite3.connect(self.db_path) self.cursor = self.db.cursor() try: self.cursor.execute('SELECT id FROM tt LIMIT 1') except: self.createDb() self.settings = self.fetchSettings() self.syncer = Syncer(self.db_path, self) self.connect( self.syncer, SIGNAL('active'), self.setSyncerActive ) self.connect( self.syncer, SIGNAL('message'), self.msg ) self.connect( self.syncer, SIGNAL('newSettings'), self.fetchSettings ) self.layout = QGridLayout(self.widget) self.descriptionLabel = QLabel(self.widget) self.descriptionLabel.setText('Beschreibung') self.descriptionLabel.setMaximumHeight( self.font().pointSize() * 2 ) self.descriptionInput = QLineEdit(self.widget) self.updateDescriptionEditCompleter() self.noteLabel = QLabel(self.widget) self.noteLabel.setText('Notiz') self.noteLabel.setMaximumHeight( self.font().pointSize() * 2 ) self.noteInput = QLineEdit(self.widget) self.startStopButton = QPushButton(self.widget) self.startStopButton.setText('Start') self.tableView = TplTable(self, int( self.getSetting('displayrows', DEFAULTROWS) ) ) self.pageForwardAction = QAction(self) self.pageForwardAction.setShortcut(QKeySequence('Right')) self.connect(self.pageForwardAction, SIGNAL('triggered()'), self.pageForward); self.pageForwardButton.addAction(self.pageForwardAction) self.pageBackwardAction = QAction(self) self.pageBackwardAction.setShortcut(QKeySequence('Left')) self.connect(self.pageBackwardAction, SIGNAL('triggered()'), self.pageBackward); self.pageBackwardButton.addAction(self.pageBackwardAction) self.updateTplTable() self.layout.addWidget(self.descriptionLabel, 0, 0, 1, 1) self.layout.addWidget(self.descriptionInput, 1, 0, 1, 1) self.layout.addWidget(self.noteLabel, 0, 1, 1, 1) self.layout.addWidget(self.noteInput, 1, 1, 1, 1) self.layout.addWidget(self.startStopButton, 2, 0, 1, 2) self.layout.addWidget(self.tableView, 3,0,1,2) self.layout.addWidget(self.pageBackwardButton, 4, 0, 1, 1) self.layout.addWidget(self.pageForwardButton, 4, 1, 1, 1) self.connect(self.descriptionInput, SIGNAL('returnPressed ()'), self.onStartStop ) self.connect(self.noteInput, SIGNAL('returnPressed ()'), self.onStartStop ) self.connect(self.startStopButton, SIGNAL('clicked()'), self.onStartStop ) self.connect(self.tableView, SIGNAL('valueChanged(int)'), self.onValueChanged ) self.connect(self.tableView, SIGNAL('del(int)'), self.onDelete ) self.last_sync = datetime.now() self.sync()
def __init__(self): QMainWindow.__init__(self) self.setWindowTitle('%s %s' % (QApplication.applicationName(), QApplication.applicationVersion())); self.config = ConfigHandler(os.path.join(os.path.expanduser('~'), '.pywv/pywv.cfg'), self) self.setStyle(QStyleFactory.create(self.config.loadStyle())) if self.config.loadStyleSheet(): self.setStyleSheet(self.config.loadStyleSheet()) else: self.setStyleSheet("* {}") # without any stylesheet, windowstyles won't apply self.setDockOptions(QMainWindow.AnimatedDocks | QMainWindow.AllowNestedDocks | QMainWindow.AllowTabbedDocks | QMainWindow.VerticalTabs); # self.dummy = QWidget(self) self.setCentralWidget(QWidget(self)) self.pBar = QProgressBar(self) self.pBar.setRange(0, self.config.loadReloadInterval()) self.pBar.setFormat("%v Sekunden") if not self.config.loadAutoload(): self.pBar.hide() self.statusBar = QStatusBar(self) self.setStatusBar(self.statusBar) self.statusBar.addWidget(self.pBar) self.reloadTimer = QTimer(self); self.reloadTimer.setInterval(self.config.loadReloadInterval() * 1000) self.connect(self.reloadTimer, SIGNAL('timeout()'), self.reload_) if self.config.loadAutoload(): self.reloadTimer.start() self.autoloadStatusTimer = QTimer(self) self.autoloadStatusTimer.setInterval(1000) # 1 sec self.connect(self.autoloadStatusTimer, SIGNAL('timeout()'), self.onAutoloadStatus) self.autoloadStatusTimer.start() self.mAction = self.menuBar().addMenu(self.tr("&Action")) self.mAction.addAction(self.tr("&update"), self.reload_, QKeySequence('F5')) self.mAction.addAction(self.tr("e&xit"), self.onExit, 'Ctrl+Q') self.mStyle = QMenu(self.tr("&Style"), self) for s in list(QStyleFactory.keys()):# // fill in all available Styles self.mStyle.addAction(s) self.connect(self.mStyle, SIGNAL('triggered(QAction*)'), self.onStyleMenu) self.mOption = self.menuBar().addMenu(self.tr("&Options")) self.mOption.addAction(self.tr("reloadinterval") , self.onReloadTime , 'F8') self.mOption.addAction(self.tr("manage links") , self.onNewLink , 'F6') self.mOption.addSeparator() self.ontopAction = QAction(self.tr("always on &top") , self) self.showTrayAction = QAction(self.tr("show tray &icon") , self) self.closeToTrayAction = QAction(self.tr("close to &tray") , self) self.autoloadAction = QAction(self.tr("auto&load") , self) self.ontopAction.setCheckable(True) self.showTrayAction.setCheckable(True) self.closeToTrayAction.setCheckable(True) self.autoloadAction.setCheckable(True) self.showTrayAction.setChecked (self.config.loadShowTray() ) self.ontopAction.setChecked (self.config.loadOntop() ) self.closeToTrayAction.setChecked(self.config.loadCloseToTray()) self.autoloadAction.setChecked (self.config.loadAutoload() ) self.connect(self.ontopAction , SIGNAL('toggled(bool)') , self.onOntopAction) self.connect(self.showTrayAction , SIGNAL('toggled(bool)') , self.onShowTrayAction) self.connect(self.closeToTrayAction , SIGNAL('toggled(bool)') , self.onCloseToTrayAction) self.connect(self.autoloadAction , SIGNAL('toggled(bool)') , self.onAutoloadAction) self.mOption.addAction(self.ontopAction) self.mOption.addAction(self.showTrayAction) self.mOption.addAction(self.closeToTrayAction) self.mOption.addAction(self.autoloadAction) self.mOption.addSeparator() self.mOption.addMenu(self.mStyle) self.trayIcon = QSystemTrayIcon(QIcon(':/appicon'), self); self.trayMgr = TrayManager(self.config, self.trayIcon) self.connect(self.trayIcon, SIGNAL('activated(QSystemTrayIcon::ActivationReason)'), self.onTrayIcon) if self.config.loadShowTray(): self.trayIcon.show() self.trayIconMenu = QMenu() self.trayIconMenu.addAction(self.tr("e&xit"), self.onExit) self.trayIcon.setContextMenu(self.trayIconMenu) self.mAbout = self.menuBar().addMenu(self.tr("&about")) self.mAbout.addAction(QApplication.applicationName(), self.onAboutAppAction) self.mAbout.addAction("Qt", self.onAboutQtAction) self.createWidgets() self.resize(self.config.loadWindowSize()) self.restoreState(self.config.loadWindowState()) if self.config.loadIsVisible(): self.show() self.reload_()
def __init__(self): QMainWindow.__init__(self) self.listSize = 20 self.verbose = False self.timePattern = re.compile('\.[0-9]+$') self.setWindowTitle('%s %s' % (QApplication.applicationName(), QApplication.applicationVersion())); self.widget = QWidget() self.setCentralWidget(self.widget) self.statusBar = QStatusBar(self) self.setStatusBar(self.statusBar) self.mAction = self.menuBar().addMenu(self.tr("&Action")) #self.mAction.addAction(self.tr("&update"), self.updateTplTable(), QKeySequence('F5')) self.mAction.addAction(self.tr("e&xit"), self.onExit, 'Ctrl+Q') self.mAbout = self.menuBar().addMenu(self.tr("&about")) self.mAbout.addAction(QApplication.applicationName(), self.onAboutAppAction) self.mAbout.addAction("Qt", self.onAboutQtAction) self.pageForwardButton = QPushButton(self) self.pageForwardButton.setText('>') self.connect(self.pageForwardButton, SIGNAL('clicked()'), self.pageForward) self.pageBackwardButton = QPushButton(self) self.pageBackwardButton.setText('<') self.connect(self.pageBackwardButton, SIGNAL('clicked()'), self.pageBackward) self.timer = QTimer(self) self.timer.setInterval(1000) self.connect(self.timer, SIGNAL('timeout()'), self, SLOT('onTimer()')) self.time_begin = datetime.now() self.time_end = datetime.now() db_path = os.path.join(os.path.dirname(sys.argv[0]) if os.name != 'posix' else os.path.expanduser('~'), '.tt.db') self.db = sqlite3.connect(db_path) self.cursor = self.db.cursor() try: self.cursor.execute('SELECT id FROM timebrowser_record LIMIT 1') except: try: # print 'migrate' # print 'try tt' self.cursor.execute('SELECT id FROM tt LIMIT 1') # print 'may drop timebrowser_record' self.cursor.execute('DROP TABLE IF EXISTS timebrowser_record') # print 'get create statements' self.cursor.execute('''SELECT sql FROM sqlite_master WHERE type='table' AND name='tt' ''') sql1 = self.cursor.fetchone()[0].replace( ' tt ', ' timebrowser_record ' ) self.cursor.execute('''SELECT sql FROM sqlite_master WHERE type='index' AND tbl_name='tt' ''') sql2 = self.cursor.fetchone()[0].replace( ' tt ', ' timebrowser_record ' ) # print 'drop index' self.cursor.execute('DROP INDEX IF EXISTS idx_time_begin') # print 'apply create statements' self.cursor.execute( sql1 ) self.cursor.execute( sql2 ) # print 'copy data' self.cursor.execute( 'INSERT INTO timebrowser_record SELECT * FROM tt' ) # print 'drop tt' self.cursor.execute( 'DROP TABLE tt' ) self.statusBar.showMessage('successfully migrated Database!') # print 'done' except:# Exception, e: # print e self.createDb() self.layout = QGridLayout(self.widget) self.descriptionLabel = QLabel(self.widget) self.descriptionLabel.setText('Beschreibung') self.descriptionLabel.setMaximumHeight( self.font().pointSize() * 2 ) self.descriptionInput = QLineEdit(self.widget) self.updateDescriptionEditCompleter() self.noteLabel = QLabel(self.widget) self.noteLabel.setText('Notiz') self.noteLabel.setMaximumHeight( self.font().pointSize() * 2 ) self.noteInput = QLineEdit(self.widget) self.startStopButton = QPushButton(self.widget) self.startStopButton.setText('Start') self.tableView = TplTable(self, self.listSize) self.pageForwardAction = QAction(self) self.pageForwardAction.setShortcut(QKeySequence('Right')) self.connect(self.pageForwardAction, SIGNAL('triggered()'), self.pageForward); self.pageForwardButton.addAction(self.pageForwardAction) self.pageBackwardAction = QAction(self) self.pageBackwardAction.setShortcut(QKeySequence('Left')) self.connect(self.pageBackwardAction, SIGNAL('triggered()'), self.pageBackward); self.pageBackwardButton.addAction(self.pageBackwardAction) self.updateTplTable() self.layout.addWidget(self.descriptionLabel, 0, 0, 1, 1) self.layout.addWidget(self.descriptionInput, 1, 0, 1, 1) self.layout.addWidget(self.noteLabel, 0, 1, 1, 1) self.layout.addWidget(self.noteInput, 1, 1, 1, 1) self.layout.addWidget(self.startStopButton, 2, 0, 1, 2) self.layout.addWidget(self.tableView, 3,0,1,2) self.layout.addWidget(self.pageBackwardButton, 4, 0, 1, 1) self.layout.addWidget(self.pageForwardButton, 4, 1, 1, 1) self.connect(self.descriptionInput, SIGNAL('returnPressed ()'), self.onStartStop ) self.connect(self.noteInput, SIGNAL('returnPressed ()'), self.onStartStop ) self.connect(self.startStopButton, SIGNAL('clicked()'), self.onStartStop ) self.connect(self.tableView, SIGNAL('valueChanged(int)'), self.onValueChanged ) self.connect(self.tableView, SIGNAL('del(int)'), self.onDelete )
def initGUI(self): self.setWindowTitle(QApplication.applicationName()) self.fmt = QFontMetrics(QFont()) layout = QVBoxLayout() toplayout = QHBoxLayout() currentLayout = QGridLayout() currentLayout.setContentsMargins(0,20,0,20) currentLayout.setHorizontalSpacing(100) currentLayout.setVerticalSpacing(20) # current song information currentLayout.addWidget(QLabel("<b>Artist</b>"),1,0) self.artist = QLabel() currentLayout.addWidget(self.artist,1,1) currentLayout.addWidget(QLabel("<b>Title</b>"),2,0) self.title = QLabel() currentLayout.addWidget(self.title,2,1) currentLayout.addWidget(QLabel("<b>Albumartist</b>"),3,0) self.albumartist = QLabel() currentLayout.addWidget(self.albumartist,3,1) currentLayout.addWidget(QLabel("<b>Album</b>"),4,0) self.album = QLabel() currentLayout.addWidget(self.album,4,1) # playlist and song position self.playlistposition = QLabel() currentLayout.addWidget(self.playlistposition,5,0) poslayout = QHBoxLayout() poslayout.setSpacing(10) self.time = QLabel("00:00") poslayout.addWidget(self.time) self.position = QSlider(Qt.Horizontal) self.position.setTracking(False) self.position.setSingleStep(10) self.position.sliderReleased.connect( self.seek) self.position.sliderMoved.connect( lambda x: self.time.setText(self.mpd.timeString(x))) poslayout.addWidget(self.position) self.length = QLabel("00:00") poslayout.addWidget(self.length) currentLayout.addLayout(poslayout,5,1) toplayout.addLayout(currentLayout) layout.addLayout(toplayout) layout.addStretch(1) self.settingsWidget = QMenu() self.consumeBtn = self.settingsWidget.addAction("Consume") self.consumeBtn.setCheckable(True) self.consumeBtn.triggered.connect( lambda x: self.mpd.consume(int(x))) self.singleBtn = self.settingsWidget.addAction("Single") self.singleBtn.setCheckable(True) self.singleBtn.triggered.connect( lambda x: self.mpd.single(int(x))) toolLayout = QHBoxLayout() self.settingsBtn = QToolButton() self.settingsBtn.setFixedSize(64,64) self.settingsBtn.setIcon( self.ih.settingsButton) self.settingsBtn.clicked.connect(self.showAdditionalControls) toolLayout.addWidget(self.settingsBtn) toolWidget = QStackedWidget() transpWidget = QWidget() transpLayout = QHBoxLayout() self.prevBtn = self.createButton( self.ih.prevButton, self.ih.prevButtonPressed) self.prevBtn.clicked.connect( lambda x: self.mpd.previous()) transpLayout.addWidget(self.prevBtn) self.playBtn = self.createCheckButton( self.ih.playButton, self.ih.pauseButton) self.playBtn.clicked.connect( self.playPressed) transpLayout.addWidget(self.playBtn) self.stopBtn = self.createButton( self.ih.stopButton, self.ih.stopButtonPressed) self.stopBtn.clicked.connect( lambda x: self.mpd.stop()) transpLayout.addWidget(self.stopBtn) self.nextBtn = self.createButton( self.ih.nextButton, self.ih.nextButtonPressed) self.nextBtn.clicked.connect( lambda x: self.mpd.next()) transpLayout.addWidget(self.nextBtn) self.shuffleBtn = self.createCheckButton( self.ih.shuffleButton, self.ih.shuffleButtonPressed) self.shuffleBtn.toggled.connect( lambda x: self.mpd.random(1) if x else self.mpd.random(0)) transpLayout.addWidget(self.shuffleBtn) self.repeatBtn = self.createCheckButton( self.ih.repeatButton, self.ih.repeatButtonPressed) self.repeatBtn.toggled.connect( lambda x: self.mpd.repeat(1) if x else self.mpd.repeat(0)) transpLayout.addWidget(self.repeatBtn) transpLayout.addSpacing(64) transpWidget.setLayout(transpLayout) toolWidget.addWidget( transpWidget) self.volume = QSlider(Qt.Horizontal) self.volume.valueChanged.connect(self.mpd.setvol) toolWidget.addWidget(self.volume) toolLayout.addWidget(toolWidget) self.volumeBtn = QToolButton() self.volumeBtn.setFixedSize(64,64) self.volumeBtn.setCheckable(True) self.volumeBtn.setIcon( self.ih.volumeButton) self.volumeBtn.toggled.connect( lambda x: toolWidget.setCurrentIndex(x)) toolLayout.addWidget(self.volumeBtn) layout.addLayout(toolLayout) self.setLayout(layout)