本文整理汇总了Python中PyQt5.QtWidgets.QToolBar方法的典型用法代码示例。如果您正苦于以下问题:Python QtWidgets.QToolBar方法的具体用法?Python QtWidgets.QToolBar怎么用?Python QtWidgets.QToolBar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets
的用法示例。
在下文中一共展示了QtWidgets.QToolBar方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OnCreate
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QToolBar [as 别名]
def OnCreate(self, form):
"""
Called when the view is created
"""
self.bp_tree_widget = QtWidgets.QTreeWidget()
self.bp_handler = BpHandler.get_bp_handler()
self.die_icons = DIE.UI.Die_Icons.get_die_icons()
# Get parent widget
self.parent = self.FormToPyQtWidget(form)
self._add_parser_data()
toolbar = QtWidgets.QToolBar()
action_refresh = QtWidgets.QAction(self.die_icons.icon_refresh, "Refresh", toolbar)
action_refresh.triggered.connect(self.refresh)
toolbar.addAction(action_refresh)
layout = QtWidgets.QGridLayout()
layout.addWidget(toolbar)
layout.addWidget(self.bp_tree_widget)
self.parent.setLayout(layout)
示例2: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QToolBar [as 别名]
def __init__(self, client):
super().__init__()
self.toolbar = QtWidgets.QToolBar()
action_help = QtWidgets.QAction(tools.load_ui_icon('icon.help.png'), 'Show help', self)
action_help.triggered.connect(client.show_help_browser) # TODO with partial make reference to specific page
self.toolbar.addAction(action_help)
action_quit = QtWidgets.QAction(tools.load_ui_icon('icon.back_to_startscreen.png'), 'Exit to main menu', self)
action_quit.triggered.connect(client.switch_to_start_screen)
self.toolbar.addAction(action_quit)
# main map
self.main_map = MainMap()
# mini map
self.mini_map = MiniMap()
# info box
self.info_box = InfoBox()
# layout
layout = QtWidgets.QGridLayout(self)
layout.addWidget(self.toolbar, 0, 0)
layout.addWidget(self.mini_map, 1, 0)
layout.addWidget(self.info_box, 2, 0)
layout.addWidget(self.main_map, 0, 1, 3, 1)
layout.setRowStretch(2, 1) # the info box will take all vertical space left
layout.setColumnStretch(1, 1) # the main map will take all horizontal space left
示例3: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QToolBar [as 别名]
def __init__(self, *args, **kwargs):
"""
Create toolbar.
"""
super().__init__(*args, **kwargs)
self.layout = QtWidgets.QVBoxLayout(self)
self.layout.setContentsMargins(0, 0, 0, 0)
# create tool bar
toolbar = QtWidgets.QToolBar()
action_group = QtWidgets.QActionGroup(toolbar)
# actions single player new/load
a = qt.create_action(tools.load_ui_icon('icon.lobby.single.new.png'),
'Start new single player scenario', action_group,
toggle_connection=self.toggled_single_player_scenario_selection, checkable=True)
toolbar.addAction(a)
a = qt.create_action(tools.load_ui_icon('icon.lobby.single.load.png'),
'Continue saved single player scenario', action_group,
toggle_connection=self.toggled_single_player_load_scenario, checkable=True)
toolbar.addAction(a)
toolbar.addSeparator()
# actions multi player
a = qt.create_action(tools.load_ui_icon('icon.lobby.network.png'),
'Show server lobby', action_group,
toggle_connection=self.toggled_server_lobby, checkable=True)
toolbar.addAction(a)
a = qt.create_action(tools.load_ui_icon('icon.lobby.multiplayer-game.png'),
'Start or continue multiplayer scenario', action_group,
toggle_connection=self.toggled_multiplayer_scenario_selection, checkable=True)
toolbar.addAction(a)
self.layout.addWidget(toolbar, alignment=QtCore.Qt.AlignTop)
self.content = None
示例4: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QToolBar [as 别名]
def __init__(self, initial_province=None):
super().__init__()
widget_layout = QtWidgets.QVBoxLayout(self)
# toolbar
toolbar = QtWidgets.QToolBar()
a = qt.create_action(tools.load_ui_icon('icon.add.png'), 'Add province', toolbar, self.add_province)
toolbar.addAction(a)
a = qt.create_action(tools.load_ui_icon('icon.delete.png'), 'Remove province', toolbar, self.remove_province)
toolbar.addAction(a)
widget_layout.addLayout(qt.wrap_in_boxlayout(toolbar))
# provinces selection combo box
label = QtWidgets.QLabel('Choose')
self.provinces_combobox = QtWidgets.QComboBox()
self.provinces_combobox.setFixedWidth(200)
self.provinces_combobox.currentIndexChanged.connect(self.province_combobox_index_changed)
widget_layout.addWidget(qt.wrap_in_groupbox(qt.wrap_in_boxlayout((label, self.provinces_combobox)),
'provinces'))
# province info panel
layout = QtWidgets.QVBoxLayout()
# nation
self.nation_label = QtWidgets.QLabel('Nation')
layout.addWidget(self.nation_label)
widget_layout.addWidget(qt.wrap_in_groupbox(layout, 'Info'))
# vertical stretch
widget_layout.addStretch()
# reset content
self.reset_content()
# if province is given, select it
if initial_province:
index = utils.index_of_element(self.provinces, initial_province)
self.provinces_combobox.setCurrentIndex(index)
示例5: initPre
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QToolBar [as 别名]
def initPre(self):
"""
Initialize stuff that are shared by actions, menus, widgets etc.
"""
self.addWidget(QtWidgets.QToolBar('Document', objectName='document_toolbar'))
self.addWidget(QtWidgets.QToolBar('Editor', objectName='editor_toolbar'))
self.addWidget(QtWidgets.QToolBar('View', objectName='view_toolbar'))
self.addWidget(QtWidgets.QToolBar('Graphol', objectName='graphol_toolbar'))
示例6: add_folder
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QToolBar [as 别名]
def add_folder(self, path, status_data=0):
basename = os.path.basename(os.path.normpath(path))
if self.findItems(basename):
logging.warning(
"Tried to add a folder (%s) that already exists", basename
)
return
composite_pixmap = CompositePixmap(self.icon_folder.pixmap(256, 256))
name = QStandardItem(QIcon(composite_pixmap), basename)
name.setToolTip(path)
status = QStandardItem()
mtime = QStandardItem()
size = QStandardItem()
action = QStandardItem()
self.appendRow([name, status, mtime, size, action])
action_bar = QToolBar()
action_bar.setIconSize(QSize(16, 16))
if sys.platform == "darwin":
# See: https://bugreports.qt.io/browse/QTBUG-12717
action_bar.setStyleSheet(
"background-color: {0}; border: 0px {0}".format(
self.view.palette().base().color().name()
)
)
action_bar_action = QAction(self.icon_action, "Action...", self)
action_bar_action.setStatusTip("Action...")
action_bar_action.triggered.connect(self.view.on_right_click)
action_bar.addAction(action_bar_action)
self.view.setIndexWidget(action.index(), action_bar)
self.view.hide_drop_label()
self.set_status(basename, status_data)
示例7: setupUi
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QToolBar [as 别名]
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.setWindowModality(QtCore.Qt.WindowModal)
MainWindow.setEnabled(True)
MainWindow.resize(440, 288)
self.centralWidget = QtWidgets.QWidget(MainWindow)
self.centralWidget.setObjectName("centralWidget")
MainWindow.setCentralWidget(self.centralWidget)
self.toolBar = QtWidgets.QToolBar(MainWindow)
self.toolBar.setMovable(True)
self.toolBar.setObjectName("toolBar")
MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar)
self.addbar = QtWidgets.QAction(MainWindow)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/newPrefix/add.png"), QtGui.QIcon.Normal, QtGui.QIcon.On)
self.addbar.setIcon(icon)
self.addbar.setObjectName("addbar")
self.setbar = QtWidgets.QAction(MainWindow)
icon1 = QtGui.QIcon()
icon1.addPixmap(QtGui.QPixmap(":/newPrefix/upon.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.setbar.setIcon(icon1)
self.setbar.setObjectName("setbar")
self.action = QtWidgets.QAction(MainWindow)
self.action.setCheckable(True)
icon2 = QtGui.QIcon()
icon2.addPixmap(QtGui.QPixmap(":/newPrefix/layout.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.action.setIcon(icon2)
self.action.setObjectName("action")
self.toolBar.addAction(self.addbar)
self.toolBar.addAction(self.action)
self.toolBar.addAction(self.setbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
示例8: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QToolBar [as 别名]
def __init__(self, icon_provider):
"""
"""
super().__init__()
# start with empty home url
self.home_url = None
self.clear_history = False
# create and add tool bar on top (non floatable or movable)
tool_bar = QtWidgets.QToolBar(self)
# create actions, connect to methods, add to tool bar
action_home = QtWidgets.QAction(self)
action_home.setIcon(icon_provider('icon.home.png'))
action_home.setToolTip('Home')
action_home.triggered.connect(self.home)
tool_bar.addAction(action_home)
action_backward = QtWidgets.QAction(self)
action_backward.setEnabled(False) # initially not enabled
action_backward.setIcon(icon_provider('icon.backward.png'))
tool_bar.addAction(action_backward)
self.action_backward = action_backward
action_forward = QtWidgets.QAction(self)
action_forward.setEnabled(False) # initially not enabled
action_forward.setIcon(icon_provider('icon.forward.png'))
tool_bar.addAction(action_forward)
self.action_forward = action_forward
# create and add web view, also store history
web_view = QtWebEngineWidgets.QWebEngineView()
self.web_view = web_view
self.web_view.loadFinished.connect(self.load_finished)
# wire forward, backward
action_backward.triggered.connect(self.backward)
action_forward.triggered.connect(self.forward)
# set Layout
layout = QtWidgets.QVBoxLayout(self)
layout.setContentsMargins(0, 0, 0, 0)
layout.addWidget(tool_bar)
layout.addWidget(web_view)
示例9: make_GraphicsItem_draggable
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QToolBar [as 别名]
def make_GraphicsItem_draggable(parent):
"""
Takes a QtWidgets.QGraphicsItem and adds signals for dragging the object around. For this the item must have the
ItemIsMovable and ItemSendsScenePositionChanges flags set. Only use it when really needed because there is
some performance hit attached.
"""
# noinspection PyPep8Naming
class DraggableGraphicsItem(parent, QtCore.QObject):
"""
Draggable GraphicsItem.
"""
changed = QtCore.pyqtSignal(object)
def __init__(self, *args, **kwargs):
"""
By default QGraphicsItems are not movable and also do not emit signals when the position is changed for
performance reasons. We need to turn this on.
"""
parent.__init__(self, *args, **kwargs)
self.parent = parent
QtCore.QObject.__init__(self)
self.setFlags(QtWidgets.QGraphicsItem.ItemIsMovable
| QtWidgets.QGraphicsItem.ItemSendsScenePositionChanges)
def itemChange(self, change, value): # noqa: N802
"""
Catch all item position changes and emit the changed signal with the value (which will be the position).
:param change:
:param value:
"""
if change == QtWidgets.QGraphicsItem.ItemPositionChange:
self.changed.emit(value)
return parent.itemChange(self, change, value)
return DraggableGraphicsItem
# Some classes we need (just to make the naming clear), Name will be used in Stylesheet selectors
#: QToolBar made draggable
示例10: OnCreate
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QToolBar [as 别名]
def OnCreate(self, form):
"""
Called when the view is created
"""
self.die_db = DIE.Lib.DIEDb.get_db()
self.function_view = DIE.UI.FunctionViewEx.get_view()
# Get parent widget
self.parent = self.FormToPyQtWidget(form)
self.valueModel = QtGui.QStandardItemModel()
self.valueTreeView = QtWidgets.QTreeView()
self.valueTreeView.setExpandsOnDoubleClick(False)
self.valueTreeView.doubleClicked.connect(self.itemDoubleClickSlot)
self._model_builder(self.valueModel)
self.valueTreeView.setModel(self.valueModel)
# Toolbar
self.value_toolbar = QtWidgets.QToolBar()
# Value type combobox
type_list = []
if self.die_db:
type_list = self.die_db.get_all_value_types()
type_list.insert(0, "All Values")
self.value_type_combo = QtWidgets.QComboBox()
self.value_type_combo.addItems(type_list)
self.value_type_combo.activated[str].connect(self.on_value_type_combobox_change)
self.value_type_label = QtWidgets.QLabel("Value Type: ")
self.value_toolbar.addWidget(self.value_type_label)
self.value_toolbar.addWidget(self.value_type_combo)
# Layout
layout = QtWidgets.QGridLayout()
layout.addWidget(self.value_toolbar)
layout.addWidget(self.valueTreeView)
self.parent.setLayout(layout)