Python PyQt5.QtWidgets.QMainWindow() Examples

The following are 30 code examples for showing how to use PyQt5.QtWidgets.QMainWindow(). These examples are extracted from open source projects. 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 check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module PyQt5.QtWidgets , or try the search function .

Example 1
Project: Python-GUI   Author: arpitj07   File: Project.py    License: MIT License 6 votes vote down vote up
def __init__(self):
        self.evalDialog = QtWidgets.QMainWindow()
        self.new_screen = Form()                           
        self.new_screen.setupUi(self.evalDialog)
        
        self.EvaluateWindow= QtWidgets.QMainWindow()
        self.eval_screen= Box()
        self.eval_screen.setupUi(self.EvaluateWindow)

        self.openDialog = QtWidgets.QMainWindow()
        self.open_screen= Ui_OpenWindow()
        self.open_screen.setupUi(self.openDialog)

        self.scoreDialog = QtWidgets.QMainWindow()
        self.score_screen= Ui_ScoreWindow()
        self.score_screen.setupUi(self.scoreDialog) 
Example 2
Project: attack_monitor   Author: yarox24   File: gui_code.py    License: GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, app, SHOW_MQ, TRAY_MQ, ALARM_MQ, MALWARE_MQ, EXCEPTION_RULES):
        QtWidgets.QMainWindow.__init__(self)
        self.app = app
        self.some_widget = QtWidgets.QWidget()
        screen_resolution = self.app.desktop().screenGeometry()
        self.screen_width, self.screen_height = screen_resolution.width(), screen_resolution.height()
        self.dialog_controls = dict()
        self.SHOW_MQ = SHOW_MQ
        self.TRAY_MQ = TRAY_MQ
        self.ALARM_MQ = ALARM_MQ
        self.MALWARE_MQ = MALWARE_MQ
        self.EXCEPTION_RULES = EXCEPTION_RULES

        # GET GUI CONFIG
        self.cc = configer.Config()
        gui_options = self.cc.get_config_single_category(configer.MAIN_CONFIG, "gui")
        if gui_options['learning_mode']:
            self.LEARNING_MODE = True
        else:
            self.LEARNING_MODE = False 
Example 3
Project: SubCrawl   Author: lukaabra   File: bindings.py    License: MIT License 6 votes vote down vote up
def __init__(self):
        Ui_SubCrawl.__init__(self)
        QtWidgets.QMainWindow.__init__(self)
        self.setupUi(self)

        # TODO: Implement enabling and disabling of buttons depending on the confirmation of selection
        self.selection_confirmed = False
        self.program_dir = os.getcwd()
        self.total_files = 0

        self.subtitle_preference = SubtitlePreference()
        self.interactor = _DBInteractor(self.program_dir)
        self.interactor.check_if_entries_exist()
        self._populate_table()

        self.subtitle_downloader = SubtitleDownloader(self.subtitle_preference, self.PromptLabel,
                                                      self.ProgressBar, self.interactor) 
Example 4
Project: scudcloud   Author: raelgc   File: scudcloud.py    License: MIT License 6 votes vote down vote up
def eventFilter(self, obj, event):
        if event.type() == QtCore.QEvent.ActivationChange and self.isActiveWindow():
            self.focusInEvent(event)
        if event.type() == QtCore.QEvent.KeyPress:
            # Ctrl + <n>
            modifiers = QtWidgets.QApplication.keyboardModifiers()
            if modifiers == QtCore.Qt.ControlModifier:
                if event.key() == QtCore.Qt.Key_1:   self.leftPane.click(0)
                elif event.key() == QtCore.Qt.Key_2: self.leftPane.click(1)
                elif event.key() == QtCore.Qt.Key_3: self.leftPane.click(2)
                elif event.key() == QtCore.Qt.Key_4: self.leftPane.click(3)
                elif event.key() == QtCore.Qt.Key_5: self.leftPane.click(4)
                elif event.key() == QtCore.Qt.Key_6: self.leftPane.click(5)
                elif event.key() == QtCore.Qt.Key_7: self.leftPane.click(6)
                elif event.key() == QtCore.Qt.Key_8: self.leftPane.click(7)
                elif event.key() == QtCore.Qt.Key_9: self.leftPane.click(8)
                # Ctrl + Tab
                elif event.key() == QtCore.Qt.Key_Tab: self.leftPane.clickNext(1)
            # Ctrl + BackTab
            if (modifiers & QtCore.Qt.ControlModifier) and (modifiers & QtCore.Qt.ShiftModifier):
                if event.key() == QtCore.Qt.Key_Backtab: self.leftPane.clickNext(-1)
            # Ctrl + Shift + <key>
            if (modifiers & QtCore.Qt.ShiftModifier) and (modifiers & QtCore.Qt.ShiftModifier):
                if event.key() == QtCore.Qt.Key_V: self.current().createSnippet()
        return QtWidgets.QMainWindow.eventFilter(self, obj, event); 
