Python qtpy.QtWidgets.QApplication() Examples
The following are 30
code examples of qtpy.QtWidgets.QApplication().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
qtpy.QtWidgets
, or try the search function
.
![](https://www.programcreek.com/common/static/images/search.png)
Example #1
Source File: mainwindow.py From tellurium with Apache License 2.0 | 6 votes |
def get_focus_widget_properties(self): """Get properties of focus widget Returns tuple (widget, properties) where properties is a tuple of booleans: (is_console, not_readonly, readwrite_editor)""" widget = QApplication.focusWidget() from spyder.widgets.shell import ShellBaseWidget from spyder.widgets.editor import TextEditBaseWidget from spyder.widgets.ipythonconsole import ControlWidget # if focused widget isn't valid try the last focused if not isinstance(widget, (ShellBaseWidget, TextEditBaseWidget, ControlWidget)): widget = self.previous_focused_widget textedit_properties = None if isinstance(widget, (ShellBaseWidget, TextEditBaseWidget, ControlWidget)): console = isinstance(widget, (ShellBaseWidget, ControlWidget)) not_readonly = not widget.isReadOnly() readwrite_editor = not_readonly and not console textedit_properties = (console, not_readonly, readwrite_editor) return widget, textedit_properties
Example #2
Source File: eventEngine.py From vnpy_crypto with MIT License | 6 votes |
def test(): """测试函数""" import sys from datetime import datetime from qtpy import QtWidgets,QtCore def simpletest(event): print( u'处理每秒触发的计时器事件:%s' % str(datetime.now())) app = QtWidgets.QApplication([]) eventEngine = EventEngine2() #ee.register(EVENT_TIMER, simpletest) eventEngine.registerGeneralHandler(simpletest) eventEngine.start() app.exec_() # 直接运行脚本可以进行测试
Example #3
Source File: mainwindow.py From tellurium with Apache License 2.0 | 6 votes |
def get_focus_widget_properties(self): """Get properties of focus widget Returns tuple (widget, properties) where properties is a tuple of booleans: (is_console, not_readonly, readwrite_editor)""" widget = QApplication.focusWidget() from spyder.widgets.shell import ShellBaseWidget from spyder.widgets.editor import TextEditBaseWidget from spyder.widgets.ipythonconsole import ControlWidget # if focused widget isn't valid try the last focused if not isinstance(widget, (ShellBaseWidget, TextEditBaseWidget, ControlWidget)): widget = self.previous_focused_widget textedit_properties = None if isinstance(widget, (ShellBaseWidget, TextEditBaseWidget, ControlWidget)): console = isinstance(widget, (ShellBaseWidget, ControlWidget)) not_readonly = not widget.isReadOnly() readwrite_editor = not_readonly and not console textedit_properties = (console, not_readonly, readwrite_editor) return widget, textedit_properties
Example #4
Source File: misc.py From argos with GNU General Public License v3.0 | 6 votes |
def initQApplication(): """ Initializes the QtWidgets.QApplication instance. Creates one if it doesn't exist. Sets Argos specific attributes, such as the OrganizationName, so that the application persistent settings are read/written to the correct settings file/winreg. It is therefore important to call this function at startup. The ArgosApplication constructor does this. Returns the application. """ # PyQtGraph recommends raster graphics system for OS-X. if 'darwin' in sys.platform: graphicsSystem = "raster" # raster, native or opengl os.environ.setdefault('QT_GRAPHICSSYSTEM', graphicsSystem) logger.info("Setting QT_GRAPHICSSYSTEM to: {}".format(graphicsSystem)) app = QtWidgets.QApplication(sys.argv) initArgosApplicationSettings(app) return app
Example #5
Source File: misc.py From argos with GNU General Public License v3.0 | 6 votes |
def initArgosApplicationSettings(app): # TODO: this is Argos specific. Move somewhere else. """ Sets Argos specific attributes, such as the OrganizationName, so that the application persistent settings are read/written to the correct settings file/winreg. It is therefore important to call this function at startup. The ArgosApplication constructor does this. """ assert app, \ "app undefined. Call QtWidgets.QApplication.instance() or QtCor.QApplication.instance() first." logger.debug("Setting Argos QApplication settings.") app.setApplicationName(info.REPO_NAME) app.setApplicationVersion(info.VERSION) app.setOrganizationName(info.ORGANIZATION_NAME) app.setOrganizationDomain(info.ORGANIZATION_DOMAIN) ###################### # Exception Handling # ######################
Example #6
Source File: test_00_console_widget.py From qtconsole with BSD 3-Clause "New" or "Revised" License | 5 votes |
def tearDownClass(cls): """ Exit the application. """ QtWidgets.QApplication.quit()
Example #7
Source File: mainwindow.py From tellurium with Apache License 2.0 | 5 votes |
def get_focus_python_shell(): """Extract and return Python shell from widget Return None if *widget* is not a Python shell (e.g. IPython kernel)""" widget = QApplication.focusWidget() from spyder.widgets.shell import PythonShellWidget from spyder.widgets.externalshell.pythonshell import ExternalPythonShell if isinstance(widget, PythonShellWidget): return widget elif isinstance(widget, ExternalPythonShell): return widget.shell #============================================================================== # Main Window #==============================================================================
Example #8
Source File: mainwindow.py From tellurium with Apache License 2.0 | 5 votes |
def set_splash(self, message): """Set splash message""" if self.splash is None: return if message: self.debug_print(message) self.splash.show() self.splash.showMessage(message, Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute, QColor(Qt.black)) QApplication.processEvents()
Example #9
Source File: mainwindow.py From tellurium with Apache License 2.0 | 5 votes |
def change_last_focused_widget(self, old, now): """To keep track of to the last focused widget""" if (now is None and QApplication.activeWindow() is not None): QApplication.activeWindow().setFocus() self.last_focused_widget = QApplication.focusWidget() elif now is not None: self.last_focused_widget = now self.previous_focused_widget = old
Example #10
Source File: mainwindow.py From tellurium with Apache License 2.0 | 5 votes |
def close_current_dockwidget(self): widget = QApplication.focusWidget() for plugin in self.widgetlist: if plugin.isAncestorOf(widget): plugin.dockwidget.hide() break
Example #11
Source File: mainwindow.py From tellurium with Apache License 2.0 | 5 votes |
def maximize_dockwidget(self, restore=False): """Shortcut: Ctrl+Alt+Shift+M First call: maximize current dockwidget Second call (or restore=True): restore original window layout""" if self.state_before_maximizing is None: if restore: return # No plugin is currently maximized: maximizing focus plugin self.state_before_maximizing = self.saveState() focus_widget = QApplication.focusWidget() for plugin in self.widgetlist: plugin.dockwidget.hide() if plugin.isAncestorOf(focus_widget): self.last_plugin = plugin self.last_plugin.dockwidget.toggleViewAction().setDisabled(True) self.setCentralWidget(self.last_plugin) self.last_plugin.ismaximized = True # Workaround to solve an issue with editor's outline explorer: # (otherwise the whole plugin is hidden and so is the outline explorer # and the latter won't be refreshed if not visible) self.last_plugin.show() self.last_plugin.visibility_changed(True) if self.last_plugin is self.editor: # Automatically show the outline if the editor was maximized: self.addDockWidget(Qt.RightDockWidgetArea, self.outlineexplorer.dockwidget) self.outlineexplorer.dockwidget.show() else: # Restore original layout (before maximizing current dockwidget) self.last_plugin.dockwidget.setWidget(self.last_plugin) self.last_plugin.dockwidget.toggleViewAction().setEnabled(True) self.setCentralWidget(None) self.last_plugin.ismaximized = False self.restoreState(self.state_before_maximizing) self.state_before_maximizing = None self.last_plugin.get_focus_widget().setFocus() self.__update_maximize_action()
Example #12
Source File: mainwindow.py From tellurium with Apache License 2.0 | 5 votes |
def apply_settings(self): """Apply settings changed in 'Preferences' dialog box""" qapp = QApplication.instance() # Set 'gtk+' as the default theme in Gtk-based desktops # Fixes Issue 2036 if is_gtk_desktop() and ('GTK+' in QStyleFactory.keys()): try: qapp.setStyle('gtk+') except: pass else: style_name = CONF.get('main', 'windows_style', self.default_style) style = QStyleFactory.create(style_name) style.setProperty('name', style_name) qapp.setStyle(style) default = self.DOCKOPTIONS if CONF.get('main', 'vertical_tabs'): default = default|QMainWindow.VerticalTabs if CONF.get('main', 'animated_docks'): default = default|QMainWindow.AnimatedDocks self.setDockOptions(default) self.apply_panes_settings() self.apply_statusbar_settings() if CONF.get('main', 'use_custom_cursor_blinking'): qapp.setCursorFlashTime(CONF.get('main', 'custom_cursor_blinking')) else: qapp.setCursorFlashTime(self.CURSORBLINK_OSDEFAULT)
Example #13
Source File: __main__.py From mnelab with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _run(): app_name = "MNELAB" if sys.platform.startswith("darwin"): try: # set bundle name on macOS (app name shown in the menu bar) from Foundation import NSBundle except ImportError: pass else: bundle = NSBundle.mainBundle() if bundle: info = (bundle.localizedInfoDictionary() or bundle.infoDictionary()) if info: info["CFBundleName"] = app_name matplotlib.use("Qt5Agg") app = QApplication(sys.argv) app.setApplicationName(app_name) app.setOrganizationName("cbrnr") if sys.platform.startswith("darwin"): app.setAttribute(Qt.AA_DontShowIconsInMenus, True) app.setAttribute(Qt.AA_UseHighDpiPixmaps) model = Model() model.view = MainWindow(model) if len(sys.argv) > 1: # open files from command line arguments for f in sys.argv[1:]: model.load(f) model.view.show() sys.exit(app.exec_())
Example #14
Source File: qtconsoleapp.py From qtconsole with BSD 3-Clause "New" or "Revised" License | 5 votes |
def init_qt_app(self): # separate from qt_elements, because it must run first self.app = QtWidgets.QApplication(['jupyter-qtconsole']) self.app.setApplicationName('jupyter-qtconsole')
Example #15
Source File: qtconsoleapp.py From qtconsole with BSD 3-Clause "New" or "Revised" License | 5 votes |
def init_qt_elements(self): # Create the widget. base_path = os.path.abspath(os.path.dirname(__file__)) icon_path = os.path.join(base_path, 'resources', 'icon', 'JupyterConsole.svg') self.app.icon = QtGui.QIcon(icon_path) QtWidgets.QApplication.setWindowIcon(self.app.icon) ip = self.ip local_kernel = (not self.existing) or is_local_ip(ip) self.widget = self.widget_factory(config=self.config, local_kernel=local_kernel) self.init_colors(self.widget) self.widget._existing = self.existing self.widget._may_close = not self.existing self.widget._confirm_exit = self.confirm_exit self.widget._display_banner = self.display_banner self.widget.kernel_manager = self.kernel_manager self.widget.kernel_client = self.kernel_client self.window = MainWindow(self.app, confirm_exit=self.confirm_exit, new_frontend_factory=self.new_frontend_master, slave_frontend_factory=self.new_frontend_slave, connection_frontend_factory=self.new_frontend_connection, ) self.window.log = self.log self.window.add_tab_with_frontend(self.widget) self.window.init_menu_bar() # Ignore on OSX, where there is always a menu bar if sys.platform != 'darwin' and self.hide_menubar: self.window.menuBar().setVisible(False) self.window.setWindowTitle('Jupyter QtConsole')
Example #16
Source File: qtconsoleapp.py From qtconsole with BSD 3-Clause "New" or "Revised" License | 5 votes |
def init_signal(self): """allow clean shutdown on sigint""" signal.signal(signal.SIGINT, lambda sig, frame: self.exit(-2)) # need a timer, so that QApplication doesn't block until a real # Qt event fires (can require mouse movement) # timer trick from http://stackoverflow.com/q/4938723/938949 timer = QtCore.QTimer() # Let the interpreter run each 200 ms: timer.timeout.connect(lambda: None) timer.start(200) # hold onto ref, so the timer doesn't get cleaned up self._sigint_timer = timer
Example #17
Source File: test_00_console_widget.py From qtconsole with BSD 3-Clause "New" or "Revised" License | 5 votes |
def setUpClass(cls): """ Create the application for the test case. """ cls._app = QtWidgets.QApplication.instance() if cls._app is None: cls._app = QtWidgets.QApplication([]) cls._app.setQuitOnLastWindowClosed(False)
Example #18
Source File: mainwindow.py From tellurium with Apache License 2.0 | 5 votes |
def apply_settings(self): """Apply settings changed in 'Preferences' dialog box""" qapp = QApplication.instance() # Set 'gtk+' as the default theme in Gtk-based desktops # Fixes Issue 2036 if is_gtk_desktop() and ('GTK+' in QStyleFactory.keys()): try: qapp.setStyle('gtk+') except: pass else: style_name = CONF.get('main', 'windows_style', self.default_style) style = QStyleFactory.create(style_name) if style is not None: style.setProperty('name', style_name) qapp.setStyle(style) default = self.DOCKOPTIONS if CONF.get('main', 'vertical_tabs'): default = default|QMainWindow.VerticalTabs if CONF.get('main', 'animated_docks'): default = default|QMainWindow.AnimatedDocks self.setDockOptions(default) self.apply_panes_settings() self.apply_statusbar_settings() if CONF.get('main', 'use_custom_cursor_blinking'): qapp.setCursorFlashTime(CONF.get('main', 'custom_cursor_blinking')) else: qapp.setCursorFlashTime(self.CURSORBLINK_OSDEFAULT)
Example #19
Source File: test_jupyter_widget.py From qtconsole with BSD 3-Clause "New" or "Revised" License | 5 votes |
def setUpClass(cls): """ Create the application for the test case. """ cls._app = QtWidgets.QApplication.instance() if cls._app is None: cls._app = QtWidgets.QApplication([]) cls._app.setQuitOnLastWindowClosed(False)
Example #20
Source File: test_jupyter_widget.py From qtconsole with BSD 3-Clause "New" or "Revised" License | 5 votes |
def tearDownClass(cls): """ Exit the application. """ QtWidgets.QApplication.quit()
Example #21
Source File: test_frontend_widget.py From qtconsole with BSD 3-Clause "New" or "Revised" License | 5 votes |
def setUpClass(cls): """ Create the application for the test case. """ cls._app = QtWidgets.QApplication.instance() if cls._app is None: cls._app = QtWidgets.QApplication([]) cls._app.setQuitOnLastWindowClosed(False)
Example #22
Source File: test_frontend_widget.py From qtconsole with BSD 3-Clause "New" or "Revised" License | 5 votes |
def tearDownClass(cls): """ Exit the application. """ QtWidgets.QApplication.quit()
Example #23
Source File: test_completion_widget.py From qtconsole with BSD 3-Clause "New" or "Revised" License | 5 votes |
def setUpClass(cls): """ Create the application for the test case. """ cls._app = QtWidgets.QApplication.instance() if cls._app is None: cls._app = QtWidgets.QApplication([]) cls._app.setQuitOnLastWindowClosed(False)
Example #24
Source File: test_kill_ring.py From qtconsole with BSD 3-Clause "New" or "Revised" License | 5 votes |
def setUpClass(cls): """ Create the application for the test case. """ cls._app = QtWidgets.QApplication.instance() if cls._app is None: cls._app = QtWidgets.QApplication([]) cls._app.setQuitOnLastWindowClosed(False)
Example #25
Source File: test_kill_ring.py From qtconsole with BSD 3-Clause "New" or "Revised" License | 5 votes |
def tearDownClass(cls): """ Exit the application. """ QtWidgets.QApplication.quit()
Example #26
Source File: test_patch_qcombobox.py From qtpy with MIT License | 5 votes |
def get_qapp(icon_path=None): qapp = QtWidgets.QApplication.instance() if qapp is None: qapp = QtWidgets.QApplication(['']) return qapp
Example #27
Source File: test_uic.py From qtpy with MIT License | 5 votes |
def get_qapp(icon_path=None): """ Helper function to return a QApplication instance """ qapp = QtWidgets.QApplication.instance() if qapp is None: qapp = QtWidgets.QApplication(['']) return qapp
Example #28
Source File: app.py From pydiq with MIT License | 5 votes |
def run_app(path): if len(sys.argv) < 2: path = "." else: path = sys.argv[1] app = QtWidgets.QApplication(sys.argv) QtCore.QCoreApplication.setApplicationName("pydiq") QtCore.QCoreApplication.setOrganizationName("Jan Pipek") viewer = Viewer(path) viewer.show() sys.exit(app.exec_())
Example #29
Source File: icon_browser.py From qtawesome with MIT License | 5 votes |
def _copyIconText(self): """ Copy the name of the currently selected icon to the clipboard. """ indexes = self._listView.selectedIndexes() if not indexes: return clipboard = QtWidgets.QApplication.instance().clipboard() clipboard.setText(indexes[0].data())
Example #30
Source File: test_uic.py From vnpy_crypto with MIT License | 5 votes |
def get_qapp(icon_path=None): """ Helper function to return a QApplication instance """ qapp = QtWidgets.QApplication.instance() if qapp is None: qapp = QtWidgets.QApplication(['']) return qapp