本文整理汇总了Python中PyQt5.QtWidgets.QBoxLayout.addWidget方法的典型用法代码示例。如果您正苦于以下问题:Python QBoxLayout.addWidget方法的具体用法?Python QBoxLayout.addWidget怎么用?Python QBoxLayout.addWidget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QBoxLayout
的用法示例。
在下文中一共展示了QBoxLayout.addWidget方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt5.QtWidgets import QBoxLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QBoxLayout import addWidget [as 别名]
def __init__(self):
super().__init__()
# information widget
self.plotWidget = VariantPlotWidget()
self.infoWidget = VariantInfoWidget()
# splitter settings
splitter = QSplitter(Qt.Horizontal)
splitter.addWidget(self.plotWidget)
splitter.addWidget(self.infoWidget)
splitter.setStretchFactor(0, 3)
splitter.setStretchFactor(1, 1)
# layout
layout = QBoxLayout(QBoxLayout.TopToBottom)
layout.addWidget(splitter)
self.setLayout(layout)
# connect signals
self.plotWidget.curvePlotted.connect(self.infoWidget.updateResults)
self.plotWidget.plotReady.connect(self.infoWidget.showResults)
self.plotWidget.cleared.connect(self.infoWidget.clear)
self.infoWidget.legendChanged.connect(self.plotWidget.paintCalculation)
# translate the graphical user interface
self.retranslateUi()
示例2: GUI
# 需要导入模块: from PyQt5.QtWidgets import QBoxLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QBoxLayout import addWidget [as 别名]
class GUI(QDialog):
def __init__(self, settings):
super(QDialog, self).__init__()
self.setWindowTitle("Settings")
self.setWindowIcon(QIcon('ui/icon.png'))
self.setModal(True)
self.setWindowFlags(Qt.WindowStaysOnTopHint)
self._button_box = QDialogButtonBox(
QDialogButtonBox.Ok
)
self._button_box.button(QDialogButtonBox.Ok).clicked.connect(self.accept)
self._tabs = QTabWidget()
self._layout = QBoxLayout(QBoxLayout.TopToBottom)
self._layout.addWidget(self._tabs)
self._layout.addWidget(self._button_box)
self.setLayout(self._layout)
# setup tabs
self.tab_list = {}
self.widgets = {}
# general tab
general_tab = GeneralTab(settings)
self._tabs.addTab(general_tab, general_tab.get_title())
characters_tab = CharactersTab(settings)
self._tabs.addTab(characters_tab, characters_tab.get_title())
def set_show_tab(self, tab):
if tab == "characters":
self._tabs.setCurrentIndex(1)
示例3: __init__
# 需要导入模块: from PyQt5.QtWidgets import QBoxLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QBoxLayout import addWidget [as 别名]
def __init__(self, algorithms):
super(Window, self).__init__()
self.stackedWidget = QStackedWidget()
self.orientationCombo = QComboBox()
for category in categories:
pass
for algorithm in algorithms:
self.orientationCombo.addItem(algorithm.get_name())
self.stackedWidget.addWidget(GroupOfSliders(algorithm))
layout = QBoxLayout(QBoxLayout.TopToBottom)
settings_layout = QBoxLayout(QBoxLayout.TopToBottom)
settings_layout.addWidget(self.stackedWidget)
select_layout = QBoxLayout(QBoxLayout.TopToBottom)
select_layout.addWidget(self.orientationCombo)
layout.addItem(settings_layout)
layout.addItem(select_layout)
self.setLayout(layout)
self.setWindowTitle(algorithm.get_name() + " Settings")
示例4: __init__
# 需要导入模块: from PyQt5.QtWidgets import QBoxLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QBoxLayout import addWidget [as 别名]
def __init__(self, message, title):
super(ErrorMessage, self).__init__()
self.message = message
# self.setWindowTitle(title)
self.setStyleSheet(style.style_loader.stylesheet)
self.label = QLabel(str(self.message), self)
self.label_widget = QWidget(self)
label_layout = QBoxLayout(QBoxLayout.LeftToRight)
label_layout.addWidget(self.label)
self.label_widget.setLayout(label_layout)
self.submit_btn = QPushButton('OK', self)
self.submit_btn.clicked.connect(self.submit)
self.submit_btn_widget = QWidget(self)
submit_btn_layout = QBoxLayout(QBoxLayout.LeftToRight)
submit_btn_layout.addWidget(self.submit_btn)
self.submit_btn_widget.setLayout(submit_btn_layout)
layout = QFormLayout()
layout.addRow(self.label_widget)
layout.addRow(self.submit_btn_widget)
self.setLayout(layout)
self.show()
self.setFixedHeight(self.height())
self.setFixedWidth(self.width())
self.close()
示例5: ComboBoxWidget
# 需要导入模块: from PyQt5.QtWidgets import QBoxLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QBoxLayout import addWidget [as 别名]
class ComboBoxWidget(QGroupBox):
"""
This is the combobox widget as it is shown in the settings
panel of the GUI. It gets initialized with a name
With self.valueChanged on can connect a pyqt slot with the
combobox pyqtSignal.
"""
def __init__(self, name, options, slot=None, default=None):
super(ComboBoxWidget, self).__init__()
self.activated = pyqtSignal()
# ComboBox itself
self.combobox = QtWidgets.QComboBox()
self.combobox.orientationCombo = PyQt5.QtWidgets.QComboBox()
self.combobox.setFixedWidth(220)
# Label
self.label = QtWidgets.QLabel()
self.label.setText(name + ": ")
self.SingleCheckBoxLayout = QBoxLayout(QBoxLayout.LeftToRight)
self.SingleCheckBoxLayout.addWidget(self.label)
self.SingleCheckBoxLayout.addWidget(self.combobox, Qt.AlignRight)
self.setLayout(self.SingleCheckBoxLayout)
self.setFixedHeight(70)
self.setFlat(True)
# options
for i in options:
self.add_item(i)
if default is not None:
index = self.combobox.findText(default)
if index != -1:
self.combobox.setCurrentIndex(index)
if slot is not None:
self.combobox.activated.connect(slot)
def add_item(self, option, image=None):
"""
Args:
| *option*: A string option refers to an entry which can be selected in the combobox later.
| *image*: An optional icon that can be shown combobox.
"""
if image is None:
self.combobox.addItem(option)
else:
self.combobox.addItem(QIcon(image), option)
示例6: GroupOfImages
# 需要导入模块: from PyQt5.QtWidgets import QBoxLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QBoxLayout import addWidget [as 别名]
class GroupOfImages(QGroupBox):
def __init__(self):
super(GroupOfImages, self).__init__()
self.GroupOfImagesLayout = QBoxLayout(QBoxLayout.TopToBottom)
GroupOfImages.setFixedHeight(self, 300)
GroupOfImages.setFixedWidth(self, 300)
self.height = 300
def addImage(self, image):
self.GroupOfImagesLayout.addWidget(image)
self.height += 300
GroupOfImages.setFixedHeight(self, self.height + 300)
self.setLayout(self.GroupOfImagesLayout)
def removeImage(self, image):
self.GroupOfImagesLayout.removeWidget(image)
self.setLayout(self.GroupOfImagesLayout)
def refreshView(self):
self.setLayout(self.GroupOfImagesLayout)
示例7: __init__
# 需要导入模块: from PyQt5.QtWidgets import QBoxLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QBoxLayout import addWidget [as 别名]
def __init__(self, orientation, title, parent=None):
super(SlidersGroup, self).__init__(title, parent)
self.slider = QSlider(orientation)
self.slider.setFocusPolicy(Qt.StrongFocus)
self.slider.setTickPosition(QSlider.TicksBothSides)
self.slider.setTickInterval(10)
self.slider.setSingleStep(1)
self.scrollBar = QScrollBar(orientation)
self.scrollBar.setFocusPolicy(Qt.StrongFocus)
self.dial = QDial()
self.dial.setFocusPolicy(Qt.StrongFocus)
self.slider.valueChanged.connect(self.scrollBar.setValue)
self.scrollBar.valueChanged.connect(self.dial.setValue)
self.dial.valueChanged.connect(self.slider.setValue)
self.dial.valueChanged.connect(self.valueChanged)
if orientation == Qt.Horizontal:
direction = QBoxLayout.TopToBottom
else:
direction = QBoxLayout.LeftToRight
slidersLayout = QBoxLayout(direction)
slidersLayout.addWidget(self.slider)
slidersLayout.addWidget(self.scrollBar)
slidersLayout.addWidget(self.dial)
self.setLayout(slidersLayout)
示例8: __init__
# 需要导入模块: from PyQt5.QtWidgets import QBoxLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QBoxLayout import addWidget [as 别名]
def __init__(self):
super(Window, self).__init__()
global current_state
current_state = dict(screen_data)
self.createControls()
self.createCommandBox()
self.brightnessSliders = SlidersGroup(self.commandBox)
self.stackedWidget = QStackedWidget()
self.stackedWidget.addWidget(self.brightnessSliders)
layout = QBoxLayout(QBoxLayout.TopToBottom)
layout.addWidget(self.stackedWidget)
layout.addWidget(self.commandBoxGroup)
layout.addWidget(self.controlsGroup)
self.setLayout(layout)
self.setWindowTitle("Brightness editor")
self.resize(850, 500)
command = "# get display names and brightness values\n" + \
get_brightness_command + "\n" + \
"# results (formatted): " + str(screen_data)
if primary != None:
command += " primary: " + screen_data[primary][0]
self.commandBox.document().setPlainText(command)
示例9: __init__
# 需要导入模块: from PyQt5.QtWidgets import QBoxLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QBoxLayout import addWidget [as 别名]
def __init__(self, parent=None):
super(AddConfigurationDialog, self).__init__(parent)
self._layout = QBoxLayout(QBoxLayout.TopToBottom)
self.setLayout(self._layout)
self.setWindowTitle('Add configuration')
self._nameField = QLineEdit()
name_form_layout = QFormLayout()
name_form_layout.addRow('Name:', self._nameField)
self._layout.addLayout(name_form_layout)
self._layout.addWidget(QLabel("You won't be able to change this name later."))
self._cancelButton = QPushButton("Cancel")
self._saveButton = QPushButton("Create")
button_layout = QBoxLayout(QBoxLayout.LeftToRight)
button_layout.addWidget(self._cancelButton)
button_layout.addWidget(self._saveButton)
self._layout.addLayout(button_layout)
self._configuration = None
self._cancelButton.clicked.connect(self.reject)
self._saveButton.clicked.connect(self._saved)
示例10: AddConfigurationDialog
# 需要导入模块: from PyQt5.QtWidgets import QBoxLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QBoxLayout import addWidget [as 别名]
class AddConfigurationDialog(QDialog):
def __init__(self, parent=None):
super(AddConfigurationDialog, self).__init__(parent)
self._layout = QBoxLayout(QBoxLayout.TopToBottom)
self.setLayout(self._layout)
self.setWindowTitle('Add configuration')
self._nameField = QLineEdit()
name_form_layout = QFormLayout()
name_form_layout.addRow('Name:', self._nameField)
self._layout.addLayout(name_form_layout)
self._layout.addWidget(QLabel("You won't be able to change this name later."))
self._cancelButton = QPushButton("Cancel")
self._saveButton = QPushButton("Create")
button_layout = QBoxLayout(QBoxLayout.LeftToRight)
button_layout.addWidget(self._cancelButton)
button_layout.addWidget(self._saveButton)
self._layout.addLayout(button_layout)
self._configuration = None
self._cancelButton.clicked.connect(self.reject)
self._saveButton.clicked.connect(self._saved)
def _saved(self):
name = self._nameField.text()
self._configuration = Configuration(name)
data = DataStorage()
data.add_configuration(self._configuration)
data.persist()
self.accept()
def get_configuration(self):
"""
Returns the created configuration if called after executing the dialog or None otherwise.
:rtype: Configuration
"""
return self._configuration
示例11: __init__
# 需要导入模块: from PyQt5.QtWidgets import QBoxLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QBoxLayout import addWidget [as 别名]
def __init__(self, parent):
super(RoundManagerWidget, self).__init__(parent)
self.parent = parent
self.sort_order = 'by_name'
view.notifier.observers.append(self)
timer = QTimer(self)
timer.timeout.connect(self.update)
timer.start()
self.header_label = QLabel('Round')
self.header_widget = QWidget(self)
header_layout = QBoxLayout(QBoxLayout.LeftToRight)
header_layout.addWidget(self.header_label)
self.header_widget.setLayout(header_layout)
self.submit_btn = QPushButton(self)
self.submit_btn.clicked.connect(self.submit)
self.submit_btn_widget = QWidget(self)
submit_btn_layout = QBoxLayout(QBoxLayout.LeftToRight)
submit_btn_layout.addWidget(self.submit_btn)
self.submit_btn_widget.setLayout(submit_btn_layout)
self.round_info = QLabel()
self.round_info.setAlignment(Qt.AlignCenter)
self.timer_display = QLabel()
self.timer_display.setAlignment(Qt.AlignCenter)
self.info_widget = QWidget(self)
info_layout = QBoxLayout(QBoxLayout.LeftToRight)
info_layout.addWidget(self.round_info)
info_layout.addWidget(self.timer_display)
self.info_widget.setLayout(info_layout)
self.error = None
layout = QFormLayout()
layout.addRow(self.header_widget)
layout.addRow(self.submit_btn_widget)
layout.addRow(self.info_widget)
self.setLayout(layout)
self.update()
示例12: __init__
# 需要导入模块: from PyQt5.QtWidgets import QBoxLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QBoxLayout import addWidget [as 别名]
def __init__(self, *args, **kwargs):
# set parent
super().__init__(kwargs['main_window'])
self.setModal(True)
self.show()
self.setWindowTitle("New Course")
self.setFixedSize(400, 150)
# main widget
#main_widget = QWidget()
main_layout = QBoxLayout(QBoxLayout.TopToBottom)
# form widget
form_widget = QWidget()
form_layout = QFormLayout()
form_layout.setFormAlignment(QtCore.Qt.AlignLeft)
new_course_label = QLabel("Course Name:")
new_course_entry = CustomLineEdit(default_entry="<Enter course name>")
new_course_entry.setFixedWidth(230)
form_layout.addRow(new_course_label, new_course_entry)
form_widget.setLayout(form_layout)
# action buttons
action_widget = QWidget()
add_course_button = QPushButton("Add Course")
cancel_button = QPushButton("Cancel")
action_layout = QBoxLayout(QBoxLayout.LeftToRight)
action_layout.addWidget(cancel_button)
action_layout.addWidget(add_course_button)
action_widget.setLayout(action_layout)
action_widget.setTabOrder(add_course_button, cancel_button)
# add widgets
main_layout.addWidget(form_widget)
main_layout.addWidget(action_widget)
self.setLayout(main_layout)
new_course_entry.setFocus()
new_course_entry.selectAll()
示例13: SliderWidget
# 需要导入模块: from PyQt5.QtWidgets import QBoxLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QBoxLayout import addWidget [as 别名]
class SliderWidget(QGroupBox):
valueChanged = pyqtSignal()
def __init__(self, name, lower, upper, step_size, default, float_flag):
super(SliderWidget, self).__init__()
self.internal_steps = abs(upper - lower) / step_size
def to_internal_coordinate(self, value):
return (self.internal_steps / (upper - lower)) * (value - lower)
def to_external_coordinate(self, value):
return lower + (value * (upper - lower)) / self.internal_steps
# Slider itself
self.slider = \
Slider(0, self.internal_steps, 1, to_internal_coordinate(self, default)) \
.slider
# Textfield
if float_flag:
self.textfield = \
DoubleTextfield(lower, upper, step_size, default) \
.textfield
else:
self.textfield = \
IntegerTextfield(lower, upper, step_size, default)\
.textfield
# Label
self.label = QLabel()
self.label.setText(name + ": ")
# Connect Textfield with Slider
def textfield_value_changed(value):
self.slider.setValue(to_internal_coordinate(self, value))
def slider_value_changed(value):
self.textfield.setValue(to_external_coordinate(self, value))
self.textfield.valueChanged.connect(textfield_value_changed)
self.slider.valueChanged.connect(slider_value_changed)
self.SingleSlidersLayout = QBoxLayout(QBoxLayout.LeftToRight)
self.SingleSlidersLayout.addWidget(self.label)
self.SingleSlidersLayout.addWidget(self.slider)
self.SingleSlidersLayout.addWidget(self.textfield)
self.setLayout(self.SingleSlidersLayout)
self.setFixedHeight(50)
self.setFlat(True)
示例14: __init__
# 需要导入模块: from PyQt5.QtWidgets import QBoxLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QBoxLayout import addWidget [as 别名]
def __init__(self):
super(AddPlayerWidget, self).__init__()
self.users = {}
# self.setWindowTitle('Add Player')
self.setStyleSheet(style.style_loader.stylesheet)
self.label = QLabel('Enter Name:', self)
self.label_widget = QWidget(self)
label_layout = QBoxLayout(QBoxLayout.LeftToRight)
label_layout.addWidget(self.label)
self.label_widget.setLayout(label_layout)
self.user_box = QComboBox(self)
self.user_box.setFixedWidth(210)
self.user_box.setFixedHeight(50)
self.user_box_widget = QWidget(self)
user_box_layout = QBoxLayout(QBoxLayout.LeftToRight)
user_box_layout.addWidget(self.user_box)
self.user_box_widget.setLayout(user_box_layout)
self.submit_btn = QPushButton('Add Player', self)
self.submit_btn.clicked.connect(self.submit)
self.submit_btn_widget = QWidget(self)
submit_btn_layout = QBoxLayout(QBoxLayout.LeftToRight)
submit_btn_layout.addWidget(self.submit_btn)
self.submit_btn_widget.setLayout(submit_btn_layout)
layout = QFormLayout()
layout.addRow(self.label_widget)
layout.addRow(self.user_box_widget)
layout.addRow(self.submit_btn_widget)
self.setLayout(layout)
self.show()
self.setFixedHeight(self.height())
self.setFixedWidth(self.width())
self.close()
示例15: __init__
# 需要导入模块: from PyQt5.QtWidgets import QBoxLayout [as 别名]
# 或者: from PyQt5.QtWidgets.QBoxLayout import addWidget [as 别名]
def __init__(self, parent):
super(PairingsWidget, self).__init__(parent)
self.parent = parent
view.notifier.observers.append(self)
self.header_label = QLabel('Pairings')
self.header_widget = QWidget(self)
header_layout = QBoxLayout(QBoxLayout.TopToBottom)
header_layout.addWidget(self.header_label)
self.header_widget.setLayout(header_layout)
self.pairings_list = QTableWidget(style.style_loader.TABLE_INITIAL_LENGTH, 2, self)
self.pairings_list.setFixedHeight(300)
self.pairings_list.setFixedWidth(400)
self.pairings_list.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
self.pairings_list.verticalHeader().setSectionResizeMode(QHeaderView.Fixed)
self.pairings_list_widget = QWidget(self)
pairings_list_layout = QBoxLayout(QBoxLayout.LeftToRight)
pairings_list_layout.addWidget(self.pairings_list)
self.pairings_list_widget.setLayout(pairings_list_layout)
self.report_btn = QPushButton('Report Results', self)
self.report_btn.clicked.connect(parent.show_report_result_widget)
self.report_btn_widget = QWidget(self)
report_btn_layout = QBoxLayout(QBoxLayout.LeftToRight)
report_btn_layout.addWidget(self.report_btn)
self.report_btn_widget.setLayout(report_btn_layout)
layout = QFormLayout()
layout.addRow(self.header_widget)
layout.addRow(self.pairings_list_widget)
layout.addRow(self.report_btn_widget)
self.setLayout(layout)
self.update()