本文整理汇总了Python中PyQt5.QtWidgets.QStackedWidget.show方法的典型用法代码示例。如果您正苦于以下问题:Python QStackedWidget.show方法的具体用法?Python QStackedWidget.show怎么用?Python QStackedWidget.show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QStackedWidget
的用法示例。
在下文中一共展示了QStackedWidget.show方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: E5SideBar
# 需要导入模块: from PyQt5.QtWidgets import QStackedWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QStackedWidget import show [as 别名]
class E5SideBar(QWidget):
"""
Class implementing a sidebar with a widget area, that is hidden or shown,
if the current tab is clicked again.
"""
Version = 1
North = 0
East = 1
South = 2
West = 3
def __init__(self, orientation=None, delay=200, parent=None):
"""
Constructor
@param orientation orientation of the sidebar widget (North, East,
South, West)
@param delay value for the expand/shrink delay in milliseconds
(integer)
@param parent parent widget (QWidget)
"""
super(E5SideBar, self).__init__(parent)
self.__tabBar = QTabBar()
self.__tabBar.setDrawBase(True)
self.__tabBar.setShape(QTabBar.RoundedNorth)
self.__tabBar.setUsesScrollButtons(True)
self.__tabBar.setDrawBase(False)
self.__stackedWidget = QStackedWidget(self)
self.__stackedWidget.setContentsMargins(0, 0, 0, 0)
self.__autoHideButton = QToolButton()
self.__autoHideButton.setCheckable(True)
self.__autoHideButton.setIcon(
UI.PixmapCache.getIcon("autoHideOff.png"))
self.__autoHideButton.setChecked(True)
self.__autoHideButton.setToolTip(
self.tr("Deselect to activate automatic collapsing"))
self.barLayout = QBoxLayout(QBoxLayout.LeftToRight)
self.barLayout.setContentsMargins(0, 0, 0, 0)
self.layout = QBoxLayout(QBoxLayout.TopToBottom)
self.layout.setContentsMargins(0, 0, 0, 0)
self.layout.setSpacing(0)
self.barLayout.addWidget(self.__autoHideButton)
self.barLayout.addWidget(self.__tabBar)
self.layout.addLayout(self.barLayout)
self.layout.addWidget(self.__stackedWidget)
self.setLayout(self.layout)
# initialize the delay timer
self.__actionMethod = None
self.__delayTimer = QTimer(self)
self.__delayTimer.setSingleShot(True)
self.__delayTimer.setInterval(delay)
self.__delayTimer.timeout.connect(self.__delayedAction)
self.__minimized = False
self.__minSize = 0
self.__maxSize = 0
self.__bigSize = QSize()
self.splitter = None
self.splitterSizes = []
self.__hasFocus = False
# flag storing if this widget or any child has the focus
self.__autoHide = False
self.__tabBar.installEventFilter(self)
self.__orientation = E5SideBar.North
if orientation is None:
orientation = E5SideBar.North
self.setOrientation(orientation)
self.__tabBar.currentChanged[int].connect(
self.__stackedWidget.setCurrentIndex)
e5App().focusChanged[QWidget, QWidget].connect(self.__appFocusChanged)
self.__autoHideButton.toggled[bool].connect(self.__autoHideToggled)
def setSplitter(self, splitter):
"""
Public method to set the splitter managing the sidebar.
@param splitter reference to the splitter (QSplitter)
"""
self.splitter = splitter
self.splitter.splitterMoved.connect(self.__splitterMoved)
self.splitter.setChildrenCollapsible(False)
index = self.splitter.indexOf(self)
self.splitter.setCollapsible(index, False)
def __splitterMoved(self, pos, index):
"""
Private slot to react on splitter moves.
@param pos new position of the splitter handle (integer)
@param index index of the splitter handle (integer)
"""
if self.splitter:
#.........这里部分代码省略.........
示例2: MainView
# 需要导入模块: from PyQt5.QtWidgets import QStackedWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QStackedWidget import show [as 别名]
#.........这里部分代码省略.........
print("Remove entry at pos " + str(self.pipeline.get_index(cat)) + " " + str(cat))
self.pipeline.delete_category(self.pipeline.get_index(cat))
def change_pip_entry_alg(self, position, new_category, new_algorithm, pipe_entry_widget, settings_widget):
"""
Changes the selected algorithm of the pipeline entry at the position.
Afterwards create all widgets for this algorithm instance
Args:
position: the position of the pipeline entry
algorithm: the selected algorithm for this category
"""
print("Position to be changed:" + str(position))
print("Pipeline length: " + str(len(self.pipeline.executed_cats)))
old_cat = self.pipeline.executed_cats[position]
old_alg = old_cat.active_algorithm
print("Old Cat found in pipeline: " + str(old_cat))
print("Old Alg: found in pipeline:" + str(old_alg))
print("New Category given:" + str(new_category))
print("New Algorithm given:" + str(new_algorithm))
# set in model
self.pipeline.change_category(new_category, position)
self.pipeline.change_algorithm(new_algorithm, position)
new_cat = self.pipeline.executed_cats[position]
new_alg = new_cat.active_algorithm
# change settings widgets
self.remove_pip_entry(pipe_entry_widget, settings_widget)
(new_pipe_entry_widget, new_settings_widget) = self.add_pipe_entry_new(position)
self.stackedWidget_Settings.show()
self.stackedWidget_Settings.setCurrentIndex(position)
self.settings_collapsable.setTitle(new_alg.get_name() + " Settings")
self.remove_cat_alg_dropdown()
self.create_cat_alg_dropdown(position, new_pipe_entry_widget, new_settings_widget)
self.set_cat_alg_dropdown(new_cat, new_alg)
print("New Cat found in pipeline: " + str(new_cat))
print("New Alg found in pipeline: " + str(new_alg))
def load_settings_widgets_from_pipeline_groupbox(self, position):
"""
Extracts all widgets from a single algorithm and returns a QBoxLayout
Args:
alg: the alg instance we extract from
Returns: a QBoxLayout containing all widgets for this particular alg.
"""
alg = self.pipeline.executed_cats[position].active_algorithm
print("alg " + str(alg))
print("cat " + str(self.pipeline.executed_cats[position]))
empty_flag = True
groupOfSliders = QGroupBox()
sp = QSizePolicy()
sp.setVerticalPolicy(QSizePolicy.Preferred)
示例3: QPushButton
# 需要导入模块: from PyQt5.QtWidgets import QStackedWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QStackedWidget import show [as 别名]
# add buttons
btn1 = QPushButton("PLAY")
player = QMediaPlayer()
media = QMediaContent(QUrl(sys.argv[1]))
player.setMedia(media)
# Create and set video output widget
video = ClickableVideoWidget()
player.setVideoOutput(video)
# add to stacked layout
print("Added widget", w.addWidget(btn1))
print("Added widget", w.addWidget(video))
def play_video():
w.setCurrentIndex(1)
player.play()
def pause_video():
player.pause()
w.setCurrentIndex(0)
# connect signals to stack change layout slot
btn1.clicked.connect(play_video)
video.clicked.connect(pause_video)
w.show()
sys.exit(app.exec_())