我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用PySide.QtGui.QApplication()。
def main(): app = QApplication([]) webview = QWebView() loop = QEventLoop() webview.loadFinished.connect(loop.quit) webview.load(QUrl('http://example.webscraping.com/search')) loop.exec_() webview.show() frame = webview.page().mainFrame() frame.findFirstElement('#search_term').setAttribute('value', '.') frame.findFirstElement('#page_size option:checked').setPlainText('1000') frame.findFirstElement('#search').evaluateJavaScript('this.click()') elements = None while not elements: app.processEvents() elements = frame.findAllElements('#results a') countries = [e.toPlainText().strip() for e in elements] print countries
def main(): from PySide import QtGui from bar_widget import BarWidget app = QtGui.QApplication(sys.argv) widget = BarWidget() widget.setWindowTitle('Direction Of Arrival') widget.show() doa = DOA() quit_event = threading.Event() thread = threading.Thread(target=doa.start, args=(quit_event, widget.setBars)) thread.start() app.exec_() quit_event.set() thread.join()
def quickModKeyAsk(self): modifiers = QtWidgets.QApplication.queryKeyboardModifiers() clickMode = 0 # basic mode if modifiers == QtCore.Qt.ControlModifier: clickMode = 1 # ctrl elif modifiers == QtCore.Qt.ShiftModifier: clickMode = 2 # shift elif modifiers == QtCore.Qt.AltModifier: clickMode = 3 # alt elif modifiers == QtCore.Qt.ControlModifier | QtCore.Qt.ShiftModifier | QtCore.Qt.AltModifier: clickMode = 4 # ctrl+shift+alt elif modifiers == QtCore.Qt.ControlModifier | QtCore.Qt.AltModifier: clickMode = 5 # ctrl+alt elif modifiers == QtCore.Qt.ControlModifier | QtCore.Qt.ShiftModifier: clickMode = 6 # ctrl+shift elif modifiers == QtCore.Qt.AltModifier | QtCore.Qt.ShiftModifier: clickMode = 7 # alt+shift return clickMode
def __init__(self, filename=None): QtGui.QApplication.__init__(self, ['Talpa']) splash_img = QtGui.QPixmap( get_resource('talpa_splash.png'))\ .scaled(QtCore.QSize(400, 250), QtCore.Qt.KeepAspectRatio) self.splash = QtGui.QSplashScreen( splash_img, QtCore.Qt.WindowStaysOnTopHint) self.updateSplashMessage('') self.splash.show() self.processEvents() self.talpa_win = TalpaMainWindow(filename=filename) self.splash.finish(self.talpa_win) self.aboutToQuit.connect(self.splash.deleteLater) self.aboutToQuit.connect(self.deleteLater) self.talpa_win.show() rc = self.exec_() sys.exit(rc)
def save_file(self, fileName): '''(file open for writing)-> boolean ''' fname = QtCore.QFile(fileName) if not fname.open(QtCore.QFile.WriteOnly | QtCore.QFile.Text): QtGui.QMessageBox.warning(self, "Application", "Cannot write file %s:\n%s." % (fileName, fname.errorString())) return False outf = QtCore.QTextStream(fname) QtGui.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor) outf << self.ui.textEdit.toPlainText() QtGui.QApplication.restoreOverrideCursor() # self.setCurrentFile(fileName); # QtGui.QMessageBox.about(self,'Information',"File saved")
def launchFinPlateController(osdagMainWindow): set_osdaglogger() rawLogger = logging.getLogger("raw") rawLogger.setLevel(logging.INFO) fh = logging.FileHandler("./Connections/Shear/Finplate/fin.log", mode="w") formatter = logging.Formatter('''%(message)s''') fh.setFormatter(formatter) rawLogger.addHandler(fh) rawLogger.info('''<link rel="stylesheet" type="text/css" href="./Connections/Shear/Finplate/log.css"/>''') # app = QtGui.QApplication(sys.argv) window = MainController() osdagMainWindow.hide() window.show() window.closed.connect(osdagMainWindow.show) # sys.exit(app.exec_())
def main(params, nb_cpu, nb_gpu, use_gpu, extension): logger = init_logging(params.logfile) logger = logging.getLogger('circus.merging') file_out_suff = params.get('data', 'file_out_suff') extension_in = extension extension_out = '-merged' if comm.rank == 0: if (extension != '') and (os.path.exists(file_out_suff + '.result%s.hdf5' %extension_out)): erase = query_yes_no("Export already made! Do you want to erase everything?", default=None) if erase: purge(file_out_suff, extension) extension_in = '' comm.Barrier() if comm.rank == 0: app = QApplication([]) try: pylab.style.use('ggplot') except Exception: pass else: app = None if comm.rank == 0: print_and_log(['Launching the merging GUI...'], 'debug', logger) mygui = gui.MergeWindow(params, app, extension_in, extension_out) sys.exit(app.exec_())
def qWait(msec): start = time.time() QtGui.QApplication.processEvents() while time.time() < start + msec * 0.001: QtGui.QApplication.processEvents()
def getPaletteInfo(): palette = QtGui.QApplication.palette() # build a dict with all the colors result = {} for role in roles: for group in groups: qGrp = getattr(QtGui.QPalette, group) qRl = getattr(QtGui.QPalette, role) result['%s:%s' % (role, group)] = palette.color(qGrp, qRl).rgba() return result
def setPaletteFromDct(dct): palette = QtGui.QPalette() for role in roles: for group in groups: color = QtGui.QColor(dct['%s:%s' % (role, group)]) qGrp = getattr(QtGui.QPalette, group) qRl = getattr(QtGui.QPalette, role) palette.setColor(qGrp, qRl, color) QtGui.QApplication.setPalette(palette)
def startup(restart=False): app = QtGui.QApplication.instance() if not app: app = QtGui.QApplication([]) # app = QtGui.QApplication(sys.argv) # app.setStyle("plastique") # setPaletteFromDct(palette) window = lib.ui_main_classes.Ui_Main() env.Inst.ui_standalone = window window.main_layout.setSpacing(6) window.main_layout.setContentsMargins(9, 9, 9, 0) window.statusBar() window.show() sys.exit(app.exec_())
def main(): app = QtGui.QApplication(sys.argv) MainWindow = Window() app.exec_()
def __init__(self, argparser): from gramps.gen.dbstate import DbState from guiQML.viewmanager import ViewManager from gramps.cli.arghandler import ArgHandler from PySide import QtGui self.app = QtGui.QApplication(sys.argv) dbstate = DbState() self.vm = ViewManager(dbstate) #act based on the given arguments ah = ArgHandler(dbstate, argparser, self.vm, self.argerrorfunc, gui=True) ah.handle_args_gui() if ah.open or ah.imp_db_path: # if we opened or imported something, only show the interface self.vm.post_init_interface() elif config.get('paths.recent-file') and config.get('behavior.autoload'): # if we need to autoload last seen file, do so filename = config.get('paths.recent-file') if os.path.isdir(filename) and \ os.path.isfile(os.path.join(filename, "name.txt")) and \ ah.check_db(filename): self.vm.open_activate(filename) self.vm.post_init_interface() else: self.vm.post_init_interface() else: # open without fam tree loaded self.vm.post_init_interface() #start the QT loop self.app.exec_()
def ensureQapp(): global _qt_app if not globals().get("_qt_app"): _qt_app = QtGui.QApplication([])
def retranslateUi(self, Form): Form.setWindowTitle(QtGui.QApplication.translate( "Form", "Form", None, QtGui.QApplication.UnicodeUTF8)) self.Username.setText(QtGui.QApplication.translate( "Form", "Username :", None, QtGui.QApplication.UnicodeUTF8)) self.Password.setText(QtGui.QApplication.translate( "Form", "Password :", None, QtGui.QApplication.UnicodeUTF8)) self.Login.setText(QtGui.QApplication.translate( "Form", "Log in", None, QtGui.QApplication.UnicodeUTF8)) self.Captslog.setText(QtGui.QApplication.translate( "Form", "CAPTSLOG", None, QtGui.QApplication.UnicodeUTF8)) self.Signup.setText(QtGui.QApplication.translate( "Form", "Sign Up", None, QtGui.QApplication.UnicodeUTF8))
def retranslateUi(self, Form): Form.setWindowTitle(QtGui.QApplication.translate("Form", "Form", None, QtGui.QApplication.UnicodeUTF8)) self.username.setText(QtGui.QApplication.translate("Form", "Username :", None, QtGui.QApplication.UnicodeUTF8)) self.password1.setText(QtGui.QApplication.translate("Form", "Password :", None, QtGui.QApplication.UnicodeUTF8)) self.password2.setText(QtGui.QApplication.translate("Form", "Password :", None, QtGui.QApplication.UnicodeUTF8)) self.label.setText(QtGui.QApplication.translate("Form", "Please enter your Username and Password (at least 4 characters)", None, QtGui.QApplication.UnicodeUTF8))
def launch_gui(): global qApp global bitmaskd global browser if IS_WIN: freeze_support() bitmaskd = Process(target=run_bitmaskd) bitmaskd.start() qApp = QApplication([]) try: browser = BrowserWindow(None) except NoAuthToken as e: print('ERROR: ' + e.message) sys.exit(1) browser.setupSysTray() qApp.setQuitOnLastWindowClosed(True) qApp.lastWindowClosed.connect(browser.shutdown) signal.signal( signal.SIGINT, partial(_handle_kill, win=browser)) # Avoid code to get stuck inside c++ loop, returning control # to python land. timer = QtCore.QTimer() timer.timeout.connect(lambda: None) timer.start(500) browser.show() sys.exit(qApp.exec_())
def __init__(self, display=True): self.app = QApplication([]) QWebView.__init__(self) if display: self.show() # show the browser
def runStandalone(): app = QtWidgets.QApplication(sys.argv) panel = brontes_controller.Brontes() panel.show() app.exec_()
def copyToClipboard(self): sortedTasks = sorted([t for t in self.taskStore.tasks if t.index >= 0], key=lambda task: task.priority) if self.sortButton.isChecked(): sortedTasks.reverse() clipboard = QtGui.QApplication.clipboard() text = '\n'.join([str(t) for t in sortedTasks]) clipboard.setText(text)
def _closeRunningInstances(self): '''Check if other instances are already runnign and close them before proceding.''' for widget in QtGui.QApplication.allWidgets(): name = widget.objectName() if type(widget) == type(self): p = widget.parentWidget() while p: if p.parent() and isinstance(p.parent(), QtGui.QStackedWidget): p.parent().removeWidget(p) # THIS ASSUMES NUKE'S QSTACKEDWIDGET HOLDING THIS WIDGET p = None else: p = p.parentWidget()
def inHiero(): '''Return True if this is run from inside of Hiero, else return False''' return 'Hiero' in QtGui.QApplication.applicationName()
def findAndReload(): ''' find MainWindow amongst all Nuke widgets and reload unless widget already has a settings file This is for nuke's onScriptSaveCallback for cases where the widget was first called in a deactivated state (from an unsaved nuke script) and is then saved while the widget is visible. This is also triggered via onScriptLoad to guarntee refresh when a script is loaded. ''' for widget in QtGui.QApplication.allWidgets(): if str(widget) == 'OHUfx ToDoList Widget': if not widget.settingsFile: widget.rebuildTaskWidgets()
def main(): args = _parsed_args() application = QtGui.QApplication(sys.argv) window = Main() if args.input is not None: window.load(args.input) window.show() window.raise_() application.exec_()
def main(): app = QtGui.QApplication(sys.argv) read_formats = ', '.join([str(format).lower() \ for format in QtGui.QImageReader.supportedImageFormats()]) print('Qt4 plugin paths: ' + str(list(app.libraryPaths()))) print('Qt4 image read support: ' + read_formats) print('Qt4 Libraries path: ' + str( QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.LibrariesPath))) ex = MyDialog() app.exec_()
def main(): app = QtGui.QApplication(sys.argv) FBXGui = FBXConvertGUI() FBXGui.show() app.exec_() sys.exit()
def main(): app = QtGui.QApplication(sys.argv) OBJGui = ConversionTypeSelection() OBJGui.show() app.exec_() sys.exit()
def main(): app = QtGui.QApplication(sys.argv) OBJGui = OBJConvertGUI() OBJGui.show() app.exec_() sys.exit()
def run(): appl = QtGui.QApplication(sys.argv) form = MainWindow() form.show() appl.exec_()
def display(self, model): app = QtGui.QApplication.instance() if not app: # create QApplication if it doesnt exist app = QtGui.QApplication(sys.argv) tree = QtGui.QTreeView() tree.setModel(model) tree.show() app.exec_() return tree
def main(): """ Application entry point """ logging.basicConfig(level=logging.DEBUG) # create the application and the main window app = QtGui.QApplication(sys.argv) window = QtGui.QMainWindow() # setup ui ui = example_ui.Ui_MainWindow() ui.setupUi(window) ui.bt_delay_popup.addActions([ ui.actionAction, ui.actionAction_C ]) ui.bt_instant_popup.addActions([ ui.actionAction, ui.actionAction_C ]) ui.bt_menu_button_popup.addActions([ ui.actionAction, ui.actionAction_C ]) window.setWindowTitle("QDarkStyle example") # tabify dock widgets to show bug #6 window.tabifyDockWidget(ui.dockWidget1, ui.dockWidget2) # setup stylesheet app.setStyleSheet(qdarkstyle.load_stylesheet(pyside=True)) # auto quit after 2s when testing on travis-ci if "--travis" in sys.argv: QtCore.QTimer.singleShot(2000, app.exit) # run window.show() app.exec_()
def main(): app = QtGui.QApplication([]) f = open("../darkorange.stylesheet","r") s = f.read() f.close() app.setStyleSheet(s) ui = ConsolePanel() ui.setGeometry(0,0,600,400) ui.show() sys.exit(app.exec_())
def main(): app = QtGui.QApplication([]) f = open(pc.CSSPATH,"r") s = f.read() f.close() app.setStyleSheet(s) ui = QNodePanel() ui.setGeometry(0,0,600,400) ui.show() sys.exit(app.exec_())
def main(): app = QtGui.QApplication([]) #style = QtGui.QStyle() #style = QtGui.QPlastiqueStyle() #app.setStyle(style) ui = ParameterPanel() ui.setGeometry(0,0,400,600) ui.show() p = GEO_locator() ui.displayParameterTemplateGroup(p.parmTemplateGroup()) sys.exit(app.exec_())
def __main__(): app = QtGui.QApplication(sys.argv) ui = ParameterPanelEdit() ui.setGeometry(100, 100, 300, 300) ui.show() sys.exit(app.exec_())
def main(): app = QtGui.QApplication([]) ex = fileBrowserUI() sys.exit(app.exec_())
def main(): app = QtGui.QApplication([]) #style = QtGui.QStyle() #style = QtGui.QPlastiqueStyle() #app.setStyle(style) #f = open("style.css","r") #s = f.read() #f.close() #app.setStyleSheet(s) ui = sRenderManagerUI() sys.exit(app.exec_())
def main(): app = QtGui.QApplication([]) ui = ParameterPanel() f = open(pc.CSSPATH,"r") s = f.read() f.close() app.setStyleSheet(s) ui.setGeometry(0,0,800,800) ui.show() sys.exit(app.exec_())
def main(): app = QtGui.QApplication([]) ui = sRenderServerUI() sys.exit(app.exec_())
def main(): app = QtGui.QApplication([]) ui = sRenderSlaveUI() sys.exit(app.exec_())
def choose(choices, within_qtloop = False, parent = None): if not within_qtloop: app = QApplication(sys.argv) dialog = ChoiceDialog(choices, parent) result = dialog.open() # show() will not get result app.exec_() # dialog.exec_() will call the app.exec_() else: dialog = ChoiceDialog(choices, parent) result = dialog.exec_() # show() will not get result, must using exec_() or error choice = dialog.getChoice() choiceId = dialog.getChoiceId() return (choice, choiceId, result == QDialog.Accepted) # Accepted
def test(): print(choose(['choice a', 'choic b'])) #print(choose(['choice a', 'choic b'])) # run into error, when call this again: RuntimeError: A QApplication instance already exists.
def main(): import sys app = QtGui.QApplication(sys.argv) BarWidget().show() sys.exit(app.exec_())
def launch(): freeze_support() check_app_running() me = singleton.SingleInstance() windows_appusermodelid() app = QtGui.QApplication(sys.argv) QtGui.QApplication.setQuitOnLastWindowClosed(False) if check_settings() == False or is_user_info_invalid() == True: waiting = WaitingWindow() else: main = MainWindow() sys.exit(app.exec_())
def main(): # app = QtGui.QApplication([]) # assign a callback function win = UILayout(get_maya_window()) win.createLayout(elementList) setupElement(win) setupEvent(win) win.show() print 'executing' # win.exec_() return