本文整理汇总了Python中PyQt5.QtWidgets.QWidget方法的典型用法代码示例。如果您正苦于以下问题:Python QtWidgets.QWidget方法的具体用法?Python QtWidgets.QWidget怎么用?Python QtWidgets.QWidget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets
的用法示例。
在下文中一共展示了QtWidgets.QWidget方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QWidget [as 别名]
def __init__(self, parent=None, frame=QtWidgets.QFrame.Box):
super(FIRSTUI.ScrollWidget, self).__init__()
# Container Widget
widget = QtWidgets.QWidget()
# Layout of Container Widget
self.layout = QtWidgets.QVBoxLayout(self)
self.layout.setContentsMargins(0, 0, 0, 0)
widget.setLayout(self.layout)
# Scroll Area Properties
scroll = QtWidgets.QScrollArea()
scroll.setFrameShape(frame)
scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
scroll.setWidgetResizable(True)
scroll.setWidget(widget)
# Scroll Area Layer add
scroll_layout = QtWidgets.QVBoxLayout(self)
scroll_layout.addWidget(scroll)
scroll_layout.setContentsMargins(0, 0, 0, 0)
self.setLayout(scroll_layout)
示例2: on_focus_changed
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QWidget [as 别名]
def on_focus_changed(_old, new):
"""Register currently focused main window in the object registry."""
if new is None:
return
if not isinstance(new, QWidget):
log.misc.debug("on_focus_changed called with non-QWidget {!r}".format(
new))
return
window = new.window()
if isinstance(window, mainwindow.MainWindow):
objreg.register('last-focused-main-window', window, update=True)
# A focused window must also be visible, and in this case we should
# consider it as the most recently looked-at window
objreg.register('last-visible-main-window', window, update=True)
示例3: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QWidget [as 别名]
def __init__(self, parent):
QtWidgets.QWidget.__init__(self)
self.setupUi(self)
self.parent = parent
# self.result_area.setEnabled(False)
if self.parent.results.get_formula:
self.formula_label.setVisible(True)
self.formula_area.setEnabled(True)
else:
self.formula_label.setVisible(False)
self.formula_area.setVisible(False)
self.action_selector.setEnabled(False)
self.action_button.setEnabled(False)
self.action_selector.addItem(self.parent.ANNOT_CODE)
self.action_button.clicked.connect(self.action_clicked)
self.action_selector.currentIndexChanged[str].connect(self.action_selector_changed)
示例4: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QWidget [as 别名]
def __init__(self, url=QUrl(), title='', tab_id=0, *,
scroll_pos_perc=(0, 0),
load_status=usertypes.LoadStatus.success,
progress=0, can_go_back=None, can_go_forward=None):
super().__init__(win_id=0, mode_manager=None, private=False)
self._load_status = load_status
self._title = title
self._url = url
self._progress = progress
self.history = FakeWebTabHistory(self, can_go_back=can_go_back,
can_go_forward=can_go_forward)
self.scroller = FakeWebTabScroller(self, scroll_pos_perc)
self.audio = FakeWebTabAudio(self)
self.private_api = FakeWebTabPrivate(tab=self, mode_manager=None)
wrapped = QWidget()
self._layout.wrap(self, wrapped)
示例5: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QWidget [as 别名]
def __init__(self,
name: str,
items: typing.Iterable[_ItemType],
sort: bool = True,
delete_func: util.DeleteFuncType = None,
parent: QWidget = None):
super().__init__(parent)
self.name = name
self.srcmodel = QStandardItemModel(parent=self)
self._pattern = ''
# ListCategory filters all columns
self.columns_to_filter = [0, 1, 2]
self.setFilterKeyColumn(-1)
for item in items:
self.srcmodel.appendRow([QStandardItem(x) for x in item])
self.setSourceModel(self.srcmodel)
self.delete_func = delete_func
self._sort = sort
示例6: create
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QWidget [as 别名]
def create(win_id: int,
private: bool,
parent: QWidget = None) -> 'AbstractTab':
"""Get a QtWebKit/QtWebEngine tab object.
Args:
win_id: The window ID where the tab will be shown.
private: Whether the tab is a private/off the record tab.
parent: The Qt parent to set.
"""
# Importing modules here so we don't depend on QtWebEngine without the
# argument and to avoid circular imports.
mode_manager = modeman.instance(win_id)
if objects.backend == usertypes.Backend.QtWebEngine:
from qutebrowser.browser.webengine import webenginetab
tab_class = webenginetab.WebEngineTab # type: typing.Type[AbstractTab]
else:
from qutebrowser.browser.webkit import webkittab
tab_class = webkittab.WebKitTab
return tab_class(win_id=win_id, mode_manager=mode_manager, private=private,
parent=parent)
示例7: _set_widget
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QWidget [as 别名]
def _set_widget(self, widget: QWidget) -> None:
# pylint: disable=protected-access
self._widget = widget
self.data.splitter = miscwidgets.InspectorSplitter(widget)
self._layout.wrap(self, self.data.splitter)
self.history._history = widget.history()
self.history.private_api._history = widget.history()
self.scroller._init_widget(widget)
self.caret._widget = widget
self.zoom._widget = widget
self.search._widget = widget
self.printing._widget = widget
self.action._widget = widget
self.elements._widget = widget
self.audio._widget = widget
self.private_api._widget = widget
self.settings._settings = widget.settings()
self._install_event_filter()
self.zoom.apply_default()
示例8: create
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QWidget [as 别名]
def create(*, splitter: 'miscwidgets.InspectorSplitter',
win_id: int,
parent: QWidget = None) -> 'AbstractWebInspector':
"""Get a WebKitInspector/WebEngineInspector.
Args:
splitter: InspectorSplitter where the inspector can be placed.
win_id: The window ID this inspector is associated with.
parent: The Qt parent to set.
"""
# Importing modules here so we don't depend on QtWebEngine without the
# argument and to avoid circular imports.
if objects.backend == usertypes.Backend.QtWebEngine:
from qutebrowser.browser.webengine import webengineinspector
if webengineinspector.supports_new():
return webengineinspector.WebEngineInspector(
splitter, win_id, parent)
else:
return webengineinspector.LegacyWebEngineInspector(
splitter, win_id, parent)
else:
from qutebrowser.browser.webkit import webkitinspector
return webkitinspector.WebKitInspector(splitter, win_id, parent)
示例9: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QWidget [as 别名]
def __init__(self, *, win_id: int,
private: bool,
parent: QWidget = None) -> None:
misc.CommandLineEdit.__init__(self, parent=parent)
misc.MinimalLineEditMixin.__init__(self)
self._win_id = win_id
if not private:
command_history = objreg.get('command-history')
self.history.history = command_history.data
self.history.changed.connect(command_history.changed)
self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Ignored)
self.cursorPositionChanged.connect(
self.update_completion) # type: ignore[arg-type]
self.textChanged.connect(
self.update_completion) # type: ignore[arg-type]
self.textChanged.connect(self.updateGeometry)
self.textChanged.connect(self._incremental_search)
示例10: _add_widgets
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QWidget [as 别名]
def _add_widgets(self):
"""Add or readd all widgets to the VBox."""
self._vbox.removeWidget(self.tabbed_browser.widget)
self._vbox.removeWidget(self._downloadview)
self._vbox.removeWidget(self.status)
widgets = [self.tabbed_browser.widget] # type: typing.List[QWidget]
downloads_position = config.val.downloads.position
if downloads_position == 'top':
widgets.insert(0, self._downloadview)
elif downloads_position == 'bottom':
widgets.append(self._downloadview)
else:
raise ValueError("Invalid position {}!".format(downloads_position))
status_position = config.val.statusbar.position
if status_position == 'top':
widgets.insert(0, self.status)
elif status_position == 'bottom':
widgets.append(self.status)
else:
raise ValueError("Invalid position {}!".format(status_position))
for widget in widgets:
self._vbox.addWidget(widget)
示例11: setupUi
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QWidget [as 别名]
def setupUi(self, ScoreWindow):
ScoreWindow.setObjectName("ScoreWindow")
ScoreWindow.resize(471, 386)
self.centralwidget = QtWidgets.QWidget(ScoreWindow)
self.centralwidget.setObjectName("centralwidget")
self.Score = QtWidgets.QLineEdit(self.centralwidget)
self.Score.setGeometry(QtCore.QRect(180, 180, 113, 22))
self.Score.setObjectName("Score")
self.teamscore = QtWidgets.QLabel(self.centralwidget)
self.teamscore.setGeometry(QtCore.QRect(180, 130, 151, 20))
font = QtGui.QFont()
font.setBold(True)
font.setWeight(75)
self.teamscore.setFont(font)
self.teamscore.setObjectName("teamscore")
ScoreWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(ScoreWindow)
self.statusbar.setObjectName("statusbar")
ScoreWindow.setStatusBar(self.statusbar)
self.retranslateUi(ScoreWindow)
QtCore.QMetaObject.connectSlotsByName(ScoreWindow)
示例12: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QWidget [as 别名]
def __init__(self, parent=None):
super(TextInput, self).__init__(parent)
self.setWindowFlags(Qt.Dialog | Qt.FramelessWindowHint)
self.mainLayout = QVBoxLayout()
self.textArea = QTextEdit(self)
self.buttonArea = QWidget(self)
self.buttonLayout = QHBoxLayout()
self.cancelButton = QPushButton('Cancel', self)
self.okButton = QPushButton('Ok', self)
self.buttonLayout.addWidget(self.cancelButton)
self.buttonLayout.addWidget(self.okButton)
self.buttonArea.setLayout(self.buttonLayout)
self.mainLayout.addWidget(self.textArea)
self.mainLayout.addWidget(self.buttonArea)
self.setLayout(self.mainLayout)
self.textArea.textChanged.connect(self.textChanged_)
self.okButton.clicked.connect(self.okButtonClicked)
self.cancelButton.clicked.connect(self.cancelPressed)
示例13: setupUi
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QWidget [as 别名]
def setupUi(self, QHangupsConversationsList):
QHangupsConversationsList.setObjectName("QHangupsConversationsList")
QHangupsConversationsList.resize(250, 500)
self.centralwidget = QtWidgets.QWidget(QHangupsConversationsList)
self.centralwidget.setObjectName("centralwidget")
self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget)
self.verticalLayout.setObjectName("verticalLayout")
self.conversationsListWidget = QtWidgets.QListWidget(self.centralwidget)
self.conversationsListWidget.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.conversationsListWidget.setObjectName("conversationsListWidget")
self.verticalLayout.addWidget(self.conversationsListWidget)
QHangupsConversationsList.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(QHangupsConversationsList)
self.menubar.setGeometry(QtCore.QRect(0, 0, 250, 27))
self.menubar.setObjectName("menubar")
QHangupsConversationsList.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(QHangupsConversationsList)
self.statusbar.setObjectName("statusbar")
QHangupsConversationsList.setStatusBar(self.statusbar)
self.retranslateUi(QHangupsConversationsList)
QtCore.QMetaObject.connectSlotsByName(QHangupsConversationsList)
示例14: setupUi
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QWidget [as 别名]
def setupUi(self, QHangupsConversations):
QHangupsConversations.setObjectName("QHangupsConversations")
QHangupsConversations.resize(500, 350)
self.centralwidget = QtWidgets.QWidget(QHangupsConversations)
self.centralwidget.setObjectName("centralwidget")
self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
self.gridLayout.setObjectName("gridLayout")
self.conversationsTabWidget = QtWidgets.QTabWidget(self.centralwidget)
self.conversationsTabWidget.setElideMode(QtCore.Qt.ElideRight)
self.conversationsTabWidget.setTabsClosable(True)
self.conversationsTabWidget.setMovable(True)
self.conversationsTabWidget.setObjectName("conversationsTabWidget")
self.gridLayout.addWidget(self.conversationsTabWidget, 0, 0, 1, 1)
QHangupsConversations.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(QHangupsConversations)
self.menubar.setGeometry(QtCore.QRect(0, 0, 500, 27))
self.menubar.setObjectName("menubar")
QHangupsConversations.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(QHangupsConversations)
self.statusbar.setObjectName("statusbar")
QHangupsConversations.setStatusBar(self.statusbar)
self.retranslateUi(QHangupsConversations)
self.conversationsTabWidget.setCurrentIndex(-1)
QtCore.QMetaObject.connectSlotsByName(QHangupsConversations)
示例15: populate
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QWidget [as 别名]
def populate(self):
self.setFeatures(QtWidgets.QDockWidget.DockWidgetClosable)
self.setTitleBarWidget(QtWidgets.QWidget(self)) # Removes titlebar
self.sideDockTabWidget = QtWidgets.QTabWidget(self)
self.setWidget(self.sideDockTabWidget)
# This order is important
self.bookmarkModel = QtGui.QStandardItemModel(self)
self.bookmarkProxyModel = BookmarkProxyModel(self)
self.bookmarks = Bookmarks(self)
self.bookmarks.generate_bookmark_model()
if not self.parent.are_we_doing_images_only:
self.annotationModel = QtGui.QStandardItemModel(self)
self.annotations = Annotations(self)
self.annotations.generate_annotation_model()
self.searchResultsModel = QtGui.QStandardItemModel(self)
self.search = Search(self)