def __init__(self, log_enable=None): QtGui.QMenu.__init__(self) self.setTitle('Y Axis') # range self.range = QtGui.QMenu() self.range.setTitle('Range') self.range_group = QtGui.QActionGroup(self) self.range_group.setExclusive(True) self.range_auto = QtGui.QAction( '&Auto', self.range_group, checkable=True, toolTip= 'Automatically adjust the y-axis range to show all visible data.') self.range_auto.setChecked(True) self.range.addAction(self.range_auto) self.range_group.addAction(self.range_auto) self.range_manual = QtGui.QAction( '&Manual', self.range_group, checkable=True, toolTip='Manually zoom and pan the y-axis range.') self.range.addAction(self.range_manual) self.range_group.addAction(self.range_manual) self.addMenu(self.range) self.scale = QtGui.QMenu() self.scale.setTitle('Scale') self.scale_group = QtGui.QActionGroup(self) self.scale_group.setExclusive(True) self.scale_linear = QtGui.QAction( '&Linear', self.scale_group, checkable=True, toolTip='Use a "normal" linear y-axis scale.') self.scale_linear.setChecked(True) self.scale.addAction(self.scale_linear) self.scale_group.addAction(self.scale_linear) self.scale_logarithmic = QtGui.QAction( 'Lo&garithmic', self.scale_group, checkable=True, toolTip='Use a logarithmic y-axis scale.') self.scale.addAction(self.scale_logarithmic) self.scale_group.addAction(self.scale_logarithmic) if log_enable: self.addMenu(self.scale) self.hide_request = QtGui.QAction('&Hide', self) self.hide_request.setToolTip('Hide this signal.') self.addAction(self.hide_request)
def __init__(self): QtGui.QMenu.__init__(self) self.annotations = self.addMenu('&Annotations') self.single_marker = QtGui.QAction('&Single Marker') self.annotations.addAction(self.single_marker) self.dual_markers = QtGui.QAction('&Dual Markers') self.annotations.addAction(self.dual_markers) self.clear_all_markers = QtGui.QAction('&Clear all') self.annotations.addAction(self.clear_all_markers)
def createActions(self): self.toFrontAction = QtGui.QAction( QtGui.QIcon(':/images/bringtofront.png'), "Bring to &Front", self, shortcut="Ctrl+F", statusTip="Bring item to front", triggered=self.bringToFront) self.sendBackAction = QtGui.QAction( QtGui.QIcon(':/images/sendtoback.png'), "Send to &Back", self, shortcut="Ctrl+B", statusTip="Send item to back", triggered=self.sendToBack) self.deleteAction = QtGui.QAction(QtGui.QIcon(':/images/delete.png'), "&Delete", self, shortcut="Delete", statusTip="Delete item from diagram", triggered=self.deleteItem) self.exitAction = QtGui.QAction("E&xit", self, shortcut="Ctrl+X", statusTip="Quit Scenediagram example", triggered=self.close) self.boldAction = QtGui.QAction(QtGui.QIcon(':/images/bold.png'), "Bold", self, checkable=True, shortcut="Ctrl+B", triggered=self.handleFontChange) self.italicAction = QtGui.QAction(QtGui.QIcon(':/images/italic.png'), "Italic", self, checkable=True, shortcut="Ctrl+I", triggered=self.handleFontChange) self.underlineAction = QtGui.QAction( QtGui.QIcon(':/images/underline.png'), "Underline", self, checkable=True, shortcut="Ctrl+U", triggered=self.handleFontChange) self.aboutAction = QtGui.QAction("A&bout", self, shortcut="Ctrl+B", triggered=self.about)
def __init__(self, parent=None): QtGui.QMainWindow.__init__(self, parent) self.centralWidget = QtGui.QWidget() self.setCentralWidget(self.centralWidget) self.createGroupBox() listWidget = QtGui.QListWidget() for le in MainWindow.listEntries: listWidget.addItem(self.tr(le)) mainLayout = QtGui.QVBoxLayout() mainLayout.addWidget(self.groupBox) mainLayout.addWidget(listWidget) self.centralWidget.setLayout(mainLayout) exitAction = QtGui.QAction(self.tr("E&xit"), self) self.connect(exitAction, QtCore.SIGNAL("triggered()"), QtGui.qApp, QtCore.SLOT("quit()")) fileMenu = self.menuBar().addMenu(self.tr("&File")) fileMenu.setPalette(QtGui.QPalette(QtCore.Qt.red)) fileMenu.addAction(exitAction) self.setWindowTitle(self.tr("Language: %s") % (self.tr("English"))) self.statusBar().showMessage(self.tr("Internationalization Example")) if self.tr("LTR") == "RTL": self.setLayoutDirection(QtCore.Qt.RightToLeft)
def createActions(self): self.minimizeAction = QtGui.QAction("Mi&nimize", self, triggered=self.hide) self.maximizeAction = QtGui.QAction("Ma&ximize", self, triggered=self.showMaximized) self.restoreAction = QtGui.QAction("&Restore", self, triggered=self.showNormal) self.quitAction = QtGui.QAction("&Quit", self, triggered=QtGui.qApp.quit)
def createActions(self): self.addImagesAct = QtGui.QAction("&Add Images...", self, shortcut="Ctrl+A", triggered=self.addImage) self.removeAllImagesAct = QtGui.QAction("&Remove All Images", self, shortcut="Ctrl+R", triggered=self.removeAllImages) self.exitAct = QtGui.QAction("&Quit", self, shortcut="Ctrl+Q", triggered=self.close) self.styleActionGroup = QtGui.QActionGroup(self) for styleName in QtGui.QStyleFactory.keys(): action = QtGui.QAction(self.styleActionGroup, text="%s Style" % styleName, checkable=True, triggered=self.changeStyle) action.setData(styleName) self.guessModeStateAct = QtGui.QAction("&Guess Image Mode/State", self, checkable=True, checked=True) self.aboutAct = QtGui.QAction("&About", self, triggered=self.about) self.aboutQtAct = QtGui.QAction("About &Qt", self, triggered=QtGui.qApp.aboutQt)
def setupFileMenu(self): fileMenu = QtGui.QMenu(self.tr("&File"), self) self.menuBar().addMenu(fileMenu) newFileAct = QtGui.QAction(self.tr("&New..."), self) newFileAct.setShortcut( QtGui.QKeySequence(self.tr("Ctrl+N", "File|New"))) self.connect(newFileAct, QtCore.SIGNAL("triggered()"), self.newFile) fileMenu.addAction(newFileAct) openFileAct = QtGui.QAction(self.tr("&Open..."), self) openFileAct.setShortcut( QtGui.QKeySequence(self.tr("Ctrl+O", "File|Open"))) self.connect(openFileAct, QtCore.SIGNAL("triggered()"), self.openFile) fileMenu.addAction(openFileAct) fileMenu.addAction(self.tr("E&xit"), QtGui.qApp, QtCore.SLOT("quit()"), QtGui.QKeySequence(self.tr("Ctrl+Q", "File|Exit")))
def createActions(self): self.openAct = QtGui.QAction("&Open...", self, shortcut="Ctrl+O", triggered=self.open) self.printAct = QtGui.QAction("&Print...", self, shortcut="Ctrl+P", enabled=False, triggered=self.print_) self.exitAct = QtGui.QAction("E&xit", self, shortcut="Ctrl+Q", triggered=self.close) self.zoomInAct = QtGui.QAction("Zoom &In (25%)", self, shortcut="Ctrl++", enabled=False, triggered=self.zoomIn) self.zoomOutAct = QtGui.QAction("Zoom &Out (25%)", self, shortcut="Ctrl+-", enabled=False, triggered=self.zoomOut) self.normalSizeAct = QtGui.QAction("&Normal Size", self, shortcut="Ctrl+S", enabled=False, triggered=self.normalSize) self.fitToWindowAct = QtGui.QAction("&Fit to Window", self, enabled=False, checkable=True, shortcut="Ctrl+F", triggered=self.fitToWindow) self.aboutAct = QtGui.QAction("&About", self, triggered=self.about) self.aboutQtAct = QtGui.QAction("About &Qt", self, triggered=QtGui.qApp.aboutQt)
def __init__(self): super(MelexStatistics, self).__init__() self.setWindowTitle("Melex Statistics") self.docks = {} self._current_dock_pos = 0 exit_action = QtGui.QAction(QtGui.QIcon('exit.png'), '&Exit', self) exit_action.setShortcut('Ctrl+Q') exit_action.setStatusTip('Exit application') exit_action.triggered.connect(self.close) open_action = QtGui.QAction(QtGui.QIcon('open.png'), '&Open', self) open_action.setShortcut('Ctrl+O') open_action.setStatusTip('Open statistics') open_action.triggered.connect(self.open_statistics) self.statusBar() self.menubar = self.menuBar() fileMenu = self.menubar.addMenu('&File') fileMenu.addAction(open_action) fileMenu.addAction(exit_action)
def createActions(self): self.openAct = QtGui.QAction("&Open...", self, shortcut="Ctrl+O", triggered=self.open) self.saveAsAct = QtGui.QAction("&Save As...", self, shortcut="Ctrl+S", triggered=self.saveAs) self.exitAct = QtGui.QAction("E&xit", self, shortcut="Ctrl+Q", triggered=self.close) self.aboutAct = QtGui.QAction("&About", self, triggered=self.about) self.aboutQtAct = QtGui.QAction("About &Qt", self, triggered=QtGui.qApp.aboutQt)
def createColorMenu(self, slot, defaultColor): colors = [QtCore.Qt.black, QtCore.Qt.white, QtCore.Qt.red, QtCore.Qt.blue, QtCore.Qt.yellow] names = ["black", "white", "red", "blue", "yellow"] colorMenu = QtGui.QMenu(self) for color, name in zip(colors, names): action = QtGui.QAction(self.createColorIcon(color), name, self, triggered=slot) action.setData(QtGui.QColor(color)) colorMenu.addAction(action) if color == defaultColor: colorMenu.setDefaultAction(action) return colorMenu
def createActions(self): self.newAct = QtGui.QAction("&New", self, shortcut=QtGui.QKeySequence.New, statusTip="Create a new file", triggered=self.newFile) self.openAct = QtGui.QAction("&Open...", self, shortcut=QtGui.QKeySequence.Open, statusTip="Open an existing file", triggered=self.open) self.saveAct = QtGui.QAction("&Save", self, shortcut=QtGui.QKeySequence.Save, statusTip="Save the document to disk", triggered=self.save) self.saveAsAct = QtGui.QAction( "Save &As...", self, shortcut=QtGui.QKeySequence.SaveAs, statusTip="Save the document under a new name", triggered=self.saveAs) for i in range(MainWindow.MaxRecentFiles): self.recentFileActs.append( QtGui.QAction(self, visible=False, triggered=self.openRecentFile)) self.exitAct = QtGui.QAction("E&xit", self, shortcut="Ctrl+Q", statusTip="Exit the application", triggered=QtGui.qApp.closeAllWindows) self.aboutAct = QtGui.QAction( "&About", self, statusTip="Show the application's About box", triggered=self.about) self.aboutQtAct = QtGui.QAction( "About &Qt", self, statusTip="Show the Qt library's About box", triggered=QtGui.qApp.aboutQt)
def createActions(self): self.openAct = QtGui.QAction("&Open...", self, shortcut="Ctrl+O", triggered=self.open) for codec in self.codecs: name = codec_name(codec) action = QtGui.QAction(name + '...', self, triggered=self.save) action.setData(name) self.saveAsActs.append(action) self.exitAct = QtGui.QAction("E&xit", self, shortcut="Ctrl+Q", triggered=self.close) self.aboutAct = QtGui.QAction("&About", self, triggered=self.about) self.aboutQtAct = QtGui.QAction("About &Qt", self, triggered=QtGui.qApp.aboutQt)
def createActions(self): self.openAct = QtGui.QAction("&Open...", self, shortcut="Ctrl+O", triggered=self.open) for format in QtGui.QImageWriter.supportedImageFormats(): text = str(format.toUpper() + "...") action = QtGui.QAction(text, self, triggered=self.save) action.setData(format) self.saveAsActs.append(action) self.printAct = QtGui.QAction("&Print...", self, triggered=self.scribbleArea.print_) self.exitAct = QtGui.QAction("E&xit", self, shortcut="Ctrl+Q", triggered=self.close) self.penColorAct = QtGui.QAction("&Pen Color...", self, triggered=self.penColor) self.penWidthAct = QtGui.QAction("Pen &Width...", self, triggered=self.penWidth) self.clearScreenAct = QtGui.QAction( "&Clear Screen", self, shortcut="Ctrl+L", triggered=self.scribbleArea.clearImage) self.aboutAct = QtGui.QAction("&About", self, triggered=self.about) self.aboutQtAct = QtGui.QAction("About &Qt", self, triggered=QtGui.qApp.aboutQt)
def menu_exec(self, pos): menu = QtGui.QMenu() menu.setToolTipsVisible(True) signal_add = QtGui.QMenu() signal_add.setTitle('&Add') signal_add_actions = [] for s in self._signals_available: if s not in self._signals_visible: a = QtGui.QAction(s, signal_add) a.triggered.connect(self._signal_add_construct(s)) signal_add.addAction(a) signal_add_actions.append(a) if len(signal_add_actions): menu.addMenu(signal_add) menu.exec_(pos)
def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(573, 468) self.centralwidget = QtGui.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.vboxlayout = QtGui.QVBoxLayout(self.centralwidget) self.vboxlayout.setContentsMargins(0, 0, 0, 0) self.vboxlayout.setSpacing(0) self.vboxlayout.setObjectName("vboxlayout") self.view = QtGui.QTreeView(self.centralwidget) self.view.setAlternatingRowColors(True) self.view.setSelectionBehavior(QtGui.QAbstractItemView.SelectItems) self.view.setHorizontalScrollMode( QtGui.QAbstractItemView.ScrollPerPixel) self.view.setAnimated(False) self.view.setAllColumnsShowFocus(True) self.view.setObjectName("view") self.vboxlayout.addWidget(self.view) MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 573, 31)) self.menubar.setObjectName("menubar") self.fileMenu = QtGui.QMenu(self.menubar) self.fileMenu.setObjectName("fileMenu") self.actionsMenu = QtGui.QMenu(self.menubar) self.actionsMenu.setObjectName("actionsMenu") MainWindow.setMenuBar(self.menubar) self.statusbar = QtGui.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.exitAction = QtGui.QAction(MainWindow) self.exitAction.setObjectName("exitAction") self.insertRowAction = QtGui.QAction(MainWindow) self.insertRowAction.setObjectName("insertRowAction") self.removeRowAction = QtGui.QAction(MainWindow) self.removeRowAction.setObjectName("removeRowAction") self.insertColumnAction = QtGui.QAction(MainWindow) self.insertColumnAction.setObjectName("insertColumnAction") self.removeColumnAction = QtGui.QAction(MainWindow) self.removeColumnAction.setObjectName("removeColumnAction") self.insertChildAction = QtGui.QAction(MainWindow) self.insertChildAction.setObjectName("insertChildAction") self.fileMenu.addAction(self.exitAction) self.actionsMenu.addAction(self.insertRowAction) self.actionsMenu.addAction(self.insertColumnAction) self.actionsMenu.addSeparator() self.actionsMenu.addAction(self.removeRowAction) self.actionsMenu.addAction(self.removeColumnAction) self.actionsMenu.addSeparator() self.actionsMenu.addAction(self.insertChildAction) self.menubar.addAction(self.fileMenu.menuAction()) self.menubar.addAction(self.actionsMenu.menuAction()) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow)
def createActions(self): self.newLetterAct = QtGui.QAction(QtGui.QIcon(':/images/new.png'), "&New Letter", self, shortcut=QtGui.QKeySequence.New, statusTip="Create a new form letter", triggered=self.newLetter) self.saveAct = QtGui.QAction(QtGui.QIcon(':/images/save.png'), "&Save...", self, shortcut=QtGui.QKeySequence.Save, statusTip="Save the current form letter", triggered=self.save) self.printAct = QtGui.QAction( QtGui.QIcon(':/images/print.png'), "&Print...", self, shortcut=QtGui.QKeySequence.Print, statusTip="Print the current form letter", triggered=self.print_) self.undoAct = QtGui.QAction(QtGui.QIcon(':/images/undo.png'), "&Undo", self, shortcut=QtGui.QKeySequence.Undo, statusTip="Undo the last editing action", triggered=self.undo) self.quitAct = QtGui.QAction("&Quit", self, shortcut="Ctrl+Q", statusTip="Quit the application", triggered=self.close) self.aboutAct = QtGui.QAction( "&About", self, statusTip="Show the application's About box", triggered=self.about) self.aboutQtAct = QtGui.QAction( "About &Qt", self, statusTip="Show the Qt library's About box", triggered=QtGui.qApp.aboutQt)
def __init__(self, parent=None): super(ShapedClock, self).__init__( parent, QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowSystemMenuHint) timer = QtCore.QTimer(self) timer.timeout.connect(self.update) timer.start(1000) quitAction = QtGui.QAction("E&xit", self, shortcut="Ctrl+Q", triggered=QtGui.qApp.quit) self.addAction(quitAction) self.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) self.setToolTip("Drag the clock with the left mouse button.\n" "Use the right mouse button to open a context menu.") self.setWindowTitle(self.tr("Shaped Analog Clock"))
def createActions(self): self.renderIntoPixmapAct = QtGui.QAction("&Render into Pixmap...", self, shortcut="Ctrl+R", triggered=self.renderIntoPixmap) self.grabFrameBufferAct = QtGui.QAction("&Grab Frame Buffer", self, shortcut="Ctrl+G", triggered=self.grabFrameBuffer) self.clearPixmapAct = QtGui.QAction("&Clear Pixmap", self, shortcut="Ctrl+L", triggered=self.clearPixmap) self.exitAct = QtGui.QAction("E&xit", self, shortcut="Ctrl+Q", triggered=self.close) self.aboutAct = QtGui.QAction("&About", self, triggered=self.about) self.aboutQtAct = QtGui.QAction("About &Qt", self, triggered=QtGui.qApp.aboutQt)
def __init__(self, parent = None): QtGui.QMainWindow.__init__(self, parent) self.categories = {} self.runningProcesses = {} self.examples = {} self.runningExamples = [] self.titleFont = QtGui.QFont(self.font()) self.titleFont.setWeight(QtGui.QFont.Bold) self.fontRatio = 0.8 self.documentFont = self.font() self.inFullScreenResize = False self.currentCategory = "[starting]" self.qtLogo = QtGui.QImage() self.rbLogo = QtGui.QImage() self.currentExample = "" self.assistantProcess = QtCore.QProcess() parentPageAction1 = QtGui.QAction(self.tr("Show Parent Page"), self) parentPageAction2 = QtGui.QAction(self.tr("Show Parent Page"), self) parentPageAction3 = QtGui.QAction(self.tr("Show Parent Page"), self) parentPageAction1.setShortcut(QtGui.QKeySequence(self.tr("Escape"))) parentPageAction2.setShortcut(QtGui.QKeySequence(self.tr("Backspace"))) parentPageAction3.setShortcut(QtGui.QKeySequence(self.tr("Alt+Left"))) fullScreenAction = QtGui.QAction(self.tr("Toggle &Full Screen"), self) fullScreenAction.setShortcut(QtGui.QKeySequence(self.tr("Ctrl+F"))) exitAction = QtGui.QAction(self.tr("E&xit"), self) exitAction.setShortcut(QtGui.QKeySequence(self.tr("Ctrl+Q"))) self.connect(parentPageAction1, QtCore.SIGNAL("triggered()"), self, QtCore.SIGNAL("showPage()")) self.connect(parentPageAction2, QtCore.SIGNAL("triggered()"), self, QtCore.SIGNAL("showPage()")) self.connect(parentPageAction3, QtCore.SIGNAL("triggered()"), self, QtCore.SIGNAL("showPage()")) self.connect(fullScreenAction, QtCore.SIGNAL("triggered()"), self.toggleFullScreen) self.connect(exitAction, QtCore.SIGNAL("triggered()"), self.close) self.display = DisplayWidget() self.addAction(parentPageAction1) self.addAction(parentPageAction2) self.addAction(parentPageAction3) self.addAction(fullScreenAction) self.addAction(exitAction) self.slideshowTimer = QtCore.QTimer(self) self.slideshowTimer.setInterval(5000) self.resizeTimer = QtCore.QTimer(self) self.resizeTimer.setSingleShot(True) self.connect(self.resizeTimer, QtCore.SIGNAL("timeout()"), self.redisplayWindow) self.connect(self.display, QtCore.SIGNAL("actionRequested"), self.executeAction) self.connect(self.display, QtCore.SIGNAL("categoryRequested"), self.showExamples) self.connect(self.display, QtCore.SIGNAL("documentationRequested"), self.showExampleDocumentation) self.connect(self.display, QtCore.SIGNAL("exampleRequested"), self.showExampleSummary) self.connect(self.display, QtCore.SIGNAL("launchRequested"), self.launchExample) self.connect(self, QtCore.SIGNAL("showPage()"), self.showParentPage, QtCore.Qt.QueuedConnection) self.connect(self, QtCore.SIGNAL("windowResized()"), self.redisplayWindow, QtCore.Qt.QueuedConnection) self.setCentralWidget(self.display) self.setMaximumSize(QtGui.QApplication.desktop().screenGeometry().size()) self.setWindowTitle(self.tr("PyQt Examples and Demos")) self.setWindowIcon(QtGui.QIcon(QtGui.QPixmap(":/images/qt4-logo.png")))
def createActions(self): self.newAct = QtGui.QAction(QtGui.QIcon(':/images/new.png'), "&New", self, shortcut=QtGui.QKeySequence.New, statusTip="Create a new file", triggered=self.newFile) self.openAct = QtGui.QAction(QtGui.QIcon(':/images/open.png'), "&Open...", self, shortcut=QtGui.QKeySequence.Open, statusTip="Open an existing file", triggered=self.open) self.saveAct = QtGui.QAction(QtGui.QIcon(':/images/save.png'), "&Save", self, shortcut=QtGui.QKeySequence.Save, statusTip="Save the document to disk", triggered=self.save) self.saveAsAct = QtGui.QAction( "Save &As...", self, shortcut=QtGui.QKeySequence.SaveAs, statusTip="Save the document under a new name", triggered=self.saveAs) self.closeAct = QtGui.QAction("&Close", self, shortcut="Ctrl+W", statusTip="Close this window", triggered=self.close) self.exitAct = QtGui.QAction("E&xit", self, shortcut="Ctrl+Q", statusTip="Exit the application", triggered=QtGui.qApp.closeAllWindows) self.cutAct = QtGui.QAction( QtGui.QIcon(':/images/cut.png'), "Cu&t", self, enabled=False, shortcut=QtGui.QKeySequence.Cut, statusTip="Cut the current selection's contents to the clipboard", triggered=self.textEdit.cut) self.copyAct = QtGui.QAction( QtGui.QIcon(':/images/copy.png'), "&Copy", self, enabled=False, shortcut=QtGui.QKeySequence.Copy, statusTip="Copy the current selection's contents to the clipboard", triggered=self.textEdit.copy) self.pasteAct = QtGui.QAction( QtGui.QIcon(':/images/paste.png'), "&Paste", self, shortcut=QtGui.QKeySequence.Paste, statusTip= "Paste the clipboard's contents into the current selection", triggered=self.textEdit.paste) self.aboutAct = QtGui.QAction( "&About", self, statusTip="Show the application's About box", triggered=self.about) self.aboutQtAct = QtGui.QAction( "About &Qt", self, statusTip="Show the Qt library's About box", triggered=QtGui.qApp.aboutQt) self.textEdit.copyAvailable.connect(self.cutAct.setEnabled) self.textEdit.copyAvailable.connect(self.copyAct.setEnabled)
def initUI(self): """ Initializes graphical elements of Terminal. Including... * Toolbar * :class:`.gui.Control_Panel` * :class:`.plots.Plot_Widget` """ # set central widget self.widget = QtWidgets.QWidget() self.setCentralWidget(self.widget) # Start GUI self.layout = QtWidgets.QGridLayout() self.layout.setSpacing(0) self.layout.setContentsMargins(0, 0, 0, 0) self.widget.setLayout(self.layout) self.setWindowTitle('Terminal') #self.menuBar().setFixedHeight(40) # Main panel layout #self.panel_layout.setContentsMargins(0,0,0,0) # Init toolbar # File menu # make menu take up 1/10 of the screen winsize = app.desktop().availableGeometry() if sys.platform == 'darwin': bar_height = 0 else: bar_height = (winsize.height() / 30) + 5 self.menuBar().setFixedHeight(bar_height) self.file_menu = self.menuBar().addMenu("&File") self.file_menu.setObjectName("file") new_pilot_act = QtWidgets.QAction("New &Pilot", self, triggered=self.new_pilot) new_prot_act = QtWidgets.QAction("New Pro&tocol", self, triggered=self.new_protocol) #batch_create_subjects = QtWidgets.QAction("Batch &Create subjects", self, triggered=self.batch_subjects) # TODO: Update pis self.file_menu.addAction(new_pilot_act) self.file_menu.addAction(new_prot_act) #self.file_menu.addAction(batch_create_subjects) # Tools menu self.tool_menu = self.menuBar().addMenu("&Tools") subject_weights_act = QtWidgets.QAction("View Subject &Weights", self, triggered=self.subject_weights) update_protocol_act = QtWidgets.QAction( "Update Protocols", self, triggered=self.update_protocols) reassign_act = QtWidgets.QAction("Batch Reassign Protocols", self, triggered=self.reassign_protocols) calibrate_act = QtWidgets.QAction("Calibrate &Water Ports", self, triggered=self.calibrate_ports) self.tool_menu.addAction(subject_weights_act) self.tool_menu.addAction(update_protocol_act) self.tool_menu.addAction(reassign_act) self.tool_menu.addAction(calibrate_act) # Plots menu self.plots_menu = self.menuBar().addMenu("&Plots") psychometric = QtGui.QAction("Psychometric Curve", self, triggered=self.plot_psychometric) self.plots_menu.addAction(psychometric) # Tests menu self.tests_menu = self.menuBar().addMenu("Test&s") bandwidth_test_act = QtWidgets.QAction("Test Bandwidth", self, triggered=self.test_bandwidth) self.tests_menu.addAction(bandwidth_test_act) ## Init main panels and add to layout # Control panel sits on the left, controls pilots & subjects self.control_panel = Control_Panel(pilots=self.pilots, subjects=self.subjects, start_fn=self.toggle_start) # Data panel sits on the right, plots stuff. self.data_panel = Plot_Widget() self.data_panel.init_plots(self.pilots.keys()) # Logo goes up top # https://stackoverflow.com/questions/25671275/pyside-how-to-set-an-svg-icon-in-qtreewidgets-item-and-change-the-size-of-the # # pixmap_path = os.path.join(os.path.dirname(prefs.get('AUTOPILOT_ROOT')), 'graphics', 'autopilot_logo_small.svg') # #svg_renderer = QtSvg.QSvgRenderer(pixmap_path) # #image = QtWidgets.QImage() # #self.logo = QtSvg.QSvgWidget() # # # # set size, preserving aspect ratio # logo_height = round(44.0*((bar_height-5)/44.0)) # logo_width = round(139*((bar_height-5)/44.0)) # # svg_renderer = QtSvg.QSvgRenderer(pixmap_path) # image = QtGui.QImage(logo_width, logo_height, QtGui.QImage.Format_ARGB32) # # Set the ARGB to 0 to prevent rendering artifacts # image.fill(0x00000000) # svg_renderer.render(QtGui.QPainter(image)) # pixmap = QtGui.QPixmap.fromImage(image) # self.logo = QtWidgets.QLabel() # self.logo.setPixmap(pixmap) if sys.platform != 'darwin': self.menuBar().setCornerWidget(self.logo, QtCore.Qt.TopRightCorner) self.menuBar().adjustSize() #self.logo.load(pixmap_path) # Combine all in main layout #self.layout.addWidget(self.logo, 0,0,1,2) self.layout.addWidget(self.control_panel, 0, 0, 1, 1) self.layout.addWidget(self.data_panel, 0, 1, 1, 1) self.layout.setColumnStretch(0, 1) self.layout.setColumnStretch(1, 3) # Set size of window to be fullscreen without maximization # Until a better solution is found, if not set large enough, the pilot tabs will # expand into infinity. See the Expandable_Tabs class #pdb.set_trace() screensize = app.desktop().screenGeometry() winsize = app.desktop().availableGeometry() # want to subtract bounding title box, our title bar, and logo height. # our y offset will be the size of the bounding title box # Then our tilebar # multiply by three to get the inner (file, etc.) bar, the top bar (min, maximize, etc) # and then the very top system tray bar in ubuntu #titleBarHeight = self.style().pixelMetric(QtWidgets.QStyle.PM_TitleBarHeight, # QtWidgets.QStyleOptionTitleBar(), self) * 3 title_bar_height = screensize.height() - winsize.height() #titleBarHeight = bar_height*2 # finally our logo logo_height = bar_height winheight = winsize.height( ) - title_bar_height - logo_height # also subtract logo height winsize.setHeight(winheight) self.max_height = winheight self.setGeometry(winsize) self.setSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Maximum) # Set heights on control panel and data panel # move to primary display and show maximized primary_display = app.desktop().availableGeometry(0) self.move(primary_display.left(), primary_display.top()) # self.resize(primary_display.width(), primary_display.height()) # self.control_panel.setMaximumHeight(winheight) self.data_panel.setMaximumHeight(winheight) # set stylesheet for main window self.setStyleSheet(styles.TERMINAL) # set fonts to antialias self.setFont(self.font().setStyleStrategy(QtGui.QFont.PreferAntialias)) self.show() logging.info('UI Initialized')
def __init__(self, sensor): QtWidgets.QMainWindow.__init__(self) # super doesn't seem to work here self.setWindowTitle("MUGIC Plot") self.window_widget = QtWidgets.QWidget() self.main_layout = QtWidgets.QVBoxLayout() self.window_widget.setLayout(self.main_layout) self.setCentralWidget(self.window_widget) self.setMinimumSize(1500, 500) self.stream = sensor.stream # Create the plot widget to use as the central widget self.plot_widget = PlotWidget(sensor) self.main_layout.addWidget(self.plot_widget) # Create the control panel self.control_widget = QtWidgets.QWidget(self) self.control_layout = QtWidgets.QHBoxLayout() self.main_layout.addWidget(self.control_widget) self.control_widget.setLayout(self.control_layout) self.toggle_button = QtWidgets.QPushButton() self.toggle_button.setText("Start Recording") self.toggle_button.clicked.connect(self.toggle_recording) self.control_layout.addWidget(self.toggle_button) reset_button = QtWidgets.QPushButton() reset_button.setText("Reset") reset_button.clicked.connect(self.reset_recording) self.control_layout.addWidget(reset_button) export_button = QtWidgets.QPushButton() export_button.setText("Export") export_button.clicked.connect(self.export_csv) self.control_layout.addWidget(export_button) # Create the menu bar menu_bar = self.menuBar() file_menu = menu_bar.addMenu("File") run_menu = menu_bar.addMenu("Run") toggle_option = QtGui.QAction("Toggle recording", self) toggle_option.setShortcut("Ctrl+R") toggle_option.setStatusTip("Start/stop plotting data") toggle_option.triggered.connect(self.toggle_recording) run_menu.addAction(toggle_option) toggle_option = QtGui.QAction("Reset plots", self) toggle_option.setShortcut("Ctrl+Backspace") toggle_option.setStatusTip("Clear plotting data") toggle_option.triggered.connect(self.reset_recording) run_menu.addAction(toggle_option) export_option = QtGui.QAction("Export data...", self) export_option.setShortcut("Ctrl+S") export_option.setStatusTip("Export accumulated raw and processed data") export_option.triggered.connect(self.export_csv) file_menu.addAction(export_option) # Create the output console self.console = QtGui.QTextEdit() self.console.moveCursor(QtGui.QTextCursor.Start) self.console.ensureCursorVisible() self.main_layout.addWidget(self.console) # Hook up stdout to the console sys.stdout = TextStream() sys.stdout.signal.connect(self.update_text) # Start the plot loop self.timer = QtCore.QTimer() self.timer.timeout.connect(self.plot_widget.update) self.timer.start(10)
def createActions(self): self.newAct = QtGui.QAction(QtGui.QIcon(':/images/new.png'), "&New", self, shortcut=QtGui.QKeySequence.New, statusTip="Create a new file", triggered=self.newFile) self.openAct = QtGui.QAction(QtGui.QIcon(':/images/open.png'), "&Open...", self, shortcut=QtGui.QKeySequence.Open, statusTip="Open an existing file", triggered=self.open) self.saveAct = QtGui.QAction(QtGui.QIcon(':/images/save.png'), "&Save", self, shortcut=QtGui.QKeySequence.Save, statusTip="Save the document to disk", triggered=self.save) self.saveAsAct = QtGui.QAction( "Save &As...", self, shortcut=QtGui.QKeySequence.SaveAs, statusTip="Save the document under a new name", triggered=self.saveAs) self.exitAct = QtGui.QAction("E&xit", self, shortcut="Ctrl+Q", statusTip="Exit the application", triggered=QtGui.qApp.closeAllWindows) self.cutAct = QtGui.QAction( QtGui.QIcon(':/images/cut.png'), "Cu&t", self, shortcut=QtGui.QKeySequence.Cut, statusTip="Cut the current selection's contents to the clipboard", triggered=self.cut) self.copyAct = QtGui.QAction( QtGui.QIcon(':/images/copy.png'), "&Copy", self, shortcut=QtGui.QKeySequence.Copy, statusTip="Copy the current selection's contents to the clipboard", triggered=self.copy) self.pasteAct = QtGui.QAction( QtGui.QIcon(':/images/paste.png'), "&Paste", self, shortcut=QtGui.QKeySequence.Paste, statusTip= "Paste the clipboard's contents into the current selection", triggered=self.paste) self.closeAct = QtGui.QAction( "Cl&ose", self, shortcut="Ctrl+F4", statusTip="Close the active window", triggered=self.mdiArea.closeActiveSubWindow) self.closeAllAct = QtGui.QAction( "Close &All", self, statusTip="Close all the windows", triggered=self.mdiArea.closeAllSubWindows) self.tileAct = QtGui.QAction("&Tile", self, statusTip="Tile the windows", triggered=self.mdiArea.tileSubWindows) self.cascadeAct = QtGui.QAction( "&Cascade", self, statusTip="Cascade the windows", triggered=self.mdiArea.cascadeSubWindows) self.nextAct = QtGui.QAction( "Ne&xt", self, shortcut=QtGui.QKeySequence.NextChild, statusTip="Move the focus to the next window", triggered=self.mdiArea.activateNextSubWindow) self.previousAct = QtGui.QAction( "Pre&vious", self, shortcut=QtGui.QKeySequence.PreviousChild, statusTip="Move the focus to the previous window", triggered=self.mdiArea.activatePreviousSubWindow) self.separatorAct = QtGui.QAction(self) self.separatorAct.setSeparator(True) self.aboutAct = QtGui.QAction( "&About", self, statusTip="Show the application's About box", triggered=self.about) self.aboutQtAct = QtGui.QAction( "About &Qt", self, statusTip="Show the Qt library's About box", triggered=QtGui.qApp.aboutQt)
def createActions(self): self.newAct = QtGui.QAction("&New", self, shortcut=QtGui.QKeySequence.New, statusTip="Create a new file", triggered=self.newFile) self.openAct = QtGui.QAction("&Open...", self, shortcut=QtGui.QKeySequence.Open, statusTip="Open an existing file", triggered=self.open) self.saveAct = QtGui.QAction("&Save", self, shortcut=QtGui.QKeySequence.Save, statusTip="Save the document to disk", triggered=self.save) self.printAct = QtGui.QAction("&Print...", self, shortcut=QtGui.QKeySequence.Print, statusTip="Print the document", triggered=self.print_) self.exitAct = QtGui.QAction("E&xit", self, shortcut="Ctrl+Q", statusTip="Exit the application", triggered=self.close) self.undoAct = QtGui.QAction("&Undo", self, shortcut=QtGui.QKeySequence.Undo, statusTip="Undo the last operation", triggered=self.undo) self.redoAct = QtGui.QAction("&Redo", self, shortcut=QtGui.QKeySequence.Redo, statusTip="Redo the last operation", triggered=self.redo) self.cutAct = QtGui.QAction("Cu&t", self, shortcut=QtGui.QKeySequence.Cut, statusTip="Cut the current selection's contents to the clipboard", triggered=self.cut) self.copyAct = QtGui.QAction("&Copy", self, shortcut=QtGui.QKeySequence.Copy, statusTip="Copy the current selection's contents to the clipboard", triggered=self.copy) self.pasteAct = QtGui.QAction("&Paste", self, shortcut=QtGui.QKeySequence.Paste, statusTip="Paste the clipboard's contents into the current selection", triggered=self.paste) self.boldAct = QtGui.QAction("&Bold", self, checkable=True, shortcut="Ctrl+B", statusTip="Make the text bold", triggered=self.bold) boldFont = self.boldAct.font() boldFont.setBold(True) self.boldAct.setFont(boldFont) self.italicAct = QtGui.QAction("&Italic", self, checkable=True, shortcut="Ctrl+I", statusTip="Make the text italic", triggered=self.italic) italicFont = self.italicAct.font() italicFont.setItalic(True) self.italicAct.setFont(italicFont) self.setLineSpacingAct = QtGui.QAction("Set &Line Spacing...", self, statusTip="Change the gap between the lines of a paragraph", triggered=self.setLineSpacing) self.setParagraphSpacingAct = QtGui.QAction( "Set &Paragraph Spacing...", self, statusTip="Change the gap between paragraphs", triggered=self.setParagraphSpacing) self.aboutAct = QtGui.QAction("&About", self, statusTip="Show the application's About box", triggered=self.about) self.aboutQtAct = QtGui.QAction("About &Qt", self, statusTip="Show the Qt library's About box", triggered=self.aboutQt) self.aboutQtAct.triggered.connect(QtGui.qApp.aboutQt) self.leftAlignAct = QtGui.QAction("&Left Align", self, checkable=True, shortcut="Ctrl+L", statusTip="Left align the selected text", triggered=self.leftAlign) self.rightAlignAct = QtGui.QAction("&Right Align", self, checkable=True, shortcut="Ctrl+R", statusTip="Right align the selected text", triggered=self.rightAlign) self.justifyAct = QtGui.QAction("&Justify", self, checkable=True, shortcut="Ctrl+J", statusTip="Justify the selected text", triggered=self.justify) self.centerAct = QtGui.QAction("&Center", self, checkable=True, shortcut="Ctrl+C", statusTip="Center the selected text", triggered=self.center) self.alignmentGroup = QtGui.QActionGroup(self) self.alignmentGroup.addAction(self.leftAlignAct) self.alignmentGroup.addAction(self.rightAlignAct) self.alignmentGroup.addAction(self.justifyAct) self.alignmentGroup.addAction(self.centerAct) self.leftAlignAct.setChecked(True)
def createActions(self): self.openSettingsAct = QtGui.QAction("&Open Application Settings...", self, shortcut="Ctrl+O", triggered=self.openSettings) self.openIniFileAct = QtGui.QAction("Open I&NI File...", self, shortcut="Ctrl+N", triggered=self.openIniFile) self.openPropertyListAct = QtGui.QAction( "Open Mac &Property List...", self, shortcut="Ctrl+P", triggered=self.openPropertyList) if sys.platform != 'darwin': self.openPropertyListAct.setEnabled(False) self.openRegistryPathAct = QtGui.QAction( "Open Windows &Registry Path...", self, shortcut="Ctrl+G", triggered=self.openRegistryPath) if sys.platform != 'win32': self.openRegistryPathAct.setEnabled(False) self.refreshAct = QtGui.QAction("&Refresh", self, shortcut="Ctrl+R", enabled=False, triggered=self.settingsTree.refresh) self.exitAct = QtGui.QAction("E&xit", self, shortcut="Ctrl+Q", triggered=self.close) self.autoRefreshAct = QtGui.QAction("&Auto-Refresh", self, shortcut="Ctrl+A", checkable=True, enabled=False) self.autoRefreshAct.triggered[bool].connect( self.settingsTree.setAutoRefresh) self.autoRefreshAct.triggered[bool].connect( self.refreshAct.setDisabled) self.fallbacksAct = QtGui.QAction("&Fallbacks", self, shortcut="Ctrl+F", checkable=True, enabled=False) self.fallbacksAct.triggered[bool].connect( self.settingsTree.setFallbacksEnabled) self.aboutAct = QtGui.QAction("&About", self, triggered=self.about) self.aboutQtAct = QtGui.QAction("About &Qt", self, triggered=QtGui.qApp.aboutQt)