本文整理汇总了Python中qtpy.QtWidgets.QAction.setStatusTip方法的典型用法代码示例。如果您正苦于以下问题:Python QAction.setStatusTip方法的具体用法?Python QAction.setStatusTip怎么用?Python QAction.setStatusTip使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtWidgets.QAction
的用法示例。
在下文中一共展示了QAction.setStatusTip方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_action
# 需要导入模块: from qtpy.QtWidgets import QAction [as 别名]
# 或者: from qtpy.QtWidgets.QAction import setStatusTip [as 别名]
def create_action(parent, text, shortcut=None, icon=None, tip=None,
toggled=None, triggered=None, data=None, menurole=None,
context=Qt.WindowShortcut):
"""Create a QAction"""
action = QAction(text, parent)
if triggered is not None:
action.triggered.connect(triggered)
if toggled is not None:
action.toggled.connect(toggled)
action.setCheckable(True)
if icon is not None:
if is_text_string(icon):
icon = get_icon(icon)
action.setIcon(icon)
if shortcut is not None:
action.setShortcut(shortcut)
if tip is not None:
action.setToolTip(tip)
action.setStatusTip(tip)
if data is not None:
action.setData(to_qvariant(data))
if menurole is not None:
action.setMenuRole(menurole)
#TODO: Hard-code all shortcuts and choose context=Qt.WidgetShortcut
# (this will avoid calling shortcuts from another dockwidget
# since the context thing doesn't work quite well with these widgets)
action.setShortcutContext(context)
return action
示例2: create_action
# 需要导入模块: from qtpy.QtWidgets import QAction [as 别名]
# 或者: from qtpy.QtWidgets.QAction import setStatusTip [as 别名]
def create_action(parent, text, shortcut=None, icon=None, tip=None,
toggled=None, triggered=None, data=None, menurole=None,
context=Qt.WindowShortcut):
"""Create a QAction"""
action = QAction(text, parent)
if triggered is not None:
action.triggered.connect(triggered)
if toggled is not None:
action.toggled.connect(toggled)
action.setCheckable(True)
if icon is not None:
if is_text_string(icon):
icon = get_icon(icon)
action.setIcon(icon)
if tip is not None:
action.setToolTip(tip)
action.setStatusTip(tip)
if data is not None:
action.setData(to_qvariant(data))
if menurole is not None:
action.setMenuRole(menurole)
# Workround for Mac because setting context=Qt.WidgetShortcut
# there doesn't have any effect
if sys.platform == 'darwin':
action._shown_shortcut = None
if context == Qt.WidgetShortcut:
if shortcut is not None:
action._shown_shortcut = shortcut
else:
# This is going to be filled by
# main.register_shortcut
action._shown_shortcut = 'missing'
else:
if shortcut is not None:
action.setShortcut(shortcut)
action.setShortcutContext(context)
else:
if shortcut is not None:
action.setShortcut(shortcut)
action.setShortcutContext(context)
return action
示例3: create_menus
# 需要导入模块: from qtpy.QtWidgets import QAction [as 别名]
# 或者: from qtpy.QtWidgets.QAction import setStatusTip [as 别名]
def create_menus(self):
exit_action = QAction('&Exit', self)
# exitAction = QtGui.QAction(QtGui.QIcon('exit.png'), '&Exit', self)
exit_action.setShortcut('Ctrl+Q')
exit_action.setStatusTip('Exit application')
exit_action.triggered.connect(qApp.quit)
menubar = self.menuBar()
file_menu = menubar.addMenu('&File')
open_menu = file_menu.addMenu('&Open')
open_file_action = QAction('&File', self)
open_file_action.triggered.connect(self.openFile)
open_dir_action = QAction('&Directory', self)
open_dir_action.triggered.connect(self.openDirDialog)
open_menu.addAction(open_file_action)
open_menu.addAction(open_dir_action)
file_menu.addAction(exit_action)
示例4: __init__
# 需要导入模块: from qtpy.QtWidgets import QAction [as 别名]
# 或者: from qtpy.QtWidgets.QAction import setStatusTip [as 别名]
def __init__(self, *args, **kwargs):
QMainWindow.__init__(self, *args, **kwargs)
QtGuiApplication.__init__(self, self)
QtUI.__init__(self, self)
self.menubar = self.menuBar()
self.fileMenu = self.menubar.addMenu('&File')
openAction = QAction(QIcon('open.png'), '&Open...', self)
openAction.setShortcut('Ctrl+O')
openAction.setStatusTip('Open...')
openAction.triggered.connect(self.actionOpen)
exitAction = QAction("&Exit", self, shortcut='Ctrl+Q', statusTip='Exit', triggered=app.exit)
self.fileMenu.addAction(openAction)
self.fileMenu.addSeparator()
sep = self.fileMenu.addSeparator()
self.fileMenu.addAction(exitAction)
self.recentInMenu = RecentInMenu(self, self.fileMenu, self.open, sep)
self.show()
示例5: __init__
# 需要导入模块: from qtpy.QtWidgets import QAction [as 别名]
# 或者: from qtpy.QtWidgets.QAction import setStatusTip [as 别名]
def __init__(self, parent=None):
super(ManiWindow, self).__init__(parent)
self.canvas = qtViewer3d(self)
# self.setWindowTitle("pythonOCC-%s 3d viewer" % VERSION)
self.canvas.InitDriver()
bar = self.menuBar()
file = bar.addMenu("&File")
_new = QAction(QIcon('icons/exit.png'), '&New', self)
_new.setStatusTip("New application")
_new.triggered.connect(self.my_process)
# self.connect(_new, SIGNAL("triggered()"), self.my_process)
file.addAction(_new)
_exit = QAction(QIcon('icons/exit.png'), '&Exit', self)
_exit.setShortcut('Ctrl+Q')
_exit.setStatusTip('Exit application')
_exit.triggered.connect(qApp.quit)
file.addAction(_exit)
self.statusBar()
self.setCentralWidget(self.canvas)
self.resize(800, 600)
示例6: TourTestWindow
# 需要导入模块: from qtpy.QtWidgets import QAction [as 别名]
# 或者: from qtpy.QtWidgets.QAction import setStatusTip [as 别名]
class TourTestWindow(QMainWindow):
""" """
sig_resized = Signal("QResizeEvent")
sig_moved = Signal("QMoveEvent")
def __init__(self):
super(TourTestWindow, self).__init__()
self.setGeometry(300, 100, 400, 600)
self.setWindowTitle('Exploring QMainWindow')
self.exit = QAction('Exit', self)
self.exit.setStatusTip('Exit program')
# create the menu bar
menubar = self.menuBar()
file_ = menubar.addMenu('&File')
file_.addAction(self.exit)
# create the status bar
self.statusBar()
# QWidget or its instance needed for box layout
self.widget = QWidget(self)
self.button = QPushButton('test')
self.button1 = QPushButton('1')
self.button2 = QPushButton('2')
effect = QGraphicsOpacityEffect(self.button2)
self.button2.setGraphicsEffect(effect)
self.anim = QPropertyAnimation(effect, to_binary_string("opacity"))
self.anim.setStartValue(0.01)
self.anim.setEndValue(1.0)
self.anim.setDuration(500)
lay = QVBoxLayout()
lay.addWidget(self.button)
lay.addStretch()
lay.addWidget(self.button1)
lay.addWidget(self.button2)
self.widget.setLayout(lay)
self.setCentralWidget(self.widget)
self.button.clicked.connect(self.action1)
self.button1.clicked.connect(self.action2)
self.tour = AnimatedTour(self)
def action1(self):
""" """
frames = get_tour('test')
index = 0
dic = {'last': 0, 'tour': frames}
self.tour.set_tour(index, dic, self)
self.tour.start_tour()
def action2(self):
""" """
self.anim.start()
def resizeEvent(self, event):
"""Reimplement Qt method"""
QMainWindow.resizeEvent(self, event)
self.sig_resized.emit(event)
def moveEvent(self, event):
"""Reimplement Qt method"""
QMainWindow.moveEvent(self, event)
self.sig_moved.emit(event)
示例7: _update_file_menu
# 需要导入模块: from qtpy.QtWidgets import QAction [as 别名]
# 或者: from qtpy.QtWidgets.QAction import setStatusTip [as 别名]
def _update_file_menu(self):
"""
Set up the File menu and update the menu with recent files
"""
self.file_menu.clear()
newAction = QAction("&New Reduction...", self)
newAction.setShortcut("Ctrl+N")
newAction.setStatusTip("Start a new reduction")
newAction.triggered.connect(self._new)
openAction = QAction("&Open...", self)
openAction.setShortcut("Ctrl+O")
openAction.setStatusTip("Open an XML file containing reduction parameters")
openAction.triggered.connect(self._file_open)
saveAsAction = QAction("Save as...", self)
saveAsAction.setStatusTip("Save the reduction parameters to XML")
saveAsAction.triggered.connect(self._save_as)
saveAction = QAction("&Save...", self)
saveAction.setShortcut("Ctrl+S")
saveAction.setStatusTip("Save the reduction parameters to XML")
saveAction.triggered.connect(self._save)
exportAction = QAction("&Export...", self)
exportAction.setShortcut("Ctrl+E")
exportAction.setStatusTip("Export to python script for Mantid")
exportAction.triggered.connect(self._export)
quitAction = QAction("&Quit", self)
quitAction.setShortcut("Ctrl+Q")
quitAction.triggered.connect(self.close)
self.file_menu.addAction(newAction)
self.file_menu.addAction(openAction)
self.file_menu.addAction(saveAction)
self.file_menu.addAction(saveAsAction)
self.file_menu.addAction(exportAction)
self.file_menu.addSeparator()
if self.general_settings.debug:
clearAction = QAction("&Clear settings and quit", self)
clearAction.setStatusTip("Restore initial application settings and close the application")
clearAction.triggered.connect(self._clear_and_close)
self.file_menu.addAction(clearAction)
self.file_menu.addAction(quitAction)
# TOOLS menu
instrAction = QAction("Change &instrument...", self)
instrAction.setShortcut("Ctrl+I")
instrAction.setStatusTip("Select a new instrument")
instrAction.triggered.connect(self._change_instrument)
debug_menu_item_str = "Turn debug mode ON"
if self.general_settings.debug:
debug_menu_item_str = "Turn debug mode OFF"
debugAction = QAction(debug_menu_item_str, self)
debugAction.setStatusTip(debug_menu_item_str)
debugAction.triggered.connect(self._debug_mode)
self.tools_menu.clear()
self.tools_menu.addAction(instrAction)
self.tools_menu.addAction(debugAction)
recent_files = []
for fname in self._recent_files:
if fname != self._filename and QFile.exists(fname) and fname not in recent_files:
recent_files.append(fname)
if len(recent_files)>0:
self.file_menu.addSeparator()
for i, fname in enumerate(recent_files):
action = QAction("&%d %s" % (i+1, QFileInfo(fname).fileName()), self)
action.setData(fname)
action.triggered.connect(self.open_file)
self.file_menu.addAction(action)
示例8: MainWindow
# 需要导入模块: from qtpy.QtWidgets import QAction [as 别名]
# 或者: from qtpy.QtWidgets.QAction import setStatusTip [as 别名]
class MainWindow(QMainWindow):
"""OpenBurn's main window"""
title = "OpenBurn"
def __init__(self):
super(MainWindow, self).__init__()
self.setWindowTitle(self.title)
self.setGeometry(100, 100, 800, 600)
self.setWindowIcon(QIcon(RESOURCE_PATH + "icons/nakka-finocyl.gif"))
self.create_default_widgets()
self.setup_ui()
def create_default_widgets(self):
"""Creates static widgets such as menubar and statusbar"""
def create_menubar():
"""Create menu bar and populate it with sub menu actions"""
def file_menu():
"""Create a file submenu"""
self.file_sub_menu = self.menubar.addMenu('File')
self.open_action = QAction('Open File', self)
self.open_action.setStatusTip('Open a new design')
self.open_action.setShortcut('CTRL+O')
# self.open_action.triggered.connect(self.open_file)
self.exit_action = QAction('Exit', self)
self.exit_action.setStatusTip('Exit the application.')
self.exit_action.setShortcut('CTRL+Q')
self.exit_action.triggered.connect(QApplication.quit)
self.file_sub_menu.addAction(self.open_action)
self.file_sub_menu.addAction(self.exit_action)
def edit_menu():
self.edit_dub_menu = self.menubar.addMenu('Edit')
def tools_menu():
self.edit_dub_menu = self.menubar.addMenu('Tools')
def help_menu():
"""Create help submenu"""
self.help_sub_menu = self.menubar.addMenu('Help')
self.about_action = QAction('About', self)
self.about_action.setStatusTip('About the application.')
self.about_action.setShortcut('CTRL+H')
self.about_action.triggered.connect(self.about_dialog.exec_)
self.help_sub_menu.addAction(self.about_action)
self.menubar = QMenuBar(self)
file_menu()
edit_menu()
tools_menu()
help_menu()
def create_statusbar():
self.statusbar = QStatusBar(self)
self.statusbar.showMessage("Ready", 0)
self.about_dialog = AboutDialog(self)
create_menubar()
self.setMenuBar(self.menubar)
create_statusbar()
self.setStatusBar(self.statusbar)
def setup_ui(self):
"""setup the tab widget UI"""
self.tab_widget = QTabWidget()
self.tab_widget.addTab(DesignTab(), "Design")
self.tab_widget.addTab(QWidget(), "Simulation")
self.tab_widget.addTab(QWidget(), "Propellants")
self.layout = QVBoxLayout()
self.layout.addWidget(self.tab_widget)
self.frame = QFrame()
self.frame.setLayout(self.layout)
self.setCentralWidget(self.frame)