Example 5
Project: pychemqt   Author: jjgomera   File: config.py    License: GNU General Public License v3.0 6 votes vote down vote up
def setMainWindowConfig(config=None):
    """Set config as current project"""
    global currentConfig
    if config:
        currentConfig = config
        return
    else:
        widget = QtWidgets.QApplication.activeWindow()
        if isinstance(widget, QtWidgets.QMainWindow) and \
           widget.__class__.__name__ == "UI_pychemqt":
            currentConfig = widget.currentConfig
        else:
            lista = QtWidgets.QApplication.topLevelWidgets()
            for widget in lista:
                if isinstance(widget, QtWidgets.QMainWindow) and \
                   widget.__class__.__name__ == "UI_pychemqt":
                    currentConfig = widget.currentConfig
                    break 
Example 6
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_1116.py    License: MIT License 6 votes vote down vote up
def qui_menubar(self, menu_list_str):
        if not isinstance(self, QtWidgets.QMainWindow):
            print("Warning: Only QMainWindow can have menu bar.")
            return
        menubar = self.menuBar()
        create_opt_list = [ x.strip() for x in menu_list_str.split('|') ]
        for each_creation in create_opt_list:
            ui_info = [ x.strip() for x in each_creation.split(';') ]
            menu_name = ui_info[0]
            menu_title = ''
            if len(ui_info) > 1:
                menu_title = ui_info[1]
            if menu_name not in self.uiList.keys():
                self.uiList[menu_name] = QtWidgets.QMenu(menu_title)
            menubar.addMenu(self.uiList[menu_name])
    
    #=======================================
    # ui creation functions
    #======================================= 
Example 7
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_1020.py    License: MIT License 6 votes vote down vote up
def qui_menubar(self, menu_list_str):
        if not isinstance(self, QtWidgets.QMainWindow):
            print("Warning: Only QMainWindow can have menu bar.")
            return
        menubar = self.menuBar()
        create_opt_list = [ x.strip() for x in menu_list_str.split('|') ]
        for each_creation in create_opt_list:
            ui_info = [ x.strip() for x in each_creation.split(';') ]
            menu_name = ui_info[0]
            menu_title = ''
            if len(ui_info) > 1:
                menu_title = ui_info[1]
            if menu_name not in self.uiList.keys():
                self.uiList[menu_name] = QtWidgets.QMenu(menu_title)
            menubar.addMenu(self.uiList[menu_name])
    # compatible hold function 
Example 8
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_1115.py    License: MIT License 6 votes vote down vote up
def qui_menubar(self, menu_list_str):
        if not isinstance(self, QtWidgets.QMainWindow):
            print("Warning: Only QMainWindow can have menu bar.")
            return
        menubar = self.menuBar()
        create_opt_list = [ x.strip() for x in menu_list_str.split('|') ]
        for each_creation in create_opt_list:
            ui_info = [ x.strip() for x in each_creation.split(';') ]
            menu_name = ui_info[0]
            menu_title = ''
            if len(ui_info) > 1:
                menu_title = ui_info[1]
            if menu_name not in self.uiList.keys():
                self.uiList[menu_name] = QtWidgets.QMenu(menu_title)
            menubar.addMenu(self.uiList[menu_name])
    
    #=======================================
    # ui creation functions
    #======================================= 
