本文整理汇总了Python中PyQt5.QtWidgets.QWidget类的典型用法代码示例。如果您正苦于以下问题:Python QWidget类的具体用法?Python QWidget怎么用?Python QWidget使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QWidget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, parentWidget):
QWidget.__init__(self, parentWidget)
self.editorWidget = parentWidget.editorWidget # TODO: Review class structure
self.searching = False
self.ui = Ui_SearchWidget()
self.ui.setupUi(self)
self.resultListModel = QStandardItemModel(self.ui.resultList)
self.ui.resultWidget.setCurrentIndex(0)
self.ui.resultList.setModel(self.resultListModel)
self.ui.resultList.selectionModel().selectionChanged.connect(self.doResultSelected)
self.startIcon = QIcon(':/icons/search-global-start.png')
self.stopIcon = QIcon(':/icons/search-global-stop.png')
self.ui.startStopButton.setIcon(self.startIcon)
self.ui.searchInput.returnPressed.connect(self.doReturnKey)
self.ui.startStopButton.clicked.connect(self.doStartStopButton)
self.workerThread = QThread()
self.worker = SearchWorker()
self.worker.moveToThread(self.workerThread)
self.startWork.connect(self.worker.startSearch)
self.worker.searchDone.connect(self.searchDone)
self.worker.addMatch.connect(self.addMatch)
# self.stopWork.connect(self.worker.stopSearch)
self.workerThread.start()
示例2: mouseMoveEvent
def mouseMoveEvent(self, event):
# マウスをクリックして動かしたときにウィジェットを動かす
# ローカル座標が(0, 0)になってしまうので、mousePressEventで取得した
# ローカル座標を使って補正する
self.move(event.screenPos().x() - self.clickedPosx,
event.screenPos().y() - self.clickedPosy)
QWidget.mouseMoveEvent(self, event)
示例3: createTreeView
def createTreeView(self):
dockWidget = QDockWidget()
dockWidget.setAllowedAreas(Qt.LeftDockWidgetArea)
dockWidget.setFeatures(QDockWidget.NoDockWidgetFeatures)
dockWidget.setTitleBarWidget(QWidget())
self.treeView = QTreeView()
self.treeView.clicked.connect(self.treeItemClicked)
self.treeModel = TreeModel()
self.treeView.setModel(self.treeModel)
self.logo = QLabel()
logoPixmap = QPixmap(CMAKE_INSTALL_PREFIX + '/share/jderobot/resources/jderobot.png')
self.logo.setPixmap(logoPixmap)
self.upButton = QPushButton()
self.upButton.setText('Up')
self.upButton.clicked.connect(self.upButtonClicked)
leftContainer = QWidget()
leftLayout = QVBoxLayout()
leftLayout.addWidget(self.treeView)
leftLayout.addWidget(self.upButton)
leftLayout.addWidget(self.logo)
leftContainer.setLayout(leftLayout)
dockWidget.setWidget(leftContainer)
self.addDockWidget(Qt.LeftDockWidgetArea, dockWidget)
示例4: add_widget_item
def add_widget_item(self, widget_item):
self.layout.addWidget(widget_item)
widget_item.show()
widget = QWidget()
widget.setLayout(self.layout)
self.scroll.setWidget(widget)
示例5: __init__
def __init__(self, parentWidget, markerFmt, editWidget):
QWidget.__init__(self, parentWidget)
self.markerFormat = markerFmt
self.textEdit = editWidget
self.startPos = 0
self.endPos = 0
self.pattern = ''
layout = QHBoxLayout()
layout.setContentsMargins(0, 0, 0, 0)
self.setLayout(layout)
self.searchPattern = CancelAwareLineEdit(self)
self.searchPattern.setPlaceholderText('Start typing to find in page')
self.searchPattern.editingFinished.connect(self.hideWidget)
self.searchPattern.textEdited.connect(self.doSearch)
upAction = QAction(QIcon(':/icons/find-up.png'), "Find backwards (Shift-F3)", self)
upAction.setShortcut(Qt.SHIFT + Qt.Key_F3);
upAction.triggered.connect(self.findUpwards)
self.upButton = QToolButton(self)
self.upButton.setDefaultAction(upAction)
downAction = QAction(QIcon(':/icons/find-down.png'), "Find next (F3)", self)
downAction.setShortcut(Qt.Key_F3);
downAction.triggered.connect(self.findDownwards)
self.downButton = QToolButton(self)
self.downButton.setDefaultAction(downAction)
layout.addWidget(self.searchPattern)
layout.addWidget(self.upButton)
layout.addWidget(self.downButton)
示例6: Bool
class Bool(SimpleBlackbox):
author = "DrLuke"
name = "Bool"
modulename = "drluke.builtin.bool"
Category = ["Builtin"]
placeable = True
implementation = BoolImplementation
def __init__(self, *args, **kwargs):
super(Bool, self).__init__(*args, **kwargs)
self.propertiesWidget = QWidget()
self.vlayout = QVBoxLayout()
self.toggle = QCheckBox("Output")
self.toggle.toggled.connect(self.toggleTrueFalse)
self.vlayout.addWidget(self.toggle)
self.vlayout.addItem(QSpacerItem(40, 20, QSizePolicy.Minimum, QSizePolicy.Expanding))
self.propertiesWidget.setLayout(self.vlayout)
def toggleTrueFalse(self, bool):
self.sendDataToImplementations(bool)
def getPropertiesWidget(self):
return self.propertiesWidget
def defineIO(self):
self.addOutput(bool, "boolout", "Bool out")
示例7: __init__
def __init__(self, win):
QWidget.__init__(self)
self.win = win
self.setWindowTitle('Electrum - '+_('Payment Request'))
self.setMinimumSize(800, 250)
self.address = ''
self.label = ''
self.amount = 0
self.setFocusPolicy(QtCore.Qt.NoFocus)
main_box = QHBoxLayout()
self.qrw = QRCodeWidget()
main_box.addWidget(self.qrw, 1)
vbox = QVBoxLayout()
main_box.addLayout(vbox)
self.address_label = QLabel("")
#self.address_label.setFont(QFont(MONOSPACE_FONT))
vbox.addWidget(self.address_label)
self.label_label = QLabel("")
vbox.addWidget(self.label_label)
self.amount_label = QLabel("")
vbox.addWidget(self.amount_label)
vbox.addStretch(1)
self.setLayout(main_box)
示例8: __addSinglesLine
def __addSinglesLine(self):
"""
Private slot to add a line of entry widgets for single characters.
"""
hbox = QWidget(self.singlesItemsBox)
hboxLayout = QHBoxLayout(hbox)
hboxLayout.setContentsMargins(0, 0, 0, 0)
hboxLayout.setSpacing(6)
hbox.setLayout(hboxLayout)
cb1 = QComboBox(hbox)
cb1.setEditable(False)
cb1.addItems(self.comboItems)
cb1.addItems(self.singleComboItems)
hboxLayout.addWidget(cb1)
le1 = QLineEdit(hbox)
le1.setValidator(self.charValidator)
hboxLayout.addWidget(le1)
cb2 = QComboBox(hbox)
cb2.setEditable(False)
cb2.addItems(self.comboItems)
cb2.addItems(self.singleComboItems)
hboxLayout.addWidget(cb2)
le2 = QLineEdit(hbox)
le2.setValidator(self.charValidator)
hboxLayout.addWidget(le2)
self.singlesItemsBoxLayout.addWidget(hbox)
cb1.activated[int].connect(self.__singlesCharTypeSelected)
cb2.activated[int].connect(self.__singlesCharTypeSelected)
hbox.show()
self.singlesItemsBox.adjustSize()
self.singlesEntries.append([cb1, le1])
self.singlesEntries.append([cb2, le2])
示例9: __addRangesLine
def __addRangesLine(self):
"""
Private slot to add a line of entry widgets for character ranges.
"""
hbox = QWidget(self.rangesItemsBox)
hboxLayout = QHBoxLayout(hbox)
hboxLayout.setContentsMargins(0, 0, 0, 0)
hboxLayout.setSpacing(6)
hbox.setLayout(hboxLayout)
cb1 = QComboBox(hbox)
cb1.setEditable(False)
cb1.addItems(self.comboItems)
hboxLayout.addWidget(cb1)
l1 = QLabel(self.tr("Between:"), hbox)
hboxLayout.addWidget(l1)
le1 = QLineEdit(hbox)
le1.setValidator(self.charValidator)
hboxLayout.addWidget(le1)
l2 = QLabel(self.tr("And:"), hbox)
hboxLayout.addWidget(l2)
le2 = QLineEdit(hbox)
le2.setValidator(self.charValidator)
hboxLayout.addWidget(le2)
self.rangesItemsBoxLayout.addWidget(hbox)
cb1.activated[int].connect(self.__rangesCharTypeSelected)
hbox.show()
self.rangesItemsBox.adjustSize()
self.rangesEntries.append([cb1, le1, le2])
示例10: __init__
def __init__(self):
super().__init__()
# 사용한 위젯들을 생성
lbl1 = QLabel('This is') #<---- 1
lbl2 = QLabel('Layout Example')
okButton = QPushButton("OK")
cancelButton = QPushButton("Cancel")
hbox = QHBoxLayout() #<---- 2
hbox.addStretch(1) #<---- 3
hbox.addWidget(okButton) #<---- 4
hbox.addWidget(cancelButton) #<---- 5
vbox = QVBoxLayout() #<---- 6
vbox.addWidget(lbl1) #<---- 7
vbox.addWidget(lbl2) #<---- 8
vbox.addLayout(hbox) #<---- 9
window = QWidget() #<---- 10
window.setLayout(vbox) #<---- 11
self.setCentralWidget(window) #<---- 12
self.setGeometry(300, 300, 300, 150)
self.setWindowTitle('Layout Example')
self.show()
示例11: PreviewWidget
class PreviewWidget(QScrollArea):
def __init__(self, parent=None):
super(PreviewWidget, self).__init__(parent)
self.setWidgetResizable(True)
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
self.widget = QWidget()
self.layout = QHBoxLayout()
self.layout.addStretch(1)
self.layout.setContentsMargins(0, 0, 0, 0)
self.widget.setLayout(self.layout)
self.setWidget(self.widget)
def removeLast(self):
item = self.layout.takeAt(0)
if item:
item.widget().deleteLater()
def resizeEvent(self, event):
self.widget.setFixedHeight(self.viewport().height())
super(PreviewWidget, self).resizeEvent(event)
def addPixmap(self, pixmap):
label = ImageLabel(pixmap, self)
self.layout.insertWidget(0, label)
示例12: _get_control_layout
def _get_control_layout(self):
"""
Create static layout.
"""
widget = QWidget()
vbox = QVBoxLayout()
widget.setLayout(vbox)
vbox.setContentsMargins(0, 0, 0, 0)
self.template_combo_box = QComboBox()
self.template_combo_box.currentIndexChanged.connect(self._item_selected)
vbox.addWidget(self.template_combo_box)
scrollable_vbox = utils.get_scrollable(self.controls_layout)
vbox.addWidget(scrollable_vbox, stretch=80)
buttons_layout = QHBoxLayout()
vbox.addLayout(buttons_layout, stretch=20)
b = QPushButton("Назад")
b.setObjectName("controls")
b.clicked.connect(self._close)
buttons_layout.addWidget(b)
widget.setGraphicsEffect(utils.get_shadow())
return widget
示例13: __initUI__
def __initUI__(self):
# ---- Toolbar ----
toolbar_widget = QWidget()
self.btn_apply = btn_apply = QPushButton('Apply')
btn_apply.clicked.connect(self.btn_apply_isClicked)
self.btn_cancel = btn_cancel = QPushButton('Cancel')
btn_cancel.clicked.connect(self.close)
self.btn_OK = btn_OK = QPushButton('OK')
btn_OK.clicked.connect(self.btn_OK_isClicked)
toolbar_layout = QGridLayout()
toolbar_layout.addWidget(btn_OK, 0, 1)
toolbar_layout.addWidget(btn_cancel, 0, 2)
toolbar_layout.addWidget(btn_apply, 0, 3)
toolbar_layout.setColumnStretch(0, 100)
toolbar_widget.setLayout(toolbar_layout)
# ---- Main Layout
main_layout = QGridLayout()
main_layout.addWidget(self._setup_figure_layout_grpbox(), 0, 0)
main_layout.addWidget(self._setup_element_visibility_grpbox(), 1, 0)
main_layout.setRowStretch(2, 100)
main_layout.setRowMinimumHeight(2, 15)
main_layout.addWidget(toolbar_widget, 3, 0)
self.setLayout(main_layout)
示例14: update
def update(self):
for _ in range(self.layout().count()):
self.layout().itemAt(0).widget().close()
self.layout().takeAt(0)
qsa = QScrollArea()
scroll_area_widget = QWidget()
layout = QVBoxLayout()
scroll_area_widget.setLayout(layout)
model = self.result.model
cycles_per_ms = model.cycles_per_ms
for proc in model.processors:
proc_r = self.result.processors[proc]
gb = QGroupBox(proc.name)
gb_layout = QVBoxLayout()
gb.setLayout(gb_layout)
gb_layout.addWidget(QLabel(
"Cxt Save count: {}".format(proc_r.context_save_count)))
gb_layout.addWidget(QLabel(
"Cxt Load count: {}".format(proc_r.context_load_count)))
gb_layout.addWidget(QLabel(
"Cxt Save overhead: {0:.4f}ms ({1:.0f} cycles)".format(
float(proc_r.context_save_overhead) / cycles_per_ms,
proc_r.context_save_overhead)))
gb_layout.addWidget(QLabel(
"Cxt Load overhead: {0:.4f}ms ({1:.0f} cycles)".format(
float(proc_r.context_load_overhead) / cycles_per_ms,
proc_r.context_load_overhead)))
layout.addWidget(gb)
qsa.setWidget(scroll_area_widget)
self.layout().addWidget(qsa)
示例15: initUI
def initUI(self):
self.setWindowTitle('Twitter Client')
self.setWindowIcon(QIcon("twitter.svg"))
QIcon.setThemeName("Adwaita")
lay = QVBoxLayout(self)
scr = QScrollArea(self)
scr.setWidgetResizable(True)
scr.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
lay2 = QVBoxLayout()
self.setLayout(lay)
placehold = QWidget()
lay.addWidget(scr)
scr.setWidget(placehold)
placehold.setLayout(lay2)
self.lay = lay2
lay2.setSpacing(0)
lay.setSpacing(0)
lay.setContentsMargins(0, 0, 0, 0)
but = QPushButton("Refresh")
lay.addWidget(but)
but.pressed.connect(self.fetch_tweets)
self.show()