How to use the qtpy.QtWidgets.QApplication function in QtPy

To help you get started, we’ve selected a few QtPy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github glue-viz / glue / glue / viewers / common / qt / mpl_widget.py View on Github external
def _on_timeout(self):
        buttons = QtWidgets.QApplication.instance().mouseButtons()
        if buttons != Qt.NoButton:
            self._resize_timer.start()
        else:
            self.resize_end.emit()
github SteveDoyle2 / pyNastran / pyNastran / gui / menus / cutting_plane / shear_moment_torque.py View on Github external
def main():
    # kills the program when you hit Cntl+C from the command line
    # doesn't save the current state as presumably there's been an error
    import signal
    signal.signal(signal.SIGINT, signal.SIG_DFL)


    import sys
    # Someone is launching this directly
    # Create the QApplication
    app = QApplication(sys.argv)
    #The Main window

    gpforce = None
    data = {
        'font_size' : 8,
        #'cids' : [0, 1, 2, 3],
        'cids' : [0],
        'plane_color' : (1., 0., 1.), # purple
        'plane_opacity' : 0.9,
        'gpforce' : gpforce,
        #'itime' : 0,
        'word' : 'Static',
        'model_name' : 'main',
    }
    main_window = ShearMomentTorqueWindow(data)
    main_window.show()
github spyder-ide / spyder / spyder / plugins / editor / plugin.py View on Github external
def __get_focus_editorstack(self):
        fwidget = QApplication.focusWidget()
        if isinstance(fwidget, EditorStack):
            return fwidget
        else:
            for editorstack in self.editorstacks:
                if editorstack.isAncestorOf(fwidget):
                    return editorstack
github Ulm-IQO / qudi / tools / config_gui / __main__.py View on Github external
def nodeAdded(self):
        pass

    def nodeRemoved(self):
        pass

    def nodeNameChanged(self):
        pass

if __name__ == "__main__":
    parser = argparse.ArgumentParser(prog='config_gui')
    parser.add_argument('-c', '--config', default=None, help='configuration file')
    args = parser.parse_args()

    app = QtWidgets.QApplication(sys.argv)
    mw = ConfigMainWindow(loadfile=args.config)
    app.exec_()
github uvemas / ViTables / vitables / queries / querydlg.py View on Github external
"""

import logging
import os.path
import vitables.utils

import numpy
from qtpy import QtCore
from qtpy import QtGui
from qtpy import QtWidgets
from qtpy.uic import loadUiType


__docformat__ = 'restructuredtext'

translate = QtWidgets.QApplication.translate

# This method of the PyQt5.uic module allows for dinamically loading user
# interfaces created by QtDesigner. See the PyQt5 Reference Guide for more
# info.
Ui_QueryDialog = \
    loadUiType(os.path.join(os.path.dirname(__file__), 'query_dlg.ui'))[0]

log = logging.getLogger(__name__)


class QueryDlg(QtWidgets.QDialog, Ui_QueryDialog):
    """
    A dialog for filtering `tables.Table` nodes.

    By loading UI files at runtime we can:
github Ulm-IQO / qudi / gui / trayicon.py View on Github external
def __init__(self):
        """Tray icon constructor.
        Adds all the appropriate menus and actions.
        """
        QtWidgets.QSystemTrayIcon.__init__(self)
        self.setIcon(QtWidgets.QApplication.instance().windowIcon())
        self.right_menu = QtWidgets.QMenu('Quit')
        self.left_menu = QtWidgets.QMenu('Manager')
        iconpath = 'artwork/icons/oxygen'
        self.managericon = QtGui.QIcon()
        self.managericon.addFile('{0}/22x22/go-home.png'.format(iconpath), QtCore.QSize(16,16))
        self.exiticon = QtGui.QIcon()
        self.exiticon.addFile('{0}/22x22/application-exit.png'.format(iconpath), QtCore.QSize(16,16))
        self.quitAction = QtWidgets.QAction(self.exiticon, "&Quit", self.right_menu)
        self.managerAction = QtWidgets.QAction(self.managericon, "&Manager", self.left_menu)
        self.left_menu.addAction(self.managerAction)
        self.right_menu.addAction(self.quitAction)
        self.setContextMenu(self.right_menu)
        self.activated.connect(self.click_trap)