Example 9
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_1112.py    License: MIT License 6 votes vote down vote up
def qui_menubar(self, menu_list_str):
        if not isinstance(self, QtWidgets.QMainWindow):
            print("Warning: Only QMainWindow can have menu bar.")
            return
        menubar = self.menuBar()
        create_opt_list = [ x.strip() for x in menu_list_str.split('|') ]
        for each_creation in create_opt_list:
            ui_info = [ x.strip() for x in each_creation.split(';') ]
            menu_name = ui_info[0]
            menu_title = ''
            if len(ui_info) > 1:
                menu_title = ui_info[1]
            if menu_name not in self.uiList.keys():
                self.uiList[menu_name] = QtWidgets.QMenu(menu_title)
            menubar.addMenu(self.uiList[menu_name])
    
    #=======================================
    # ui creation functions
    #======================================= 
Example 10
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_1100.py    License: MIT License 6 votes vote down vote up
def qui_menubar(self, menu_list_str):
        if not isinstance(self, QtWidgets.QMainWindow):
            print("Warning: Only QMainWindow can have menu bar.")
            return
        menubar = self.menuBar()
        create_opt_list = [ x.strip() for x in menu_list_str.split('|') ]
        for each_creation in create_opt_list:
            ui_info = [ x.strip() for x in each_creation.split(';') ]
            menu_name = ui_info[0]
            menu_title = ''
            if len(ui_info) > 1:
                menu_title = ui_info[1]
            if menu_name not in self.uiList.keys():
                self.uiList[menu_name] = QtWidgets.QMenu(menu_title)
            menubar.addMenu(self.uiList[menu_name])
    
    #=======================================
    # ui creation functions
    #======================================= 
Example 11
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_1110.py    License: MIT License 6 votes vote down vote up
def qui_menubar(self, menu_list_str):
        if not isinstance(self, QtWidgets.QMainWindow):
            print("Warning: Only QMainWindow can have menu bar.")
            return
        menubar = self.menuBar()
        create_opt_list = [ x.strip() for x in menu_list_str.split('|') ]
        for each_creation in create_opt_list:
            ui_info = [ x.strip() for x in each_creation.split(';') ]
            menu_name = ui_info[0]
            menu_title = ''
            if len(ui_info) > 1:
                menu_title = ui_info[1]
            if menu_name not in self.uiList.keys():
                self.uiList[menu_name] = QtWidgets.QMenu(menu_title)
            menubar.addMenu(self.uiList[menu_name])
    
    #=======================================
    # ui creation functions
    #======================================= 
Example 12
Project: spimagine   Author: maweigert   File: imageprocessor_view.py    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def __init__(self, ):
        super(QtWidgets.QMainWindow,self).__init__()

        self.resize(300, 200)
        self.setWindowTitle('Test')

        foo  = ImageProcessorListView([
            imageprocessor.BlurProcessor(),
            imageprocessor.FFTProcessor()
        ])

        
        foo.add_image_processor(imageprocessor.BlurProcessor())


        def myfunc(data,para=1.):
            print("myfunc with para", para)
            return data*para

        imp = imageprocessor.FuncProcessor(myfunc,"myfunc",para=.1)
        foo.add_image_processor(imp)

        
        self.setCentralWidget(foo)
        self.setStyleSheet("background-color:black;") 
Example 13
Project: multibootusb   Author: mbusb   File: imager.py    License: GNU General Public License v2.0 5 votes vote down vote up
def __init__(self):
        QtWidgets.QMainWindow.__init__(self)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self) 
Example 14
Project: multibootusb   Author: mbusb   File: qemu.py    License: GNU General Public License v2.0 5 votes vote down vote up
def __init__(self):
        QtWidgets.QMainWindow.__init__(self)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self) 
Example 15
Project: BreezeStyleSheets   Author: Alexhuszagh   File: native.py    License: MIT License 5 votes vote down vote up
def main():
    """
    Application entry point
    """
    logging.basicConfig(level=logging.DEBUG)
    # create the application and the main window
    app = QtWidgets.QApplication(sys.argv)
    #app.setStyle(QtWidgets.QStyleFactory.create("fusion"))
    window = QtWidgets.QMainWindow()

    # setup ui
    ui = example.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("Native example")

    # tabify dock widgets to show bug #6
    window.tabifyDockWidget(ui.dockWidget1, ui.dockWidget2)

    # 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_() 
Example 16
Project: Python_Master_Courses   Author: makelove   File: pyqt5_1.py    License: GNU General Public License v3.0 5 votes vote down vote up
def myHello(self):
        print('call received')
        return 'hello, Python'

