本文整理汇总了Python中PyQt4.Qt.QMainWindow类的典型用法代码示例。如果您正苦于以下问题:Python QMainWindow类的具体用法?Python QMainWindow怎么用?Python QMainWindow使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QMainWindow类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, opts, parent=None, disable_automatic_gc=False):
QMainWindow.__init__(self, parent)
if disable_automatic_gc:
self._gc = GarbageCollector(self, debug=False)
if getattr(opts, 'redirect', False):
self.__console_redirect = DebugWindow(self)
sys.stdout = sys.stderr = self.__console_redirect
self.__console_redirect.show()
示例2: __init__
def __init__(self, syntax, parent=None):
QMainWindow.__init__(self, parent)
if parent is None:
self.setWindowFlags(Qt.Widget)
self.syntax = syntax
self.editor = TextEdit(self)
self.setCentralWidget(self.editor)
self.editor.modificationChanged.connect(self.modification_state_changed.emit)
self.create_toolbars()
示例3: closeEvent
def closeEvent(self, event):
dprint(1, "closing")
self._exiting = True
self.saveSizes()
if not self.closeFile():
self._exiting = False
event.ignore()
return
self.skyplot.close()
self.imgman.close()
self.emit(SIGNAL("closing"))
dprint(1, "invoking os._exit(0)")
os._exit(0)
QMainWindow.closeEvent(self, event)
示例4: __init__
def __init__(self, syntax, parent=None):
QMainWindow.__init__(self, parent)
if parent is None:
self.setWindowFlags(Qt.Widget)
self.syntax = syntax
self.editor = TextEdit(self)
self.setCentralWidget(self.editor)
self.editor.modificationChanged.connect(self.modification_state_changed.emit)
self.create_toolbars()
self.undo_available = False
self.redo_available = False
self.copy_available = self.cut_available = False
self.editor.undoAvailable.connect(self._undo_available)
self.editor.redoAvailable.connect(self._redo_available)
self.editor.textChanged.connect(self._data_changed)
self.editor.copyAvailable.connect(self._copy_available)
示例5: main
def main():
""" Main loop to run text widget as applation
"""
app = QApplication(sys.argv)
mwTextEditor = QMainWindow()
textEditorBar = EditorBar(mwTextEditor)
textEditor = TextWidget(textEditorBar)
textEditorBar.saveDocAsSignal.connect(textEditor.saveAs)
textEditorBar.spellSignal.connect(textEditor.toggleSpell)
textEditorBar.whiteSpaceSignal.connect(textEditor.togglewhiteSpace)
textEditorBar.boldSignal.connect(textEditor.toggleBold)
textEditorBar.italicSignal.connect(textEditor.toggleItalic)
textEditorBar.underlineSignal.connect(textEditor.toggleUnderline)
textEditorBar.strikethroughSignal.connect(textEditor.toggleStrikethrough)
textEditorBar.subscriptSignal.connect(textEditor.toggleSubscript)
textEditorBar.superscriptSignal.connect(textEditor.toggleSuperscript)
textEditor.fontFormatSignal.connect(textEditorBar.toggleFormat)
mwTextEditor.addToolBar(textEditorBar)
mwTextEditor.setCentralWidget(textEditor)
mwTextEditor.show()
return app.exec_()
示例6: closeEvent
def closeEvent(self, ev):
if self._hide_on_close:
ev.ignore()
self.hide()
self.new_entry_dialog.hide()
else:
if self.purrer:
self.purrer.detach()
return QMainWindow.closeEvent(self, ev)
示例7: __init__
def __init__(self, syntax, parent=None):
QMainWindow.__init__(self, parent)
if parent is None:
self.setWindowFlags(Qt.Widget)
self.is_synced_to_container = False
self.syntax = syntax
self._is_modified = False
self.copy_available = self.cut_available = False
self.quality = 90
self.canvas = Canvas(self)
self.setCentralWidget(self.canvas)
self.create_toolbars()
self.canvas.image_changed.connect(self.image_changed)
self.canvas.undo_redo_state_changed.connect(self.undo_redo_state_changed)
self.canvas.selection_state_changed.connect(self.update_clipboard_actions)
示例8: __init__
def __init__(self, syntax, parent=None):
QMainWindow.__init__(self, parent)
if parent is None:
self.setWindowFlags(Qt.Widget)
self.is_synced_to_container = False
self.syntax = syntax
self.editor = TextEdit(self)
self.editor.setContextMenuPolicy(Qt.CustomContextMenu)
self.editor.customContextMenuRequested.connect(self.show_context_menu)
self.setCentralWidget(self.editor)
self.create_toolbars()
self.undo_available = False
self.redo_available = False
self.copy_available = self.cut_available = False
self.editor.modificationChanged.connect(self._modification_state_changed)
self.editor.undoAvailable.connect(self._undo_available)
self.editor.redoAvailable.connect(self._redo_available)
self.editor.textChanged.connect(self._data_changed)
self.editor.copyAvailable.connect(self._copy_available)
self.editor.cursorPositionChanged.connect(self._cursor_position_changed)
示例9: closeEvent
def closeEvent(self, *args):
gprefs.set('preferences_window_geometry',
bytearray(self.saveGeometry()))
if self.committed:
self.gui.must_restart_before_config = self.must_restart
self.gui.tags_view.recount()
self.gui.create_device_menu()
self.gui.set_device_menu_items_state(bool(self.gui.device_connected))
self.gui.bars_manager.apply_settings()
self.gui.bars_manager.update_bars()
self.gui.build_context_menus()
return QMainWindow.closeEvent(self, *args)
示例10: __init__
def __init__(self, rddtDataExtractor, queue, recv):
"""
Main GUI Window that the user interacts with.
:type rddtDataExtractor: RedditDataExtractor.redditDataExtractor.RedditDataExtractor
:type queue: Queue.queue
:type recv: RedditDataExtractor.main.QueueMessageReceiver
"""
QMainWindow.__init__(self)
# Set up the user interface from Designer.
self.setupUi(self)
# The model for the view
self._rddtDataExtractor = rddtDataExtractor
# Bool to keep track of changes that have occurred that haven't been saved
self._unsavedChanges = False
self.queue = queue
self.recv = recv
# Custom Set ups
self.setup()
示例11: __init__
def __init__(self, gui, initial_plugin=None, close_after_initial=False):
QMainWindow.__init__(self, gui)
self.gui = gui
self.must_restart = False
self.committed = False
self.close_after_initial = close_after_initial
self.resize(930, 720)
nh, nw = min_available_height()-25, available_width()-10
if nh < 0:
nh = 800
if nw < 0:
nw = 600
nh = min(self.height(), nh)
nw = min(self.width(), nw)
self.resize(nw, nh)
self.esc_action = QAction(self)
self.addAction(self.esc_action)
self.esc_action.setShortcut(QKeySequence(Qt.Key_Escape))
self.esc_action.triggered.connect(self.esc)
geom = gprefs.get('preferences_window_geometry', None)
if geom is not None:
self.restoreGeometry(geom)
# Center
if islinux:
self.move(gui.rect().center() - self.rect().center())
self.setWindowModality(Qt.WindowModal)
self.setWindowTitle(__appname__ + ' - ' + _('Preferences'))
self.setWindowIcon(QIcon(I('config.png')))
self.status_bar = StatusBar(self)
self.setStatusBar(self.status_bar)
self.stack = QStackedWidget(self)
self.cw = QWidget(self)
self.cw.setLayout(QVBoxLayout())
self.cw.layout().addWidget(self.stack)
self.bb = QDialogButtonBox(QDialogButtonBox.Close)
self.wizard_button = self.bb.addButton(_('Run welcome wizard'),
self.bb.ActionRole)
self.wizard_button.setIcon(QIcon(I('wizard.png')))
self.wizard_button.clicked.connect(self.run_wizard,
type=Qt.QueuedConnection)
self.cw.layout().addWidget(self.bb)
self.bb.button(self.bb.Close).setDefault(True)
self.bb.rejected.connect(self.close, type=Qt.QueuedConnection)
self.setCentralWidget(self.cw)
self.browser = Browser(self)
self.browser.show_plugin.connect(self.show_plugin)
self.stack.addWidget(self.browser)
self.scroll_area = QScrollArea(self)
self.stack.addWidget(self.scroll_area)
self.scroll_area.setWidgetResizable(True)
self.bar = QToolBar(self)
self.addToolBar(self.bar)
self.bar.setVisible(False)
self.bar.setIconSize(QSize(ICON_SIZE, ICON_SIZE))
self.bar.setMovable(False)
self.bar.setFloatable(False)
self.bar.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
self.apply_action = self.bar.addAction(QIcon(I('ok.png')), _('&Apply'),
self.commit)
self.cancel_action = self.bar.addAction(QIcon(I('window-close.png')),
_('&Cancel'), self.cancel)
self.bar_title = BarTitle(self.bar)
self.bar.addWidget(self.bar_title)
self.restore_action = self.bar.addAction(QIcon(I('clear_left.png')),
_('Restore &defaults'), self.restore_defaults)
for ac, tt in [('apply', _('Save changes')),
('cancel', _('Cancel and return to overview'))]:
ac = getattr(self, ac+'_action')
ac.setToolTip(tt)
ac.setWhatsThis(tt)
ac.setStatusTip(tt)
for ch in self.bar.children():
if isinstance(ch, QToolButton):
ch.setCursor(Qt.PointingHandCursor)
ch.setAutoRaise(True)
self.stack.setCurrentIndex(0)
if initial_plugin is not None:
category, name = initial_plugin
plugin = get_plugin(category, name)
if plugin is not None:
self.show_plugin(plugin)
示例12: __init__
def __init__(self, parent, hide_on_close=False):
QMainWindow.__init__(self, parent)
self.setWindowIcon(pixmaps.tigger_starface.icon())
self._currier = PersistentCurrier()
self.hide()
# init column constants
for icol, col in enumerate(self.ViewModelColumns):
setattr(self, "Column%s" % col.capitalize(), icol)
# init GUI
self.setWindowTitle("Tigger")
# self.setIcon(pixmaps.purr_logo.pm())
cw = QWidget(self)
self.setCentralWidget(cw)
cwlo = QVBoxLayout(cw)
cwlo.setMargin(5)
# make splitter
spl1 = self._splitter1 = QSplitter(Qt.Vertical, cw)
spl1.setOpaqueResize(False)
cwlo.addWidget(spl1)
# Create listview of LSM entries
self.tw = SkyModelTreeWidget(spl1)
self.tw.hide()
# split bottom pane
spl2 = self._splitter2 = QSplitter(Qt.Horizontal, spl1)
spl2.setOpaqueResize(False)
self._skyplot_stack = QWidget(spl2)
self._skyplot_stack_lo = QVBoxLayout(self._skyplot_stack)
self._skyplot_stack_lo.setContentsMargins(0, 0, 0, 0)
# add plot
self.skyplot = SkyModelPlotter(self._skyplot_stack, self)
self.skyplot.resize(128, 128)
self.skyplot.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred)
self._skyplot_stack_lo.addWidget(self.skyplot, 1000)
self.skyplot.hide()
QObject.connect(self.skyplot, SIGNAL("imagesChanged"), self._imagesChanged)
QObject.connect(self.skyplot, SIGNAL("showMessage"), self.showMessage)
QObject.connect(self.skyplot, SIGNAL("showErrorMessage"), self.showErrorMessage)
self._grouptab_stack = QWidget(spl2)
self._grouptab_stack_lo = lo = QVBoxLayout(self._grouptab_stack)
self._grouptab_stack_lo.setContentsMargins(0, 0, 0, 0)
# add groupings table
self.grouptab = ModelGroupsTable(self._grouptab_stack)
self.grouptab.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
QObject.connect(self, SIGNAL("hasSkyModel"), self.grouptab.setEnabled)
lo.addWidget(self.grouptab, 1000)
lo.addStretch(1)
self.grouptab.hide()
# add image controls -- parentless for now (setLayout will reparent them anyway)
self.imgman = ImageManager()
self.skyplot.setImageManager(self.imgman)
QObject.connect(self.imgman, SIGNAL("imagesChanged"), self._imagesChanged)
QObject.connect(self.imgman, SIGNAL("showMessage"), self.showMessage)
QObject.connect(self.imgman, SIGNAL("showErrorMessage"), self.showErrorMessage)
# enable status line
self.statusBar().show()
# Create and populate main menu
menubar = self.menuBar()
# File menu
file_menu = menubar.addMenu("&File")
qa_open = file_menu.addAction("&Open model...", self._openFileCallback, Qt.CTRL + Qt.Key_O)
qa_merge = file_menu.addAction("&Merge in model...", self._mergeFileCallback, Qt.CTRL + Qt.SHIFT + Qt.Key_O)
QObject.connect(self, SIGNAL("hasSkyModel"), qa_merge.setEnabled)
file_menu.addSeparator()
qa_save = file_menu.addAction("&Save model", self.saveFile, Qt.CTRL + Qt.Key_S)
QObject.connect(self, SIGNAL("isUpdated"), qa_save.setEnabled)
qa_save_as = file_menu.addAction("Save model &as...", self.saveFileAs)
QObject.connect(self, SIGNAL("hasSkyModel"), qa_save_as.setEnabled)
qa_save_selection_as = file_menu.addAction("Save selection as...", self.saveSelectionAs)
QObject.connect(self, SIGNAL("hasSelection"), qa_save_selection_as.setEnabled)
file_menu.addSeparator()
qa_close = file_menu.addAction("&Close model", self.closeFile, Qt.CTRL + Qt.Key_W)
QObject.connect(self, SIGNAL("hasSkyModel"), qa_close.setEnabled)
qa_quit = file_menu.addAction("Quit", self.close, Qt.CTRL + Qt.Key_Q)
# Image menu
menubar.addMenu(self.imgman.getMenu())
# Plot menu
menubar.addMenu(self.skyplot.getMenu())
# LSM Menu
em = QMenu("&LSM", self)
self._qa_em = menubar.addMenu(em)
self._qa_em.setVisible(False)
QObject.connect(self, SIGNAL("hasSkyModel"), self._qa_em.setVisible)
self._column_view_menu = QMenu("&Show columns", self)
self._qa_cv_menu = em.addMenu(self._column_view_menu)
em.addSeparator()
em.addAction("Select &all", self._selectAll, Qt.CTRL + Qt.Key_A)
em.addAction("&Invert selection", self._selectInvert, Qt.CTRL + Qt.Key_I)
em.addAction("Select b&y attribute...", self._showSourceSelector, Qt.CTRL + Qt.Key_Y)
em.addSeparator()
qa_add_tag = em.addAction("&Tag selection...", self.addTagToSelection, Qt.CTRL + Qt.Key_T)
QObject.connect(self, SIGNAL("hasSelection"), qa_add_tag.setEnabled)
qa_del_tag = em.addAction("&Untag selection...", self.removeTagsFromSelection, Qt.CTRL + Qt.Key_U)
QObject.connect(self, SIGNAL("hasSelection"), qa_del_tag.setEnabled)
#.........这里部分代码省略.........
示例13: __init__
def __init__(self, opts, parent=None, disable_automatic_gc=False):
QMainWindow.__init__(self, parent)
if disable_automatic_gc:
self._gc = GarbageCollector(self, debug=False)
示例14: __init__
def __init__(self, parent=None):
QMainWindow.__init__(self, parent)
self.wrapper = TestWrapper()
self.setCentralWidget(self.wrapper)
self.resize(200, 300)
self.wrapper.show()
示例15: __init__
def __init__(self):
QMainWindow.__init__(self)
self.setWindowTitle("My Main Window")
self.setMinimumWidth(MAIN_WINDOW_SIZE[0])
self.setMinimumHeight(MAIN_WINDOW_SIZE[1])
self.statusbar = QtGui.QStatusBar(self)
self.statusbar.showMessage("Status message")
self.setStatusBar(self.statusbar)
################################################
self.menubar = self.menuBar()
# Any menu action makes the status bar message disappear
fileMenu = QtGui.QMenu(self.menubar)
fileMenu.setTitle("File")
self.menubar.addAction(fileMenu.menuAction())
newAction = QtGui.QAction("New", self)
newAction.setIcon(QtGui.QtIcon(icons + '/GroupPropDialog_image0.png'))
fileMenu.addAction(newAction)
openAction = QtGui.QAction("Open", self)
openAction.setIcon(QtGui.QtIcon(icons + "/MainWindowUI_image1"))
fileMenu.addAction(openAction)
saveAction = QtGui.QAction("Save", self)
saveAction.setIcon(QtGui.QtIcon(icons + "/MainWindowUI_image2"))
fileMenu.addAction(saveAction)
self.connect(newAction,SIGNAL("activated()"),self.fileNew)
self.connect(openAction,SIGNAL("activated()"),self.fileOpen)
self.connect(saveAction,SIGNAL("activated()"),self.fileSave)
for otherMenuName in ('Edit', 'View', 'Display', 'Select', 'Modify', 'NanoHive-1'):
otherMenu = QtGui.QMenu(self.menubar)
otherMenu.setTitle(otherMenuName)
self.menubar.addAction(otherMenu.menuAction())
helpMenu = QtGui.QMenu(self.menubar)
helpMenu.setTitle("Help")
self.menubar.addAction(helpMenu.menuAction())
aboutAction = QtGui.QAction("About", self)
aboutAction.setIcon(QtGui.QtIcon(icons + '/MainWindowUI_image0.png'))
helpMenu.addAction(aboutAction)
self.connect(aboutAction,SIGNAL("activated()"),self.helpAbout)
##############################################
self.setMenuBar(self.menubar)
centralwidget = QWidget()
self.setCentralWidget(centralwidget)
layout = QVBoxLayout(centralwidget)
layout.setMargin(0)
layout.setSpacing(0)
middlewidget = QWidget()
self.bigButtons = QWidget()
bblo = QHBoxLayout(self.bigButtons)
bblo.setMargin(0)
bblo.setSpacing(0)
self.bigButtons.setMinimumHeight(50)
self.bigButtons.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
for name in ('Features', 'Sketch', 'Build', 'Dimension', 'Simulator'):
btn = QPushButton(self.bigButtons)
btn.setMaximumWidth(80)
btn.setMinimumHeight(50)
btn.setText(name)
self.bigButtons.layout().addWidget(btn)
self.bigButtons.hide()
layout.addWidget(self.bigButtons)
self.littleIcons = QWidget()
self.littleIcons.setMinimumHeight(30)
self.littleIcons.setMaximumHeight(30)
lilo = QHBoxLayout(self.littleIcons)
lilo.setMargin(0)
lilo.setSpacing(0)
pb = QPushButton(self.littleIcons)
pb.setIcon(QIcon(icons + '/GroupPropDialog_image0.png'))
self.connect(pb,SIGNAL("clicked()"),self.fileNew)
lilo.addWidget(pb)
for x in "1 2 4 5 6 7 8 18 42 10 43 150 93 94 97 137".split():
pb = QPushButton(self.littleIcons)
pb.setIcon(QIcon(icons + '/MainWindowUI_image' + x + '.png'))
lilo.addWidget(pb)
layout.addWidget(self.littleIcons)
layout.addWidget(middlewidget)
self.layout = QGridLayout(middlewidget)
self.layout.setMargin(0)
self.layout.setSpacing(2)
self.gridPosition = GridPosition()
self.numParts = 0
self.show()
explainWindow = AboutWindow("Select <b>Help->About</b>"
#.........这里部分代码省略.........