我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用PyQt4.QtGui.QMainWindow()。
def setupWin(self): super(self.__class__,self).setupWin() self.setGeometry(500, 300, 250, 110) # self.resize(250,250) #------------------------------ # template list: for frameless or always on top option #------------------------------ # - template : keep ui always on top of all; # While in Maya, dont set Maya as its parent ''' self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) ''' # - template: hide ui border frame; # While in Maya, use QDialog instead, as QMainWindow will make it disappear ''' self.setWindowFlags(QtCore.Qt.FramelessWindowHint) ''' # - template: best solution for Maya QDialog without parent, for always on-Top frameless ui ''' self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint) ''' # - template: for transparent and non-regular shape ui # note: use it if you set main ui to transparent, and want to use alpha png as irregular shape window # note: black color better than white for better look of semi trans edge, like pre-mutiply ''' self.setAttribute(QtCore.Qt.WA_TranslucentBackground) self.setStyleSheet("background-color: rgba(0, 0, 0,0);") '''
def __init__(self, hostname, username, password): self.username = username self.password = password self.hostname = hostname self.patchports = None self.vlans = None #super(PortConfigGui, self).__init__() QtGui.QMainWindow.__init__(self) install_dir = os.path.dirname(os.path.realpath(__file__)) uic.loadUi(os.path.join(install_dir, 'PortConfigGui.ui'), self) self.statusbar.hide() self.buttonReload.clicked.connect(self._reload_data) self.buttonClearAll.clicked.connect(self._clear_pressed) self.buttonBugreport.clicked.connect(self.send_bug_report) self.buttonSubmitAll.clicked.connect(self._submit_all) self.setWindowTitle(self.windowTitle() + " " + self.hostname)
def __init__(self, parent=None): """Initiate GUI and Database. Args: db_handler (DBHandlerClass) : calls and initialize database. ui (QMainWindow) : calls and initialize main window. """ self.current_selection = False self.db_handler = DBHandlerClass() super(Main, self).__init__(parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.center_widget.entry.journalEntry.textChanged.connect(self.text_triggered) self.ui.center_widget.journalList.currentItemChanged.connect(self.item_changed) self.ui.actionNew_Entry.triggered.connect(self.new_entry_action) self.ui.action_Save_Entry.triggered.connect(self.save_button_action) self.ui.action_edit_entry.triggered.connect(self.edit_button_action) self.ui.action_Delete_Entry.triggered.connect(self.delete_button_action) self.ui.action_Cancel.triggered.connect(self.action_button_action) self.ui.center_widget.entry.journalEntry.setReadOnly(True) self.refresh_list_view() self.refresh_list_view()
def __init__( self, core ) : # Inheret all attributes of the "QMainWindow" class. super( custom_MainWindow, self ).__init__( ) # Save the Janus "core" to be associated with this object. self.core = core # Prepare to respond to signals received from the core. self.connect( self.core, SIGNAL('janus_exit'), self.resp_exit ) # Indicate that if a "closeEvent" is received, that a dialog # should be shown. self.show_dialog = True #----------------------------------------------------------------------- # RE-DEFINE THE RESPONSE TO THE CLOSE SIGNAL. #-----------------------------------------------------------------------
def __init__(self, parent=None): QtGui.QMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.setWindowIcon(QtGui.QIcon(os.path.join(appPath, 'assets', 'images', 'icon.jpg'))) self.apps = [] self.workspaces = [] self.keyboards = [] self.modes = {} self.initConfig() self.prepareUi() self.listenButtons() self.show()
def __init__(self, main): QtGui.QMainWindow.__init__(self, parent=None) load_ui(self, 'editor.ui') self.setContentsMargins(2, 2, 2, 2) pal = self.palette() pal.setColor(self.backgroundRole(), QtGui.QColor(20, 20, 20)) self.setPalette(pal) self.main = main self.blofeld_library = self.main.blofeld_library self.midi = self.main.midi self.input = self.midi.input self.output = self.midi.output self.graph = self.main.graph self.channel = 0 self.octave = 0 self.params = Params self.send = False self.notify = True self.save = False self._edited = False self.shown = False self.create_layout() self.setSoundDump()
def __init__(self): QtGui.QMainWindow.__init__(self) self.setWindowTitle("MK8-Editor") self.setGeometry(100,100,1080,720) self.setupMenu() self.qsettings = QtCore.QSettings("MrRean / RoadrunnerWMC","MK8 YAML Editor") self.restoreGeometry(self.qsettings.value("geometry").toByteArray()) self.restoreState(self.qsettings.value("windowState").toByteArray()) self.gamePath = self.qsettings.value('gamePath').toPyObject() if not self.isValidGameFolder(self.gamePath): self.changeGamePath(True) self.settings = SettingsWidget(self) self.setupGLScene() self.resizeWidgets() self.timer = QtCore.QTimer() self.timer.timeout.connect(self.updateCamera) self.timer.start(30) self.show()
def __init__(self): QtGui.QMainWindow.__init__(self) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.setWindowTitle("Allele frequency viewer") self.data = None self.genes = {} self.lastopeneddir = os.path.expanduser("~") self.initUI() self.init_menu() self.initRegionViewer() self.main_widget.setFocus() self.setCentralWidget(self.main_widget) self.showMaximized() self.tab_names = []
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
def setupWin(self): self.setWindowTitle("UITranslator" + " - v" + self.version) self.setGeometry(300, 300, 300, 300) # win icon setup path = os.path.join(os.path.dirname(self.location),'icons','UITranslator.png') self.setWindowIcon(QtGui.QIcon(path)) # initial win drag position self.drag_position=QtGui.QCursor.pos() #self.resize(250,250) # - for frameless or always on top option #self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) # it will keep ui always on top of desktop, but to set this in Maya, dont set Maya as its parent #self.setWindowFlags(QtCore.Qt.FramelessWindowHint) # it will hide ui border frame, but in Maya, use QDialog instead as QMainWindow will disappear #self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint) # best for Maya case with QDialog without parent, for always top frameless ui # - for transparent and non-regular shape ui #self.setAttribute(QtCore.Qt.WA_TranslucentBackground) # use it if you set main ui to transparent and want to use alpha png as irregular shape window #self.setStyleSheet("background-color: rgba(0, 0, 0,0);") # black color better white color for get better look of semi trans edge, like pre-mutiply
def eventFilter(self, source, event): if source not in [self.actionStop_btn, self.src_bpm_spin.lineEdit(), self.dest_bpm_spin.lineEdit()]: return QtGui.QMainWindow.eventFilter(self, source, event) if source == self.actionStop_btn: if event.type() not in [QtCore.QEvent.MouseButtonDblClick, QtCore.QEvent.ContextMenu]: return QtGui.QMainWindow.eventFilter(self, source, event) if event.type() == QtCore.QEvent.ContextMenu: return True if event.type() == QtCore.QEvent.MouseButtonDblClick: self.restart() return True elif source == self.src_bpm_spin.lineEdit() and event.type() == QtCore.QEvent.MouseButtonRelease and event.button() == 4: self.src_bpm_spin.setValue(120) return True elif source == self.dest_bpm_spin.lineEdit() and event.type() == QtCore.QEvent.MouseButtonRelease and event.button() == 4: self.dest_bpm_spin.setValue(self.src_bpm_spin.value()) return True return QtGui.QMainWindow.eventFilter(self, source, event)
def __init__(self,design_path): # initialize the UI. self._app = QtGui.QApplication(sys.argv) self._window = QtGui.QWidget() self._window.closeEvent = self.shutDown ui_module = import_module(design_path) self._ui = ui_module.Ui_Form() try: self._ui.setupUi(self._window) except: self._window = QtGui.QMainWindow() self._ui.setupUi(self._window) self._window.show() self._app.exec_()
def closeEvent(self, event): if self.childrenActive(): buttons = QtGui.QMessageBox.Yes | QtGui.QMessageBox.No | QtGui.QMessageBox.Cancel status = QtGui.QMessageBox.question(self, 'Processes active', """There are active processes. Do you want to terminate them?""", buttons) if status == QtGui.QMessageBox.Cancel: event.ignore() return elif status == QtGui.QMessageBox.Yes: self.terminateChildren() QtGui.QMainWindow.closeEvent(self, event)
def __init__(self): super(QtGui.QMainWindow, self).__init__() self.diagramScene = QtGui.QGraphicsScene(self) uic.loadUi('arrow.ui', self) self.graphicsView.setScene( self.diagramScene ) t1 = QtGui.QGraphicsRectItem(QtCore.QRectF(20,20,100,50 )) t1.setBrush(QtGui.QBrush(QtCore.Qt.white)) # t1.setFlag( QtGui.QGraphicsItem.ItemIsSelectable | QtGui.QGraphicsItem.ItemIsMoveable ) self.diagramScene.addItem(t1) p1 = QtGui.QGraphicsEllipseItem(QtCore.QRectF(200,200,100,50)) p1.setBrush(QtGui.QBrush(QtCore.Qt.white)) # p1.setFlags( QtGui.QGraphicsItem.ItemIsSelectable | QtGui.QGraphicsItem.ItemIsMoveable ) arc1 = ArcItem(self, self.diagramScene) arc1.arcLine.setLine(20,20,200,200) arc1.setPolygon() self.diagramScene.addItem(p1) self.show() pass
def __init__(self, parent=None): QtGui.QMainWindow.__init__(self, parent) self.setWindowTitle(u'?????') self.resize(700, 650) self.setWindowIcon(QtGui.QIcon('icons/logo.ico')) screen = QtGui.QDesktopWidget().screenGeometry() size = self.geometry() self.move((screen.width()-size.width())/2, (screen.height()-size.height())/2) self.initUI()
def __init__(self): QtGui.QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.btnConvert.clicked.connect(self.btnConvert_clicked) # self.ui.btnDefault.clicked.connect(self.btnDefault_clicked) self.ui.actionInput_File.triggered.connect(self.selectInputFile) self.ui.actionOutput_File.triggered.connect(self.setOutputFile)
def __init__(self): QtGui.QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.btnConvert.clicked.connect(self.btnConvert_clicked) self.ui.btnDefault.clicked.connect(self.btnDefault_clicked)
def __init__(self): QtGui.QMainWindow.__init__(self) self.main = Ui_MainWindow() self.flowconfig = flowconfig.FlowConfig(self) self.app = None self.streammod = StreamTable(self) # Dialogs self.aboutdialog = AboutDialog.AboutDialog(self) # Initialized after setupUi runs self.interfacesgui = None self.protocolsgui = None self.rulegui = None self.dbgui = None debugger_uri = "PYROLOC://127.0.0.1:7766/debugger" self.remote_debugger = Pyro.core.getProxyForURI(debugger_uri) self.main.dbname = self.remote_debugger.getdatabase() #self.proxy = xmlrpclib.ServerProxy("http://localhost:20757") #self.objectproxy = xmlrpclib.ServerProxy("http://localhost:20758") self.curdebugevent = "" self.log = logging.getLogger("mallorygui") config = Config() config.logsetup(self.log)
def __init__(self): QtGui.QMainWindow.__init__(self) self.main = Ui_MainWindow() self.app = None self.bdata = None self.ready = False
def __init__(self, ip, port=8080, parent=None): QtGui.QMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.ipAddress.setText(ip) self.ui.proxyPort.setValue(port) self.ui.startProxy.clicked.connect(self.startStopProxy) self.ui.actionQuit.triggered.connect(self.quit) self.ui.actionAbout.triggered.connect(self.about) self.ui.actionOpen_PCAP.triggered.connect(self.openPCAP) self.proxy = None
def __init__(self): QtGui.QMainWindow.__init__(self) self.setGeometry(300, 300, 180, 380) self.setWindowTitle('Tetris') self.tetrisboard = Board(self) self.setCentralWidget(self.tetrisboard) self.statusbar = self.statusBar() self.connect(self.tetrisboard, QtCore.SIGNAL("messageToStatusbar(QString)"), self.statusbar, QtCore.SLOT("showMessage(QString)")) self.tetrisboard.start() self.center()
def __init__(self): QtGui.QMainWindow.__init__(self) Ui_MainWindow.__init__(self) self.setupUi(self) print type(Ui_MainWindow) print type(QtBaseClass) self.getName.clicked.connect(self.showName)
def __init__(self, parent=None): QtGui.QMainWindow.__init__(self, parent) self.initUI()
def paintEvent(self, event): # Create a QPainter that can perform draw actions within a widget or image qp = QtGui.QPainter() # Begin drawing in the application widget qp.begin(self) # Update scale self.updateScale(qp) # Determine the object ID to highlight self.getHighlightedObject(qp) # Draw the image first self.drawImage(qp) if self.enableDisparity and self.showDisparity: # Draw the disparities on top overlay = self.drawDisp(qp) else: # Draw the labels on top overlay = self.drawLabels(qp) # Draw the label name next to the mouse self.drawLabelAtMouse(qp) # Draw the zoom self.drawZoom(qp, overlay) # Thats all drawing qp.end() # Forward the paint event QtGui.QMainWindow.paintEvent(self,event) # Update the scaling
def create(self): MainWindow = QtGui.QMainWindow() self.ui.setupUi(MainWindow) self.ui.label_2.setAlignment(QtCore.Qt.AlignCenter) self.sync_object = sync() QObject.connect(self.ui.pushButton,SIGNAL("clicked()"),self.sync_object.Login) QObject.connect(self.ui.pushButton_5,SIGNAL("clicked()"),self.makeTreeView) QObject.connect(self.ui.pushButton_2,SIGNAL("clicked()"),self.select_folder) # QObject.connect(self.ui.pushButton_2,SIGNAL("clicked()"),self.openFileDialog) self.treeMenu = QtGui.QMenu() self.treeAction = QtGui.QAction('Download', self.treeMenu) self.treeAction.triggered.connect(self.download_folder) self.ui.treeWidget.addAction(self.treeAction) MainWindow.show() sys.exit(app.exec_())
def __init__(self,application): #Init the base class QtGui.QMainWindow.__init__(self, None) self.application = application self.createWidgets()
def __init__(self): QtGui.QMainWindow.__init__(self) # This is always the same self.ui=Ui_MainWindow() self.ui.setupUi(self) self.createActions() self.myGraphicsScene=myGraphicsScene() self.myGraphicsScene.addLine() self.ui.mygraphicsView.setScene(self.myGraphicsScene) self.ui.mygraphicsView.show()
def __init__(self, parent=None): QtGui.QMainWindow.__init__(self, parent) self.setGeometry(300, 300, 350, 300) self.setWindowTitle('OpenFile') self.textEdit = QtGui.QTextEdit() self.setCentralWidget(self.textEdit) self.statusBar() self._label = QtGui.QLabel("Einkaufszaehler") self.statusBar().addPermanentWidget(self._label) self.statusBar().addPermanentWidget(self._label) self._label.setText("BLA2") self.setFocus() openFile = QtGui.QAction(QtGui.QIcon('open.png'), 'Open', self) openFile.setShortcut('Ctrl+O') openFile.setStatusTip('Open new File') self.connect(openFile, QtCore.SIGNAL('triggered()'), self.showDialog) menubar = self.menuBar() fileMenu = menubar.addMenu('&File') fileMenu.addAction(openFile)
def keyPressEvent(self,e): '''Close the window if escape is pressed, otherwise do as inherited.''' if e.key() == Qt.Key_Escape: self.close() else: QtGui.QMainWindow.keyPressEvent(self,e)
def show(self): '''Calls the inherited show() method then sets the splitter positions.''' QtGui.QMainWindow.show(self) self.listSplit.moveSplitter(100,1) self.seriesSplit.moveSplitter(80,1) self.viewMetaSplitter.moveSplitter(600,1)
def __init__(self): QtGui.QMainWindow.__init__(self) self.setupUi(self) self.ith = None self.labels = pd.DataFrame(index=[], columns=['image', 'cateid', 'tlx', 'tly', 'width', 'height']) self.labelsBuf = pd.DataFrame(index=[], columns=['image', 'cateid', 'tlx', 'tly', 'width', 'height']) self.labelFile = '' self._penwidth = 2 # even value self._offset = self._penwidth/2 self.initializeTasks()
def paintEvent(self, event): # Create a QPainter that can perform draw actions within a widget or image qp = QtGui.QPainter() # Begin drawing in the application widget qp.begin(self) # Update scale self.updateScale(qp) # Determine the object ID to highlight self.getHighlightedObject(qp) # Draw the image first self.drawImage(qp) # Draw the labels on top overlay = self.drawLabels(qp) # Draw the user drawn polygon self.drawDrawPoly(qp) self.drawDrawRect(qp) # Draw the label name next to the mouse self.drawLabelAtMouse(qp) # Draw the zoom # self.drawZoom(qp, overlay) self.drawZoom(qp,None) # Thats all drawing qp.end() # Forward the paint event QtGui.QMainWindow.paintEvent(self,event) # Update the scaling
def getMayaWindow(): """ Get the main Maya window as a QtGui.QMainWindow instance @return: QtGui.QMainWindow instance of the top level Maya windows """ ptr = apiUI.MQtUtil.mainWindow() if ptr is not None: return sip.wrapinstance(long(ptr), QtCore.QObject)
def getMayaWindow(self): """ Get the main Maya window as a QtGui.QMainWindow instance @return: QtGui.QMainWindow instance of the top level Maya windows """ ptr = apiUI.MQtUtil.mainWindow() if ptr is not None: return sip.wrapinstance(long(ptr), QObject)
def CreateSeq16(self): window = QtGui.QMainWindow() ui = seq16.Ui_MainWindow() ui.setupUi(window,True) self.mdiArea.addSubWindow(window) self.windows[window] = ui window.resize(940,600) window.show()
def CreateSeq16x8(self): window = QtGui.QMainWindow() ui = seq16x8.Ui_MainWindow() ui.setupUi(window,True) self.mdiArea.addSubWindow(window) self.windows[window] = ui window.show()
def CreateProSeq16x8(self): window = QtGui.QMainWindow() ui = proseq16x8.Ui_MainWindow() ui.setupUi(window,True) self.mdiArea.addSubWindow(window) self.windows[window] = ui window.show()
def __init__(self, parent=None): QtGui.QMainWindow.__init__(self, parent) self.setupUi(self) self.cntr, self.numImages = -1, -1 # self.cntr have the info of which image is selected/displayed self.image_viewer = ImageViewer(self.qlabel_image) self.__connectEvents() self.showMaximized()
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=False)) # 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 setWindowTitle(self, name=None): if name is None: name = self.name_edit.text() saved = '' if self.save_state else ' (edited)' QtGui.QMainWindow.setWindowTitle(self, 'Wavetable editor - {}{}'.format(name, saved))
def eventFilter(self, source, event): if source == self.gain_spin and event.type() == QtCore.QEvent.Wheel: if QtGui.QApplication.keyboardModifiers() == QtCore.Qt.ShiftModifier: self.gain_spin.setSingleStep(.01) else: self.gain_spin.setSingleStep(.1) elif ((event.type() == QtCore.QEvent.KeyPress and event.modifiers() & (QtCore.Qt.ShiftModifier|QtCore.Qt.ControlModifier)) or event.type() == QtCore.QEvent.KeyRelease) and self.wave_source_view.rect().contains(self.wave_source_view.mapFromGlobal(QtGui.QCursor().pos())): self.wave_source_view.event(event) return True return QtGui.QMainWindow.eventFilter(self, source, event)
def eventFilter(self, source, event): if event.type() == QtCore.QEvent.KeyPress: if event.key() == QtCore.Qt.Key_F5: self.dump_request_create() elif event.key() == QtCore.Qt.Key_Escape and source == self.search_edit: self.search_edit.setText('') if source == self.search_filter_chk and event.type() == QtCore.QEvent.FocusIn and event.reason() == QtCore.Qt.OtherFocusReason: self.search_edit.setFocus() return QtGui.QMainWindow.eventFilter(self, source, event)
def __init__(self, *args): QtGui.QMainWindow.__init__(self, *args) self._i=numpy.zeros((1,1,4),dtype=numpy.uint8) self.i=QtGui.QImage(self._i.data,self._i.shape[1],self._i.shape[0],self.imgconvarray[self._i.shape[2]]) self.show()
def __init__(self, *args, **kwargs): self.qtApp = QtGui.QApplication([]) super(QtGui.QMainWindow, self).__init__(*args, **kwargs) self.vlcInstance = vlc.Instance() self.vlcMediaPlayer = self.vlcInstance.media_player_new() self.isFullScreen = False self.currentMRL = "" self.subtitleFile = "" self.initUI() self.originalBackground = self.palette().color(self.backgroundRole())