# class MainWindow(QMainWindow): 
Example 17
Project: dottorrent-gui   Author: kz26   File: gui.py    License: GNU General Public License v3.0 5 votes vote down vote up
def main():
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    ui = DottorrentGUI()
    ui.setupUi(MainWindow)

    MainWindow.setWindowTitle(PROGRAM_NAME_VERSION)

    ui.loadSettings()
    ui.clipboard = app.clipboard
    app.aboutToQuit.connect(lambda: ui.saveSettings())
    MainWindow.show()
    sys.exit(app.exec_()) 
Example 18
Project: Writer-Tutorial   Author: goldsborough   File: part-1.py    License: MIT License 5 votes vote down vote up
def __init__(self, parent = None):
        QtWidgets.QMainWindow.__init__(self,parent)

        self.filename = ""

        self.initUI() 
Example 19
Project: Writer-Tutorial   Author: goldsborough   File: part-2.py    License: MIT License 5 votes vote down vote up
def __init__(self, parent = None):
        QtWidgets.QMainWindow.__init__(self,parent)

        self.filename = ""

        self.initUI() 
Example 20
Project: Writer-Tutorial   Author: goldsborough   File: part-3.py    License: MIT License 5 votes vote down vote up
def __init__(self,parent=None):
        QtWidgets.QMainWindow.__init__(self,parent)

        self.filename = ""

        self.initUI() 
Example 21
Project: Writer-Tutorial   Author: goldsborough   File: part-4.py    License: MIT License 5 votes vote down vote up
def __init__(self,parent=None):
        QtWidgets.QMainWindow.__init__(self,parent)

        self.filename = ""

        self.changesSaved = True

        self.initUI() 
Example 22
Project: PyQt5_stylesheets   Author: RedFalsh   File: example_pyqt5.py    License: Apache License 2.0 5 votes vote down vote up
def main():
    """
    Application entry point
    """
    logging.basicConfig(level=logging.DEBUG)
    # create the application and the main window
    app = QtWidgets.QApplication(sys.argv)
    window = QtWidgets.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(PyQt5_stylesheets.load_stylesheet_pyqt5(style="style_black"))

    # 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_() 
Example 23
Project: kite   Author: pyrocko   File: talpa.py    License: GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        filename = kwargs.pop('filename', None)
        QtWidgets.QMainWindow.__init__(self, *args, **kwargs)
        loadUi(get_resource('talpa.ui'), baseinstance=self)
        self.sandbox = SandboxModel.empty()

        self.log = SceneLog(self, self.sandbox)

        self.actionSaveModel.triggered.connect(
            self.onSaveModel)
        self.actionLoadModel.triggered.connect(
            self.loadModel)
        self.actionExportKiteScene.triggered.connect(
            self.onExportScene)
        self.actionChangeExtent.triggered.connect(
            self.extentDialog)
        self.actionChangeLos.triggered.connect(
            self.losDialog)
        self.actionLoadReferenceScene.triggered.connect(
            self.onLoadReferenceScene)

        self.actionConfiguration.triggered.connect(
            self.configDialog)

        self.actionHelp.triggered.connect(
            lambda: QtGui.QDesktopServices.openUrl('https://pyrocko.org'))
        self.actionAbout_Talpa.triggered.connect(
            self.aboutDialog().show)
        self.actionLog.triggered.connect(
            self.log.show)

        self.sandbox.sigModelChanged.connect(
            self.createMisfitWindow)

        if filename is not None:
            self.loadModel(filename)
        self.createView(self.sandbox) 
Example 24
Project: kite   Author: pyrocko   File: talpa.py    License: GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, sandbox, *args, **kwargs):
        QtWidgets.QMainWindow.__init__(self, *args, **kwargs)
        loadUi(get_resource('window_reference.ui'), self)

        self.move(
            self.parent().window().mapToGlobal(
                self.parent().window().rect().center()) -
            self.mapToGlobal(self.rect().center()))

        self.sandbox = sandbox

        self.actionOptimizeSource.triggered.connect(
            self.sandbox.optimizeSource)

        self.createView(self.sandbox) 