github smathot / OpenSesame / openexp / _canvas / _richtext / richtext.py View on Github external
qt_plugin_path = os.path.join(
			os.path.dirname(sys.executable), 'Library', 'plugins')
		if os.path.isdir(qt_plugin_path):
			QCoreApplication.addLibraryPath(
				safe_decode(qt_plugin_path, enc=misc.filesystem_encoding())
			)
		qt_plugin_path = os.path.join(
			os.path.dirname(sys.executable), 'Library', 'lib', 'qt4', 'plugins')
		if os.path.isdir(qt_plugin_path):
			QCoreApplication.addLibraryPath(
				safe_decode(qt_plugin_path, enc=misc.filesystem_encoding())
			)
		# If no instance of QApplication exists, a segmentation fault seems to
		# always occur. So we create one.
		if QCoreApplication.instance() is None:
			app = QApplication([])
		# Register the fonts bundled with OpenSesame
		if font_database is None:
			font_database = QFontDatabase()
			for font in FONTS:
				self._register_font(exp, font)
github mantidproject / mantid / qt / applications / workbench / workbench / app / mainwindow.py View on Github external
def __init__(self):
        QMainWindow.__init__(self)

        qapp = QApplication.instance()
        qapp.setAttribute(Qt.AA_UseHighDpiPixmaps)
        if hasattr(Qt, 'AA_EnableHighDpiScaling'):
            qapp.setAttribute(Qt.AA_EnableHighDpiScaling, True)

        self.setWindowTitle("Mantid Workbench")

        # -- instance attributes --
        self.window_size = None
        self.window_position = None
        self.maximized_flag = None
        # widgets
        self.messagedisplay = None
        self.ipythonconsole = None
        self.workspacewidget = None
        self.editor = None
        self.algorithm_selector = None
github spyder-ide / spyder / spyder / widgets / mixins.py View on Github external
def mouseMoveEvent(self, event):
        """Show Pointing Hand Cursor on error messages"""
        text = self.get_line_at(event.pos())
        if get_error_match(text):
            if not self.__cursor_changed:
                QApplication.setOverrideCursor(QCursor(Qt.PointingHandCursor))
                self.__cursor_changed = True
            event.accept()
            return
        if self.__cursor_changed:
            QApplication.restoreOverrideCursor()
            self.__cursor_changed = False
        self.QT_CLASS.mouseMoveEvent(self, event)
github smathot / OpenSesame / libqtopensesame / console / _ipython_console.py View on Github external
"""
		desc:
			Sets the theme, based on the QProgEdit settings.
		"""

		from QProgEdit import QColorScheme
		if not hasattr(QColorScheme, cfg.qProgEditColorScheme):
			oslogger.error(u'failed to set debug-output colorscheme')
			return u''
		cs = getattr(QColorScheme, cfg.qProgEditColorScheme)
		if not self.validTheme(cs):
			oslogger.error(u'invalid debug-output colorscheme')
			return u''
		# We need to process events first, otherwise the style changes don't
		# take for an unclear reason.
		QtWidgets.QApplication.processEvents()
		self.control._highlighter.set_style(PygmentsStyleFactory(cs))
		self.qss = u'''QPlainTextEdit, QTextEdit {
				background-color: %(Background)s;
				color: %(Default)s;
			}
			.in-prompt { color: %(Prompt in)s; }
			.in-prompt-number { font-weight: bold; }
			.out-prompt { color: %(Prompt out)s; }
			.out-prompt-number { font-weight: bold; }
			''' % cs
		self.control.style_sheet = self.qss
		self.control._control.setFont(
			QtGui.QFont(
				cfg.qProgEditFontFamily,
				cfg.qProgEditFontSize
			)