本文整理汇总了Python中PyQt5.QtWidgets.QMenuBar.addMenu方法的典型用法代码示例。如果您正苦于以下问题:Python QMenuBar.addMenu方法的具体用法?Python QMenuBar.addMenu怎么用?Python QMenuBar.addMenu使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QMenuBar
的用法示例。
在下文中一共展示了QMenuBar.addMenu方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_menubar
# 需要导入模块: from PyQt5.QtWidgets import QMenuBar [as 别名]
# 或者: from PyQt5.QtWidgets.QMenuBar import addMenu [as 别名]
def setup_menubar(self):
menu_bar = QMenuBar()
file_menu = menu_bar.addMenu("&File")
file_menu.addAction(self.new_project_action)
file_menu.addAction(self.show_settings_action)
file_menu.addSeparator()
file_menu.addAction(self.quit_action)
view_menu = menu_bar.addMenu("&View")
dockWidgets = self.findChildren(QDockWidget)
for widget in dockWidgets:
view_menu.addAction(widget.toggleViewAction())
debug_menu = menu_bar.addMenu("&Debug")
debug_menu.addAction(self.start_listening_action)
debug_menu.addAction(self.stop_listening_action)
debug_menu.addSeparator()
debug_menu.addAction(self.stop_debug_action)
debug_menu.addAction(self.detach_debug_action)
debug_menu.addSeparator()
debug_menu.addAction(self.run_debug_action)
debug_menu.addAction(self.step_over_action)
debug_menu.addAction(self.step_into_action)
debug_menu.addAction(self.step_out_action)
self.setMenuBar(menu_bar)
示例2: __init__
# 需要导入模块: from PyQt5.QtWidgets import QMenuBar [as 别名]
# 或者: from PyQt5.QtWidgets.QMenuBar import addMenu [as 别名]
def __init__(self, app):
QMainWindow.__init__(self, None)
self.l.debug('Initializing MainWindow ...')
self.setWindowTitle('MynPad')
app.setWindowIcon(QIcon(':/icons/mynpad.png'))
if os.name == 'nt':
# On Windows, make sure to use a unique Application User Model Id, otherwise
# Windows shows the default python icon in the taskbar
# see http://stackoverflow.com/questions/1551605/how-to-set-applications-taskbar-icon-in-windows-7
myappid = 'afester.mynpad'
import ctypes; ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
self.theApplication = app
app.aboutToQuit.connect(self.saveState)
# read the local configuration file
iniPath = 'mynpad.ini'
if not os.path.exists(iniPath):
iniPath = os.path.join(expanduser("~"), iniPath)
self.settings = Settings(iniPath)
self.settings.load()
# Set up the menu bar
menuBar = QMenuBar(self)
exitAction = QAction("Exit", self, triggered=self.theApplication.exit)
fileMenu = menuBar.addMenu("&File")
fileMenu.addAction(exitAction)
aboutAction = QAction("About ...", self, triggered = self.handleAbout)
helpMenu = menuBar.addMenu("&Help")
helpMenu.addAction(aboutAction)
self.setMenuBar(menuBar)
# Setup the status bar
self.statusBar = QStatusBar()
self.statusBar.showMessage("Ready.")
self.setStatusBar(self.statusBar)
self.mainWidget = CentralWidget(self, self.settings)
self.mainWidget.updateWindowTitle.connect(self.updateWindowTitle)
self.setCentralWidget(self.mainWidget)
# Reset main window size and position
pos = self.settings.getMainWindowPos()
self.move(pos.x(), pos.y())
size = self.settings.getMainWindowSize()
self.resize(size)
# initialize the browser tree (add the top nodes and expand the saved path)
self.mainWidget.browserWidget.initialize()
示例3: menubar
# 需要导入模块: from PyQt5.QtWidgets import QMenuBar [as 别名]
# 或者: from PyQt5.QtWidgets.QMenuBar import addMenu [as 别名]
def menubar():
"""Return a newly created parent-less menu bar that's used when there is no main window."""
m = QMenuBar()
m.addMenu(menu_file(m))
m.addMenu(menu_edit(m))
m.addMenu(menu_window(m))
m.addMenu(menu_sessions(m))
m.addMenu(menu_help(m))
return m
示例4: initUI
# 需要导入模块: from PyQt5.QtWidgets import QMenuBar [as 别名]
# 或者: from PyQt5.QtWidgets.QMenuBar import addMenu [as 别名]
def initUI(self):
QToolTip.setFont(QFont('SansSerif', 10))
self.setToolTip('This is a <b>QWidget</b> widget.')
#quitBtn = QPushButton('Quit', self)
#quitBtn.clicked.connect(self.quitBtnEvent())
#quitBtn.clicked.connect(QCoreApplication.instance().quit)
#quitBtn.setToolTip('This is a <b>QPushButton</b> widget.')
#quitBtn.resize(quitBtn.sizeHint())
exitAction = QAction(QIcon('application-exit-4.png'), '&Exit', self)
exitAction.setShortcut('Alt+F4')
exitAction.setStatusTip('Exit Application')
exitAction.triggered.connect(qApp.quit)
menuBar = QMenuBar()
fileMenu = menuBar.addMenu('&File')
fileMenu.addAction(exitAction)
fileMenu.resize(fileMenu.sizeHint())
toolBar = QToolBar(self)
toolBar.addAction(exitAction)
#toolBar.resize(toolBar.sizeHint())
toolBar.setFixedHeight(60)
hozLine = QFrame()
hozLine.setFrameStyle(QFrame.HLine)
#hozLine.setSizePolicy(QSizePolicy.Minimum,QSizePolicy.Expanding)
statusBar = QStatusBar(self)
statusBar.showMessage('Ready')
grid = QGridLayout()
lbl_1 = QLabel('1,1')
lbl_2 = QLabel('1,2')
lbl_3 = QLabel('2,1')
lbl_4 = QLabel('2,2')
grid.addWidget(lbl_1, 1, 1)
grid.addWidget(lbl_2, 1, 2)
grid.addWidget(lbl_3, 2, 1)
grid.addWidget(lbl_4, 2, 2)
vbox = QVBoxLayout()
vbox.addWidget(menuBar)
vbox.addWidget(hozLine)
vbox.addWidget(toolBar)
# vbox.addWidget(hozLine)
vbox.addLayout(grid)
vbox.addStretch(1)
vbox.addWidget(statusBar)
self.setLayout(vbox)
self.setGeometry(300, 300, 500, 500)
self.setWindowTitle('Photos')
self.setWindowIcon(QIcon('camera-photo-5.png'))
self.center()
self.show()
示例5: setupUI
# 需要导入模块: from PyQt5.QtWidgets import QMenuBar [as 别名]
# 或者: from PyQt5.QtWidgets.QMenuBar import addMenu [as 别名]
def setupUI(self):
menu_bar = QMenuBar()
file = menu_bar.addMenu("&File")
help = menu_bar.addMenu("&Help")
build = menu_bar.addMenu("&Build")
exit = menu_bar.addMenu("&Exit")
tabs = QTabWidget()
centerwidget = QWidget()
vshadertab = QWidget()
fshadertab = QWidget()
vshadertab_layout = QVBoxLayout(vshadertab)
fshadertab_layout = QVBoxLayout(fshadertab)
fshadereditor = GLSLEditor()
vshadereditor = GLSLEditor()
fshadertab_layout.addWidget(fshadereditor)
vshadertab_layout.addWidget(vshadereditor)
tabs.addTab(vshadertab, "Vertex Shader")
tabs.addTab(fshadertab, "Fragment Shader")
vbox = QVBoxLayout()
vbox.addWidget(menu_bar)
vbox.addWidget(tabs)
centerwidget.setLayout(vbox)
self.setCentralWidget(centerwidget)
pass
示例6: SubtleMainWindow
# 需要导入模块: from PyQt5.QtWidgets import QMenuBar [as 别名]
# 或者: from PyQt5.QtWidgets.QMenuBar import addMenu [as 别名]
class SubtleMainWindow(QMainWindow):
def __init__(self, paths=[]):
QMainWindow.__init__( self )
self.setWindowTitle( 'Subtle' )
self.setAcceptDrops( True )
self._menu = QMenuBar( self )
fileMenu = self._menu.addMenu( '&File' )
fileMenu.addAction( QAction('&Open', fileMenu) )
close = QAction('&Quit', fileMenu)
close.setShortcut( QKeySequence(QKeySequence.Quit) )
close.triggered.connect( self._close_action )
fileMenu.addAction( close )
self.setMenuBar( self._menu )
self._tree = SubtleTreeWidget(self, paths_to_items_list(self, paths))
self.setCentralWidget( self._tree )
@QtCore.pyqtSlot()
def _close_action(self):
self.close()
def dragEnterEvent(self, event):
event.acceptProposedAction()
def dropEvent(self, event):
items = paths_to_items_list(self._tree, event.mimeData().urls())
self._tree.addTopLevelItems( items )
self.update()
event.acceptProposedAction()
def update(self):
items = [ self._tree.itemAt(i, 0)
for i in range(0, self._tree.topLevelItemCount()) ]
for item in items:
print( 'item {}'.format(item.data(0, SubtleTreeWidget.ITEM_ROLE)) )
示例7: AvailableSizes
# 需要导入模块: from PyQt5.QtWidgets import QMenuBar [as 别名]
# 或者: from PyQt5.QtWidgets.QMenuBar import addMenu [as 别名]
class AvailableSizes(QDialog):
def __init__(self):
super(AvailableSizes, self).__init__()
self.createCombos()
self.createHeader()
#self.createMenuBar()
self.printOut = QTextEdit()
self.printOut.setFont(QFont('Helvetica', 11, QFont.Bold))
self.printOut.setReadOnly(True)
mainLayout = QVBoxLayout()
#mainLayout.setMenuBar(self.menuBar)
mainLayout.addWidget(self.frmHeader)
mainLayout.addWidget(self.grpBox)
mainLayout.addWidget(self.printOut)
#mainLayout.setAlignment(self.frmHeader, Qt.AlignRight)
self.setLayout(mainLayout)
#self.setWindowTitle("Available Sizes")
self.setWindowFlags(Qt.FramelessWindowHint)
bgColor = QPalette()
bgColor.setColor(self.backgroundRole(), Qt.gray)
self.setPalette(bgColor)
self.setWindowIcon(QIcon('icon/PS_Icon.png'))
self.cbSku.setFocus()
def createHeader(self):
blk = QPalette()
blk.setColor(blk.Foreground, Qt.white)
lblTitle = QLabel("Availability Checker")
lblTitle.setFont(QFont("Times", 12, QFont.Bold ))
lblTitle.setPalette(blk)
btnClose = QToolButton()
btnClose.setIcon(QIcon("icon\size_exit.png"))
btnClose.setAutoRaise(True)
btnClose.setIconSize(QSize(25,25))
btnClose.clicked.connect(lambda: self.close())
hbHeader = QHBoxLayout()
hbHeader.addWidget(lblTitle)
hbHeader.addWidget(btnClose)
hbHeader.setContentsMargins(0, 0, 0, 0)
self.frmHeader = QFrame()
self.frmHeader.setLayout(hbHeader)
def createCombos(self):
cbFont = QFont("Times", 8, QFont.Bold)
designs = self.getDesigns()
self.grpBox = QGroupBox()
self.grpBox.setFont(QFont('Times', 10, QFont.Bold))
layout = QFormLayout()
self.cbSku = QComboBox()
self.cbSku.addItem("Designs")
self.cbSku.addItems(designs)
self.cbSku.setFont(cbFont)
self.cbSku.currentIndexChanged.connect(self.skuChanged)
self.cbStyle = QComboBox()
self.cbStyle.addItem("Styles")
self.cbStyle.setFont(cbFont)
self.cbStyle.currentIndexChanged.connect(self.styleChanged)
layout.addRow(QLabel("Design:"), self.cbSku)
layout.addRow(QLabel("Style:"), self.cbStyle)
self.grpBox.setLayout(layout)
def skuChanged(self):
if self.cbStyle.count() > 0:
self.cbStyle.clear()
self.cbStyle.addItem("Style")
self.cbStyle.setCurrentIndex(0)
styles = self.getStyles(self.cbSku.currentText())
else:
styles = self.getStyles(self.cbSku.currentText())
self.cbStyle.addItems(styles)
def styleChanged(self):
self.printOut.clear()
sizes = self.getSizes(self.cbSku.currentText(), self.cbStyle.currentText())
if self.cbStyle.currentText() != "Styles":
for i in sizes:
self.printOut.insertPlainText(i + '\n')
def createMenuBar(self):
self.menuBar = QMenuBar()
self.fileMenu = QMenu("&File", self)
self.exitAction = self.fileMenu.addAction("E&xit")
self.menuBar.addMenu(self.fileMenu)
#.........这里部分代码省略.........
示例8: PDFAreaSelectorDlg
# 需要导入模块: from PyQt5.QtWidgets import QMenuBar [as 别名]
# 或者: from PyQt5.QtWidgets.QMenuBar import addMenu [as 别名]
#.........这里部分代码省略.........
self.exitAct = QAction("E&xit", self)
self.exitAct.setShortcut("Ctrl+Q")
self.exitAct.triggered.connect(self.close)
self.zoomInAct = QAction("Zoom &In (25%)", self)
self.zoomInAct.setShortcut("Ctrl++")
self.zoomInAct.setEnabled(False)
self.zoomInAct.triggered.connect(self.zoomIn)
self.zoomOutAct = QAction("Zoom &Out (25%)", self)
self.zoomOutAct.setShortcut("Ctrl+-")
self.zoomOutAct.setEnabled(False)
self.zoomOutAct.triggered.connect(self.zoomOut)
self.normalSizeAct = QAction("&Normal Size", self)
self.normalSizeAct.setShortcut("Ctrl+S")
self.normalSizeAct.setEnabled(False)
self.normalSizeAct.triggered.connect(self.normalSize)
self.fitToWindowAct = QAction("&Fit to Window", self)
self.fitToWindowAct.setEnabled(False)
self.fitToWindowAct.setCheckable(True)
self.fitToWindowAct.setShortcut("Ctrl+F")
self.fitToWindowAct.triggered.connect(self.fitToWindow)
self.nextPageAct = QAction("&Next page", self)
self.nextPageAct.setEnabled(True)
self.nextPageAct.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_Right))
self.nextPageAct.triggered.connect(self.nextPage)
self.previousPageAct = QAction("&Previous page", self)
self.previousPageAct.setEnabled(True)
self.previousPageAct.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_Left))
self.previousPageAct.triggered.connect(self.previousPage)
def createMenus(self):
self.menuBar = QMenuBar(self)
self.fileMenu = QMenu("&File", self)
self.fileMenu.addAction(self.exitAct)
self.viewMenu = QMenu("&View", self)
self.viewMenu.addAction(self.zoomInAct)
self.viewMenu.addAction(self.zoomOutAct)
self.viewMenu.addAction(self.normalSizeAct)
self.viewMenu.addSeparator()
self.viewMenu.addAction(self.fitToWindowAct)
self.viewMenu.addSeparator()
self.viewMenu.addAction(self.nextPageAct)
self.viewMenu.addAction(self.previousPageAct)
self.menuBar.addMenu(self.fileMenu)
self.menuBar.addMenu(self.viewMenu)
def updateActions(self):
self.zoomInAct.setEnabled(not self.fitToWindowAct.isChecked())
self.zoomOutAct.setEnabled(not self.fitToWindowAct.isChecked())
self.normalSizeAct.setEnabled(not self.fitToWindowAct.isChecked())
def scaleImage(self, factor):
assert(self.imageLabel.pixmap())
self.scaleFactor *= factor
self.imageLabel.resize(self.scaleFactor * self.imageLabel.pixmap().size())
self.adjustScrollBar(self.scrollArea.horizontalScrollBar(), factor)
self.adjustScrollBar(self.scrollArea.verticalScrollBar(), factor)
self.zoomInAct.setEnabled(self.scaleFactor < 3.0)
self.zoomOutAct.setEnabled(self.scaleFactor > 0.333)
def adjustScrollBar(self, scrollBar, factor):
scrollBar.setValue(int(factor * scrollBar.value()
+ ((factor - 1) * scrollBar.pageStep()/2)))
def nextPage(self):
if self._parent.currentPageInd < len(self._parent.pages)-1:
self._parent.currentPageInd += 1
self.loadImage()
self.noPageTxt.setText(str(self._parent.currentPageInd+1))
def previousPage(self):
if self._parent.currentPageInd > 0:
self._parent.currentPageInd -= 1
self.loadImage()
self.noPageTxt.setText(str(self._parent.currentPageInd+1))
示例9: GlobalMenu
# 需要导入模块: from PyQt5.QtWidgets import QMenuBar [as 别名]
# 或者: from PyQt5.QtWidgets.QMenuBar import addMenu [as 别名]
class GlobalMenu(QWidget):
new_window_signal = pyqtSignal()
rename_signal = pyqtSignal()
file_signal = pyqtSignal()
drawer_signal = pyqtSignal()
clean_up_signal = pyqtSignal()
delete_signal = pyqtSignal()
trash_action_signal = pyqtSignal()
def __init__(self, parent=None):
super(GlobalMenu, self).__init__(parent)
self.menubar = QMenuBar()
file_menu = self.menubar.addMenu('File')
edit_menu = self.menubar.addMenu('Edit')
about_action = QAction('About', self)
preferences_action = QAction('Preferences', self)
preferences_action.setShortcut('Ctrl+Shift+P')
quit_action = QAction('Quit', self)
quit_action.setShortcut('Ctrl+Q')
file_action = QAction('Create file', self)
file_action.setShortcut('Ctrl+Shift+N')
drawer_action = QAction('Create drawer', self)
drawer_action.setShortcut('Ctrl+N')
requester_action = QAction('Requester', self)
requester_action.setShortcut('Ctrl+O')
parent_action = QAction('Open Parent', self)
parent_action.setShortcut('Ctrl+P')
info_action = QAction('Get info', self)
info_action.setShortcut('Ctrl+I')
rename_action = QAction('Rename', self)
rename_action.setShortcut('Ctrl+R')
copy_action = QAction('Copy', self)
copy_action.setShortcut('Ctrl+C')
paste_action = QAction('Paste', self)
paste_action.setShortcut('Ctrl+V')
clean_action = QAction('Clean Up', self)
clean_action.setShortcut('Ctrl+;')
delete_action = QAction('Move to Trash', self)
delete_action.setShortcut('Ctrl+Backspace')
trash_action = QAction('Empty trash', self)
trash_action.setShortcut('Ctrl+Shift+Backspace')
preferences_action.triggered.connect(self.preferences_action)
quit_action.triggered.connect(self.quit_action)
requester_action.triggered.connect(self.requester_action)
parent_action.triggered.connect(self.parent_action)
file_action.triggered.connect(self.file_action)
drawer_action.triggered.connect(self.drawer_action)
rename_action.triggered.connect(self.rename_action)
clean_action.triggered.connect(self.clean_action)
delete_action.triggered.connect(self.delete_action)
trash_action.triggered.connect(self.trash_action)
file_menu.addAction(requester_action)
file_menu.addAction(parent_action)
file_menu.addAction(info_action)
file_menu.addAction(about_action)
file_menu.addAction(quit_action)
edit_menu.addAction(preferences_action)
edit_menu.addAction(file_action)
edit_menu.addAction(drawer_action)
edit_menu.addAction(rename_action)
edit_menu.addAction(copy_action)
edit_menu.addAction(paste_action)
edit_menu.addAction(clean_action)
edit_menu.addAction(delete_action)
edit_menu.addAction(trash_action)
def quit_action(self):
print("quit action menu")
sys.exit(0)
def preferences_action(self):
print("preference action menu")
QProcess.startDetached("./prefs.py")
def requester_action(self):
print("requester action menu")
QProcess.startDetached("./requester.py")
def parent_action(self):
print("parent action menu")
self.new_window_signal.emit()
def file_action(self):
print("file action menu")
self.file_signal.emit()
def drawer_action(self):
print("drawer action menu")
self.drawer_signal.emit()
def rename_action(self):
print("rename action menu")
self.rename_signal.emit()
#.........这里部分代码省略.........
示例10: CellularAutomatonQt
# 需要导入模块: from PyQt5.QtWidgets import QMenuBar [as 别名]
# 或者: from PyQt5.QtWidgets.QMenuBar import addMenu [as 别名]
class CellularAutomatonQt(QWidget):
def __init__(self, cellular_automaton):
super().__init__()
self.speed = DEFAULT_SIMULATION_SPEED
self.cell_size = CELL_SIZE
self.cellular_automaton = cellular_automaton
self.num_of_cells_x = self.cellular_automaton.size_x
self.num_of_cells_y = self.cellular_automaton.size_y
self.run = False
self.setWindowTitle('Cellular automaton')
self.setToolTip('Select cell')
self.start_btn = QPushButton('Start', self)
self.start_btn.setToolTip('Start simulation')
self.clear_btn = QPushButton('Clear', self)
self.clear_btn.setToolTip('Clear board')
self.start_btn.clicked.connect(self.toggle)
self.clear_btn.clicked.connect(self.clean)
self.timer = QTimer(self)
self.timer.timeout.connect(self.paint_update)
self.slider = QSlider(Qt.Horizontal, self)
self.slider.setMinimum(MIN_SIMULATION_SPEED)
self.slider.setMaximum(MAX_SIMULATION_SPEED)
self.slider.setValue(DEFAULT_SIMULATION_SPEED)
self.slider.setToolTip('Speed of simulation')
self.slider.valueChanged.connect(self.set_value)
btn_layout = QHBoxLayout()
btn_layout.addWidget(self.start_btn)
btn_layout.addWidget(self.clear_btn)
layout = QVBoxLayout()
layout.setAlignment(Qt.AlignBottom)
layout.addLayout(btn_layout, Qt.AlignCenter)
layout.addWidget(self.slider, Qt.AlignCenter)
self.setLayout(layout)
self.menu_bar = QMenuBar(self)
self.add_menu_bar()
self.margin_left = MARGIN
self.margin_top = MARGIN
self.resize(WINDOW_X_SIZE, WINDOW_Y_SIZE)
self.setMinimumSize(WINDOW_X_SIZE, WINDOW_Y_SIZE)
self.resizeEvent = self.on_resize
def add_menu_bar(self):
exit_menu = self.menu_bar.addMenu('File')
conway_action = QAction('Conway Life Game', self)
cf = partial(self.set_automaton,
ConwayLifeOutflow(NUM_OF_CELLS_X, NUM_OF_CELLS_Y))
conway_action.triggered.connect(cf)
exit_menu.addAction(conway_action)
sand_action = QAction('Sand', self)
sf = partial(self.set_automaton, Sand(NUM_OF_CELLS_X, NUM_OF_CELLS_Y))
sand_action.triggered.connect(sf)
exit_menu.addAction(sand_action)
exit_action = QAction('Exit', self)
exit_action.triggered.connect(self.close)
exit_menu.addAction(exit_action)
def set_automaton(self, cellular_automaton):
self.cellular_automaton = cellular_automaton
self.num_of_cells_x = self.cellular_automaton.size_x
self.num_of_cells_y = self.cellular_automaton.size_y
self.repaint()
def on_resize(self, event):
"""Resize grid"""
width, height = self.width(), self.height()
new_x_cell_size = (width - MARGIN*2) // self.num_of_cells_x
new_y_cell_size = (height - MARGIN*2) // self.num_of_cells_y
self.cell_size = min(new_x_cell_size, new_y_cell_size)
self.margin_left = (width - self.cell_size*self.num_of_cells_x) // 2
self.margin_top = (height - self.cell_size*self.num_of_cells_y) // 2
self.repaint()
def set_value(self):
"""Set slider value"""
self.speed = self.slider.value()
if self.run:
self.timer.stop()
self.timer.start(self.speed)
def toggle(self):
"""Start simulation"""
if not self.run:
self.run = True
self.start_btn.setToolTip('End simulation')
self.start_btn.setText('End')
self.timer.start(self.speed)
else:
self.run = False
self.start_btn.setToolTip('Start')
self.start_btn.setText('Start simulation')
self.timer.stop()
#.........这里部分代码省略.........
示例11: init
# 需要导入模块: from PyQt5.QtWidgets import QMenuBar [as 别名]
# 或者: from PyQt5.QtWidgets.QMenuBar import addMenu [as 别名]
def init(self):
self.main_vbox = QVBoxLayout()
self.config_file=""
self.plot_token=None
self.labels=[]
self.fig = Figure(figsize=(2.5,2), dpi=100)
self.plot_id=[]
self.canvas = FigureCanvas(self.fig) # a gtk.DrawingArea
self.zero_frame_enable=False
self.zero_frame_list=[]
self.plot_title=""
self.gen_colors(1)
toolbar=QToolBar()
toolbar.setIconSize(QSize(48, 48))
self.tb_save = QAction(QIcon(os.path.join(get_image_file_path(),"save.png")), _("Save graph"), self)
self.tb_save.triggered.connect(self.callback_plot_save)
toolbar.addAction(self.tb_save)
self.tb_refresh = QAction(QIcon(os.path.join(get_image_file_path(),"refresh.png")), _("Refresh graph"), self)
self.tb_refresh .triggered.connect(self.callback_refresh)
toolbar.addAction(self.tb_refresh )
nav_bar=NavigationToolbar(self.canvas,self)
toolbar.addWidget(nav_bar)
self.fig.canvas.mpl_connect('motion_notify_event', self.mouse_move)
menubar = QMenuBar()
file_menu = menubar.addMenu("File")
self.menu_save=file_menu.addAction(_("&Save"))
self.menu_save.triggered.connect(self.callback_save)
self.menu_save_as=file_menu.addAction(_("&Save as"))
self.menu_save_as.triggered.connect(self.callback_plot_save)
key_menu = menubar.addMenu('&Key')
key_menu = menubar.addMenu('&Color')
self.menu_black=key_menu.addAction(_("&Black"))
self.menu_black.triggered.connect(self.callback_black)
self.menu_rainbow=key_menu.addAction(_("&Rainbow"))
self.menu_rainbow.triggered.connect(self.callback_rainbow)
axis_menu = menubar.addMenu('&Color')
menu=axis_menu.addAction(_("&Autoscale"))
menu.triggered.connect(self.callback_autoscale_y)
menu=axis_menu.addAction(_("&Set log scale y"))
menu.triggered.connect(self.callback_toggle_log_scale_y)
menu=axis_menu.addAction(_("&Set log scale x"))
menu.triggered.connect(self.callback_toggle_log_scale_x)
menu=axis_menu.addAction(_("&Set log scale x"))
menu.triggered.connect(self.callback_toggle_log_scale_x)
self.menu_rainbow=key_menu.addAction(_("&Label data"))
self.menu_rainbow.triggered.connect(self.callback_toggle_label_data)
math_menu = menubar.addMenu('&Math')
menu=math_menu.addAction(_("&Subtract first point"))
menu.triggered.connect(self.callback_toggle_subtract_first_point)
menu=math_menu.addAction(_("&Add min point"))
menu.triggered.connect(self.callback_toggle_add_min)
menu=math_menu.addAction(_("&Invert y-axis"))
menu.triggered.connect(self.callback_toggle_invert_y)
menu=math_menu.addAction(_("&Norm to 1.0 y"))
menu.triggered.connect(self.callback_normtoone_y)
menu=math_menu.addAction(_("&Norm to peak of all data"))
menu.triggered.connect(self.callback_norm_to_peak_of_all_data)
menu=math_menu.addAction(_("&Heat map"))
menu.triggered.connect(self.callback_set_heat_map)
menu=math_menu.addAction(_("&Heat map edit"))
menu.triggered.connect(self.callback_heat_map_edit)
menu=math_menu.addAction(_("&xy plot"))
menu.triggered.connect(self.callback_set_xy_plot)
self.main_vbox.addWidget(menubar)
self.main_vbox.addWidget(toolbar)
#.........这里部分代码省略.........
示例12: __init__
# 需要导入模块: from PyQt5.QtWidgets import QMenuBar [as 别名]
# 或者: from PyQt5.QtWidgets.QMenuBar import addMenu [as 别名]
def __init__(self):
QWidget.__init__(self)
self.setMinimumSize(1200, 700)
self.win_list=windows()
self.win_list.load()
self.win_list.set_window(self,"fxexperiments_window")
self.main_vbox = QVBoxLayout()
menubar = QMenuBar()
file_menu = menubar.addMenu('&File')
self.menu_close=file_menu.addAction(_("Close"))
self.menu_close.triggered.connect(self.callback_close)
self.menu_experiment=menubar.addMenu(_("Experiments"))
self.menu_experiment_new=self.menu_experiment.addAction(_("&New"))
self.menu_experiment_new.triggered.connect(self.callback_add_page)
self.menu_experiment_delete=self.menu_experiment.addAction(_("&Delete experiment"))
self.menu_experiment_delete.triggered.connect(self.callback_delete_page)
self.menu_experiment_rename=self.menu_experiment.addAction(_("&Rename experiment"))
self.menu_experiment_rename.triggered.connect(self.callback_rename_page)
self.menu_experiment_clone=self.menu_experiment.addAction(_("&Clone experiment"))
self.menu_experiment_clone.triggered.connect(self.callback_copy_page)
self.menu_help=menubar.addMenu(_("Help"))
self.menu_help_help=self.menu_help.addAction(_("Help"))
self.menu_help_help.triggered.connect(self.callback_help)
self.main_vbox.addWidget(menubar)
self.setWindowTitle(_("Frequency domain experiment editor - gpvdm"))
self.setWindowIcon(QIcon(os.path.join(get_image_file_path(),"spectrum.png")))
toolbar=QToolBar()
toolbar.setIconSize(QSize(48, 48))
self.new = QAction(QIcon(os.path.join(get_image_file_path(),"new.png")), _("New experiment"), self)
self.new.triggered.connect(self.callback_add_page)
toolbar.addAction(self.new)
self.new = QAction(QIcon(os.path.join(get_image_file_path(),"delete.png")), _("Delete experiment"), self)
self.new.triggered.connect(self.callback_delete_page)
toolbar.addAction(self.new)
self.clone = QAction(QIcon(os.path.join(get_image_file_path(),"clone.png")), _("Clone experiment"), self)
self.clone.triggered.connect(self.callback_copy_page)
toolbar.addAction(self.clone)
self.clone = QAction(QIcon(os.path.join(get_image_file_path(),"rename.png")), _("Rename experiment"), self)
self.clone.triggered.connect(self.callback_rename_page)
toolbar.addAction(self.clone)
spacer = QWidget()
spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
toolbar.addWidget(spacer)
self.help = QAction(QIcon(os.path.join(get_image_file_path(),"help.png")), 'Hide', self)
self.help.setStatusTip(_("Close"))
self.help.triggered.connect(self.callback_help)
toolbar.addAction(self.help)
self.main_vbox.addWidget(toolbar)
self.notebook = QTabWidget()
self.notebook.setTabBar(QHTabBar())
self.notebook.setTabPosition(QTabWidget.West)
self.notebook.setMovable(True)
self.load_tabs()
self.main_vbox.addWidget(self.notebook)
self.status_bar=QStatusBar()
self.main_vbox.addWidget(self.status_bar)
self.setLayout(self.main_vbox)
示例13:
# 需要导入模块: from PyQt5.QtWidgets import QMenuBar [as 别名]
# 或者: from PyQt5.QtWidgets.QMenuBar import addMenu [as 别名]
#!/usr/bin/env python
# -*- coding:utf-8 -*-
__author__ = 'tim'
from PyQt5.QtWidgets import QApplication,QMenuBar
import sys
app=QApplication(sys.argv)
menubar=QMenuBar() #QMenubar是横向菜单栏
files=menubar.addMenu('File') #添加菜单
menubar.addMenu('Edit')
menubar.addMenu('View')
menubar.addMenu('Code')
menubar.addMenu('Run')
menubar.addMenu('Tools')
files.addAction('Open') #添加菜单下子菜单
project=files.addAction('New Project')
Exit=files.addAction('Exit')
files.addActions([project,Exit]) ##添加1组子菜单
menubar.show()
sys.exit(app.exec_())
示例14: DragWidget
# 需要导入模块: from PyQt5.QtWidgets import QMenuBar [as 别名]
# 或者: from PyQt5.QtWidgets.QMenuBar import addMenu [as 别名]
class DragWidget(QWidget):
spacerX = 16
spacerY = 16
clipicon = None
windowclass_signal = pyqtSignal(str)
query = pyqtSignal()
def __init__(self, path, parent=None):
super(DragWidget, self).__init__(parent)
self.setMinimumSize(400, 200)
self.setAcceptDrops(True)
self.menubar = QMenuBar()
fileMenu = self.menubar.addMenu('File')
editMenu = self.menubar.addMenu('Edit')
exitAction = QAction('Open', self)
prefAction = QAction('Pref', self)
fileMenu.addAction(exitAction)
editMenu.addAction(prefAction)
self.path = path
self.icons = []
# self.clipicon = None
for name in os.listdir(path):
icon_widget = IconWidget(self, name=name, path=self.path)
icon_widget.new_window.connect(self.windowclass_signal.emit)
icon_widget.clipboard.connect(self.on_clipboard)
self.icons.append(icon_widget)
# self.icons[-1].move(DragWidget.spacerX, DragWidget.spacerY)
self.icons[-1].setAttribute(Qt.WA_DeleteOnClose)
self.clean_up()
# self.updateScrollArea()
def updateScrollArea(self):
""" set the dimension of the widget """
iconx = []
icony = []
for item in self.icons:
iconx.append(item.x())
icony.append(item.y())
self.setMinimumWidth(max(iconx)+75)
self.setMinimumHeight(max(icony)+75)
def dragEnterEvent(self, event):
event.accept()
def dragMoveEvent(self, event):
event.accept()
def dropEvent(self, event):
event.accept()
if event.mimeData().hasFormat("application/x-icon"):
name = event.source().name
icon_widget = IconWidget(self, name=name, path=self.path)
icon_widget.new_window.connect(self.windowclass_signal.emit)
self.icons.append(icon_widget)
self.icons[-1].move(event.pos().x(), event.pos().y())
self.icons[-1].show()
self.updateScrollArea()
def mousePressEvent(self, event):
if event.buttons() == Qt.LeftButton:
for item in self.icons:
item.reset_selection()
if event.buttons() == Qt.RightButton:
menu = QMenu("Window Menu")
clean = menu.addAction("Clean Up")
clean.triggered.connect(self.clean_up)
if DragWidget.clipicon is not None:
paste = menu.addAction("Paste")
paste.triggered.connect(self.paste_icon)
eventpos = event.screenPos()
qpoint = QPoint(eventpos.x(), eventpos.y())
menu.exec_(qpoint)
def mouseDoubleClickEvent(self, event):
print("Double Click")
self.query.emit()
def clean_up(self):
print("clean_up method")
# print("sw=", self.window().width())
for item in self.icons:
item.move(DragWidget.spacerX, DragWidget.spacerY)
# initial icon placement
DragWidget.spacerX += 100
if DragWidget.spacerX + 100 > self.window().width():
DragWidget.spacerY += 75
DragWidget.spacerX = 16
# reset placement values
DragWidget.spacerX = 16
DragWidget.spacerY = 16
self.updateScrollArea()
def paste_icon(self):
print("---")
print("srce=", self.clipicon.path + "/" + self.clipicon.name)
# print("res=", self.clipicon.path + "/" + self.clipicon.name)
print("dest=", self.path + "/")
# if os.path.isdir(os.path.join(self.clipicon.path, self.clipicon.name)):
#.........这里部分代码省略.........
示例15: __init__
# 需要导入模块: from PyQt5.QtWidgets import QMenuBar [as 别名]
# 或者: from PyQt5.QtWidgets.QMenuBar import addMenu [as 别名]
#.........这里部分代码省略.........
self.defaultMarkup = mc
if len(availableMarkups) > 1:
self.chooseGroup = QActionGroup(self)
markupActions = []
for markup in availableMarkups:
markupAction = self.act(markup.name, trigbool=self.markupFunction(markup))
if markup == self.defaultMarkup:
markupAction.setChecked(True)
self.chooseGroup.addAction(markupAction)
markupActions.append(markupAction)
self.actionBold = self.act(self.tr('Bold'), shct=QKeySequence.Bold,
trig=lambda: self.insertChars('**'))
self.actionItalic = self.act(self.tr('Italic'), shct=QKeySequence.Italic,
trig=lambda: self.insertChars('*'))
self.actionUnderline = self.act(self.tr('Underline'), shct=QKeySequence.Underline,
trig=lambda: self.insertTag('u'))
self.usefulTags = ('a', 'big', 'center', 'img', 's', 'small', 'span',
'table', 'td', 'tr', 'u')
self.usefulChars = ('deg', 'divide', 'dollar', 'hellip', 'laquo', 'larr',
'lsquo', 'mdash', 'middot', 'minus', 'nbsp', 'ndash', 'raquo',
'rarr', 'rsquo', 'times')
self.tagsBox = QComboBox(self.editBar)
self.tagsBox.addItem(self.tr('Tags'))
self.tagsBox.addItems(self.usefulTags)
self.tagsBox.activated.connect(self.insertTag)
self.symbolBox = QComboBox(self.editBar)
self.symbolBox.addItem(self.tr('Symbols'))
self.symbolBox.addItems(self.usefulChars)
self.symbolBox.activated.connect(self.insertSymbol)
self.updateStyleSheet()
menubar = QMenuBar(self)
menubar.setGeometry(QRect(0, 0, 800, 25))
self.setMenuBar(menubar)
menuFile = menubar.addMenu(self.tr('File'))
menuEdit = menubar.addMenu(self.tr('Edit'))
menuHelp = menubar.addMenu(self.tr('Help'))
menuFile.addAction(self.actionNew)
menuFile.addAction(self.actionOpen)
self.menuRecentFiles = menuFile.addMenu(self.tr('Open recent'))
self.menuRecentFiles.aboutToShow.connect(self.updateRecentFiles)
menuFile.addMenu(self.menuRecentFiles)
menuFile.addAction(self.actionShow)
menuFile.addAction(self.actionSetEncoding)
menuFile.addAction(self.actionReload)
menuFile.addSeparator()
menuFile.addAction(self.actionSave)
menuFile.addAction(self.actionSaveAs)
menuFile.addSeparator()
menuFile.addAction(self.actionNextTab)
menuFile.addAction(self.actionPrevTab)
menuFile.addSeparator()
menuExport = menuFile.addMenu(self.tr('Export'))
menuExport.addAction(self.actionSaveHtml)
menuExport.addAction(self.actionOdf)
menuExport.addAction(self.actionPdf)
if self.extensionActions:
menuExport.addSeparator()
for action, mimetype in self.extensionActions:
menuExport.addAction(action)
menuExport.aboutToShow.connect(self.updateExtensionsVisibility)
menuFile.addAction(self.actionPrint)
menuFile.addAction(self.actionPrintPreview)
menuFile.addSeparator()
menuFile.addAction(self.actionQuit)
menuEdit.addAction(self.actionUndo)
menuEdit.addAction(self.actionRedo)