Example 25
Project: grap   Author: AirbusCyber   File: QtShim.py    License: MIT License 5 votes vote down vote up
def get_QMainWindow():
    """QMainWindow getter."""

    try:
        import PySide.QtGui as QtGui
        return QtGui.QMainWindow
    except ImportError:
        import PyQt5.QtWidgets as QtWidgets
        return QtWidgets.QMainWindow 
Example 26
def __init__(self, URI):
        QtWidgets.QMainWindow.__init__(self)

        self.resize(700, 500)
        self.setWindowTitle('Multi-ranger point cloud')

        self.canvas = Canvas(self.updateHover)
        self.canvas.create_native()
        self.canvas.native.setParent(self)

        self.setCentralWidget(self.canvas.native)

        cflib.crtp.init_drivers(enable_debug_driver=False)
        self.cf = Crazyflie(ro_cache=None, rw_cache='cache')

        # Connect callbacks from the Crazyflie API
        self.cf.connected.add_callback(self.connected)
        self.cf.disconnected.add_callback(self.disconnected)

        # Connect to the Crazyflie
        self.cf.open_link(URI)

        self.hover = {'x': 0.0, 'y': 0.0, 'z': 0.0, 'yaw': 0.0, 'height': 0.3}

        self.hoverTimer = QtCore.QTimer()
        self.hoverTimer.timeout.connect(self.sendHoverCommand)
        self.hoverTimer.setInterval(100)
        self.hoverTimer.start() 
Example 27
Project: antenna-array-analysis   Author: rookiepeng   File: arrayanalysis.py    License: GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
        super().__init__()
        super(QtWidgets.QMainWindow, self).__init__()

        """Constants"""
        self.window_list = ['Square', 'Chebyshev', 'Taylor', 'Hamming', 'Hann']
        self.plot_list = ['3D (Az-El-Amp)', '2D Cartesian', '2D Polar',
                          'Array layout']
        self.array_config = dict()
        self.fix_azimuth = False

        """Load UI"""
        self.ui = uic.loadUi('ui_array_analysis.ui', self)

        """Antenna array configuration"""
        self.calpattern = CalPattern()
        self.calpattern_thread = QThread()
        self.calpattern.patternReady.connect(self.update_figure)
        self.calpattern_thread.started.connect(
            self.calpattern.cal_pattern)
        self.calpattern.moveToThread(self.calpattern_thread)
        self.calpattern_thread.start()

        """Init UI"""
        self.init_ui()
        self.init_figure()

        self.new_params()
        self.ui.show() 
Example 28
def __init__(self):
        app = QtWidgets.QApplication(sys.argv)
        self.MainWindow = QtWidgets.QMainWindow()      
        self.ui = Ui_MainWindow()                           
        self.ui.setupUi(self.MainWindow)        
        self.update_widgets()
        self.widget_actions()      
        self.MainWindow.show()
        sys.exit(app.exec_()) 
Example 29
Project: universal_tool_template.py   Author: shiningdesign   File: universal_tool_template_1116.py    License: MIT License 5 votes vote down vote up
def __init__(self, parent=None, mode=0):
        UniversalToolUI.__init__(self, parent)
        
        # class variables
        self.version= version
        self.date = date
        self.log = log
        self.help = help
        
        # mode: example for receive extra user input as parameter
        self.mode = 0
        if mode in [0,1]:
            self.mode = mode # mode validator
        
        # Custom user variable
        #------------------------------
        # initial data
        #------------------------------
        self.memoData['data']=[]
        self.memoData['settingUI']=[]
        self.qui_user_dict = {} # e.g: 'edit': 'LNTextEdit',
        
        self.setupStyle()
        if isinstance(self, QtWidgets.QMainWindow):
            self.setupMenu()
        self.setupWin()
        self.setupUI()
        self.Establish_Connections()
        self.loadLang()
        self.loadData()
        
    #------------------------------
    # overwrite functions
    #------------------------------ 
Example 30
Project: universal_tool_template.py   Author: shiningdesign   File: ClassName_1010.py    License: MIT License 5 votes vote down vote up
def __init__(self):
        QtWidgets.QMainWindow.__init__(self)
        main_widget = QtWidgets.QWidget()
        self.setCentralWidget(main_widget)
        
        main_layout = QtWidgets.QVBoxLayout()
        main_widget.setLayout(main_layout)