本文整理汇总了Python中python_qt_binding.QtGui.QHBoxLayout类的典型用法代码示例。如果您正苦于以下问题:Python QHBoxLayout类的具体用法?Python QHBoxLayout怎么用?Python QHBoxLayout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QHBoxLayout类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: restore_settings
def restore_settings(self, settings):
serial_number = settings.value('parent', None)
#print 'DockWidget.restore_settings()', 'parent', serial_number, 'settings group', settings._group
if serial_number is not None:
serial_number = int(serial_number)
if self._parent_container_serial_number() != serial_number and self._container_manager is not None:
floating = self.isFloating()
pos = self.pos()
new_container = self._container_manager.get_container(serial_number)
if new_container is not None:
new_parent = new_container.main_window
else:
new_parent = self._container_manager.get_root_main_window()
area = self.parent().dockWidgetArea(self)
new_parent.addDockWidget(area, self)
if floating:
self.setFloating(floating)
self.move(pos)
title_bar = self.titleBarWidget()
title_bar.restore_settings(settings)
if title_bar.hide_title_bar and not self.features() & DockWidget.DockWidgetFloatable and \
not self.features() & DockWidget.DockWidgetMovable:
self._title_bar_backup = title_bar
title_widget = QWidget(self)
layout = QHBoxLayout(title_widget)
layout.setContentsMargins(0, 0, 0, 0)
title_widget.setLayout(layout)
self.setTitleBarWidget(title_widget)
示例2: __init__
def __init__(self, host, masteruri=None, parent=None):
PackageDialog.__init__(self, parent)
self.host = host
self.setWindowTitle('Run')
ns_name_label = QLabel("NS/Name:", self.content)
self.ns_field = QComboBox(self.content)
self.ns_field.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed))
self.ns_field.setEditable(True)
ns_history = nm.history().cachedParamValues('run_dialog/NS')
ns_history.insert(0, '/')
self.ns_field.addItems(ns_history)
self.name_field = QLineEdit(self.content)
self.name_field.setEnabled(False)
horizontalLayout = QHBoxLayout()
horizontalLayout.addWidget(self.ns_field)
horizontalLayout.addWidget(self.name_field)
self.contentLayout.addRow(ns_name_label, horizontalLayout)
args_label = QLabel("Args:", self.content)
self.args_field = QComboBox(self.content)
self.args_field.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLength)
self.args_field.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed))
self.args_field.setEditable(True)
self.contentLayout.addRow(args_label, self.args_field)
args_history = nm.history().cachedParamValues('run_dialog/Args')
args_history.insert(0, '')
self.args_field.addItems(args_history)
host_label = QLabel("Host:", self.content)
self.host_field = QComboBox(self.content)
# self.host_field.setSizeAdjustPolicy(QComboBox.AdjustToContents)
self.host_field.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed))
self.host_field.setEditable(True)
host_label.setBuddy(self.host_field)
self.contentLayout.addRow(host_label, self.host_field)
self.host_history = host_history = nm.history().cachedParamValues('/Host')
if self.host in host_history:
host_history.remove(self.host)
host_history.insert(0, self.host)
self.host_field.addItems(host_history)
master_label = QLabel("ROS Master URI:", self.content)
self.master_field = QComboBox(self.content)
self.master_field.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed))
self.master_field.setEditable(True)
master_label.setBuddy(self.host_field)
self.contentLayout.addRow(master_label, self.master_field)
self.master_history = master_history = nm.history().cachedParamValues('/Optional Parameter/ROS Master URI')
self.masteruri = "ROS_MASTER_URI" if masteruri is None else masteruri
if self.masteruri in master_history:
master_history.remove(self.masteruri)
master_history.insert(0, self.masteruri)
self.master_field.addItems(master_history)
# self.package_field.setFocus(QtCore.Qt.TabFocusReason)
if hasattr(self.package_field, "textChanged"): # qt compatibility
self.package_field.textChanged.connect(self.on_package_selected)
else:
self.package_field.editTextChanged.connect(self.on_package_selected)
self.binary_field.activated[str].connect(self.on_binary_selected)
示例3: __init__
def __init__(self, parent = None, logger = Logger()):
QWidgetWithLogger.__init__(self, parent, logger)
# start widget
hbox = QHBoxLayout()
hbox.setMargin(0)
hbox.setContentsMargins(0, 0, 0, 0)
# get system icon
icon = QIcon.fromTheme("view-refresh")
size = icon.actualSize(QSize(32, 32))
# add combo box
self.parameter_set_names_combo_box = QComboBox()
self.parameter_set_names_combo_box.currentIndexChanged[str].connect(self.param_changed)
hbox.addWidget(self.parameter_set_names_combo_box)
# add refresh button
self.get_all_parameter_set_names_button = QPushButton()
self.get_all_parameter_set_names_button.clicked.connect(self._get_all_parameter_set_names)
self.get_all_parameter_set_names_button.setIcon(icon)
self.get_all_parameter_set_names_button.setFixedSize(size.width()+2, size.height()+2)
hbox.addWidget(self.get_all_parameter_set_names_button)
# end widget
self.setLayout(hbox)
# init widget
self.reset_parameter_set_selection()
示例4: __init__
def __init__(self, parent=None, current_values=None):
super(BlacklistDialog, self).__init__(parent)
self.setWindowTitle("Blacklist")
vbox = QVBoxLayout()
self.setLayout(vbox)
self._blacklist = Blacklist()
if isinstance(current_values, list):
for val in current_values:
self._blacklist.append(val)
vbox.addWidget(self._blacklist)
controls_layout = QHBoxLayout()
add_button = QPushButton(icon=QIcon.fromTheme('list-add'))
rem_button = QPushButton(icon=QIcon.fromTheme('list-remove'))
ok_button = QPushButton("Ok")
cancel_button = QPushButton("Cancel")
add_button.clicked.connect(self._add_item)
rem_button.clicked.connect(self._remove_item)
ok_button.clicked.connect(self.accept)
cancel_button.clicked.connect(self.reject)
controls_layout.addWidget(add_button)
controls_layout.addWidget(rem_button)
controls_layout.addStretch(0)
controls_layout.addWidget(ok_button)
controls_layout.addWidget(cancel_button)
vbox.addLayout(controls_layout)
示例5: add_widget_with_frame
def add_widget_with_frame(parent, widget, text = ""):
box_layout = QHBoxLayout()
box_layout.addWidget(widget)
group_box = QGroupBox()
group_box.setStyleSheet("QGroupBox { border: 1px solid gray; border-radius: 4px; margin-top: 0.5em; } QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 3px 0 3px; }")
group_box.setTitle(text)
group_box.setLayout(box_layout)
parent.addWidget(group_box)
示例6: __init__
def __init__(self, parent = None, logger = Logger(), step_plan_topic = str()):
QWidgetWithLogger.__init__(self, parent, logger)
# start widget
vbox = QVBoxLayout()
vbox.setMargin(0)
vbox.setContentsMargins(0, 0, 0, 0)
# step plan input topic selection
if len(step_plan_topic) == 0:
step_plan_topic_widget = QTopicWidget(topic_type = 'vigir_footstep_planning_msgs/StepPlan')
step_plan_topic_widget.topic_changed_signal.connect(self._init_step_plan_subscriber)
vbox.addWidget(step_plan_topic_widget)
else:
self._init_step_plan_subscriber(step_plan_topic)
# execute action server topic selection
execute_topic_widget = QTopicWidget(topic_type = 'vigir_footstep_planning_msgs/ExecuteStepPlanAction', is_action_topic = True)
execute_topic_widget.topic_changed_signal.connect(self._init_execute_action_client)
vbox.addWidget(execute_topic_widget)
# start button part
buttons_hbox = QHBoxLayout()
buttons_hbox.setMargin(0)
# execute
self.execute_command = QPushButton("Execute (Steps: 0)")
self.execute_command.clicked.connect(self.execute_command_callback)
self.execute_command.setEnabled(False)
buttons_hbox.addWidget(self.execute_command)
# repeat
self.repeat_command = QPushButton("Repeat")
self.repeat_command.clicked.connect(self.execute_command_callback)
self.repeat_command.setEnabled(False)
buttons_hbox.addWidget(self.repeat_command)
# stop
self.stop_command = QPushButton("Stop")
self.stop_command.clicked.connect(self.stop_command_callback)
self.stop_command.setEnabled(False)
buttons_hbox.addWidget(self.stop_command)
# end button part
vbox.addLayout(buttons_hbox)
# end widget
self.setLayout(vbox)
# init widget
if len(step_plan_topic) == 0:
step_plan_topic_widget.emit_topic_name()
execute_topic_widget.emit_topic_name()
示例7: __init__
def __init__(self, context):
super(MultiRobotPasserGUIPlugin, self).__init__(context)
# Give QObjects reasonable names
self.setObjectName('MultiRobotPasserGUIPlugin')
# Create QWidget
self.widget = QWidget()
self.master_layout = QVBoxLayout(self.widget)
self.buttons = {}
self.button_layout = QHBoxLayout()
self.master_layout.addLayout(self.button_layout)
for button_text in ["Enable", "Disable"]:
button = QPushButton(button_text, self.widget)
button.clicked[bool].connect(self.handle_button)
button.setCheckable(True)
self.button_layout.addWidget(button)
self.buttons[button_text] = button
self.widget.setObjectName('MultiRobotPasserGUIPluginUI')
if context.serial_number() > 1:
self.widget.setWindowTitle(self._widget.windowTitle() + (' (%d)' % context.serial_number()))
context.add_widget(self.widget)
self.status_subscriber = rospy.Subscriber("status", Bool, self.status_callback)
self.enable = rospy.ServiceProxy("enable", Empty)
self.disable = rospy.ServiceProxy("disable", Empty)
self.enabled = False
self.connect(self.widget, SIGNAL("update"), self.update)
示例8: __init__
def __init__(self, parent):
super(TimelineWidget, self).__init__()
self.parent = parent
self._layout = QHBoxLayout()
#self._view = QGraphicsView()
self._view = TimelineWidget.TimelineView(self)
self._scene = QGraphicsScene()
self._colors = [QColor('green'), QColor('yellow'), QColor('red')]
self._messages = [None for x in range(20)]
self._mq = [1 for x in range(20)]
self._view.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self._view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self._view.setScene(self._scene)
self._layout.addWidget(self._view, 1)
self.pause_button = QPushButton('Pause')
self.pause_button.setCheckable(True)
self.pause_button.clicked.connect(self.pause)
self._layout.addWidget(self.pause_button)
self.setLayout(self._layout)
self.update.connect(self.redraw)
示例9: __init__
def __init__(self, parent=None):
"""Create a new, empty DataPlot
This will raise a RuntimeError if none of the supported plotting
backends can be found
"""
super(DataPlot, self).__init__(parent)
self._plot_index = 0
self._color_index = 0
self._markers_on = False
self._autoscroll = True
self._autoscale_x = True
self._autoscale_y = DataPlot.SCALE_ALL
# the backend widget that we're trying to hide/abstract
self._data_plot_widget = None
self._curves = {}
self._vline = None
self._redraw.connect(self._do_redraw)
self._layout = QHBoxLayout()
self.setLayout(self._layout)
enabled_plot_types = [pt for pt in self.plot_types if pt['enabled']]
if not enabled_plot_types:
version_info = ' and PySide > 1.1.0' if QT_BINDING == 'pyside' else ''
raise RuntimeError('No usable plot type found. Install at least one of: PyQtGraph, MatPlotLib (at least 1.1.0%s) or Python-Qwt5.' % version_info)
self._switch_data_plot_widget(self._plot_index)
self.show()
示例10: __init__
def __init__(self, map_topic='/map',
paths=['/move_base/NavFn/plan', '/move_base/TrajectoryPlannerROS/local_plan'],
polygons=['/move_base/local_costmap/robot_footprint']):
super(NavViewWidget, self).__init__()
self._layout = QVBoxLayout()
self._button_layout = QHBoxLayout()
self.setAcceptDrops(True)
self.setWindowTitle('Navigation Viewer')
self.paths = paths
self.polygons = polygons
self.map = map_topic
self._tf = tf.TransformListener()
self._nav_view = NavView(map_topic, paths, polygons, tf = self._tf, parent = self)
self._set_pose = QPushButton('Set Pose')
self._set_pose.clicked.connect(self._nav_view.pose_mode)
self._set_goal = QPushButton('Set Goal')
self._set_goal.clicked.connect(self._nav_view.goal_mode)
self._button_layout.addWidget(self._set_pose)
self._button_layout.addWidget(self._set_goal)
self._layout.addLayout(self._button_layout)
self._layout.addWidget(self._nav_view)
self.setLayout(self._layout)
示例11: __init__
def __init__(self, context):
super(QuestionDialogPlugin, self).__init__(context)
# Give QObjects reasonable names
self.setObjectName('QuestionDialogPlugin')
# Create QWidget
self._widget = QWidget()
self._widget.setFont(QFont("Times", 14, QFont.Bold))
self._layout = QVBoxLayout(self._widget)
self._text_browser = QTextBrowser(self._widget)
self._layout.addWidget(self._text_browser)
self._button_layout = QHBoxLayout()
self._layout.addLayout(self._button_layout)
# layout = QVBoxLayout(self._widget)
# layout.addWidget(self.button)
self._widget.setObjectName('QuestionDialogPluginUI')
if context.serial_number() > 1:
self._widget.setWindowTitle(self._widget.windowTitle() +
(' (%d)' % context.serial_number()))
context.add_widget(self._widget)
# Setup service provider
self.service = rospy.Service('question_dialog', QuestionDialog,
self.service_callback)
self.response_ready = False
self.response = None
self.buttons = []
self.text_label = None
self.text_input = None
self.connect(self._widget, SIGNAL("update"), self.update)
self.connect(self._widget, SIGNAL("timeout"), self.timeout)
示例12: __init__
def __init__(self, parent, fileName, top_widget_layout):
self.controllers = []
self.parent = parent
self.loadFile(fileName)
print "Initialize controllers..."
for controller in self.controllers:
frame = QFrame()
frame.setFrameShape(QFrame.StyledPanel);
frame.setFrameShadow(QFrame.Raised);
vbox = QVBoxLayout()
label = QLabel()
label.setText(controller.label)
vbox.addWidget(label);
print controller.name
for joint in controller.joints:
label = QLabel()
label.setText(joint.name)
vbox.addWidget(label);
#Add input for setting the biases
widget = QWidget()
hbox = QHBoxLayout()
hbox.addWidget(joint.sensor_bias_spinbox)
hbox.addWidget(joint.control_bias_spinbox)
hbox.addWidget(joint.gearing_bias_spinbox)
widget.setLayout(hbox)
vbox.addWidget(widget)
label = QLabel()
label.setText(" Sensor Control Gearing")
vbox.addWidget(label);
vbox.addStretch()
frame.setLayout(vbox)
top_widget_layout.addWidget(frame)
print "Done loading controllers"
示例13: addOnceOrRepeat_And_VoiceRadioButtons
def addOnceOrRepeat_And_VoiceRadioButtons(self, layout):
'''
Creates radio buttons for selecting whether a
sound is to play once, or repeatedly until stopped.
Also adds radio buttons for selecting voices.
Places all in a horizontal box layout. Adds
that hbox layout to the passed-in layout.
Sets instance variables:
1. C{self.onceOrRepeatDict}
2. C{self.voicesRadioButtonsDict}
@param layout: Layout object to which the label/txt-field C{hbox} is to be added.
@type layout: QLayout
'''
hbox = QHBoxLayout();
(self.onceOrRepeatGroup, onceOrRepeatButtonLayout, self.onceOrRepeatDict) =\
self.buildRadioButtons([SpeakEasyGUI.interactionWidgets['PLAY_ONCE'],
SpeakEasyGUI.interactionWidgets['PLAY_REPEATEDLY']
],
Orientation.HORIZONTAL,
Alignment.LEFT,
activeButtons=[SpeakEasyGUI.interactionWidgets['PLAY_ONCE']],
behavior=CheckboxGroupBehavior.RADIO_BUTTONS);
self.replayPeriodSpinBox = QDoubleSpinBox(self);
self.replayPeriodSpinBox.setRange(0.0, 99.9); # seconds
self.replayPeriodSpinBox.setSingleStep(0.5);
self.replayPeriodSpinBox.setDecimals(1);
onceOrRepeatButtonLayout.addWidget(self.replayPeriodSpinBox);
secondsLabel = QLabel("secs delay");
onceOrRepeatButtonLayout.addWidget(secondsLabel);
# Create an array of voice radio button labels:
voiceRadioButtonLabels = [];
for voiceKey in SpeakEasyGUI.voices.keys():
voiceRadioButtonLabels.append(SpeakEasyGUI.interactionWidgets[voiceKey]);
(self.voicesGroup, voicesButtonLayout, self.voicesRadioButtonsDict) =\
self.buildRadioButtons(voiceRadioButtonLabels,
Orientation.HORIZONTAL,
Alignment.RIGHT,
activeButtons=[SpeakEasyGUI.interactionWidgets['VOICE_1']],
behavior=CheckboxGroupBehavior.RADIO_BUTTONS);
# Style all the radio buttons:
for playFreqButton in self.onceOrRepeatDict.values():
playFreqButton.setStyleSheet(SpeakEasyGUI.playOnceRepeatButtonStylesheet);
for playFreqButton in self.voicesRadioButtonsDict.values():
playFreqButton.setStyleSheet(SpeakEasyGUI.voiceButtonStylesheet);
#...and the replay delay spinbox:
self.replayPeriodSpinBox.setStyleSheet(SpeakEasyGUI.playRepeatSpinboxStylesheet);
#****** replayPeriodSpinBox styling
hbox.addLayout(onceOrRepeatButtonLayout);
hbox.addStretch(1);
hbox.addLayout(voicesButtonLayout);
layout.addLayout(hbox);
示例14: addTxtInputFld
def addTxtInputFld(self, layout):
'''
Creates text input field label and text field
in a horizontal box layout. Adds that hbox layout
to the passed-in layout.
Sets instance variables:
1. C{self.speechInputFld}
@param layout: Layout object to which the label/txt-field C{hbox} is to be added.
@type layout: QLayout
'''
speechControlsLayout = QHBoxLayout();
speechControlsLayout.addStretch(1);
speechInputFldLabel = QLabel("<b>What to say:</b>")
speechControlsLayout.addWidget(speechInputFldLabel);
self.speechInputFld = TextPanel(numLines=5);
self.speechInputFld.setStyleSheet(SpeakEasyGUI.inputFldStylesheet);
self.speechInputFld.setFontPointSize(SpeakEasyGUI.EDIT_FIELD_TEXT_SIZE);
speechControlsLayout.addWidget(self.speechInputFld);
layout.addLayout(speechControlsLayout);
# Create and hide the dialog for adding Cepstral voice modulation
# markup to text in the text input field:
self.speechControls = MarkupManagementUI(textPanel=self.speechInputFld, parent=self);
示例15: _create_buttons
def _create_buttons(self):
# create the buttons line
self.buttons = QWidget(self)
self.horizontalLayout = QHBoxLayout(self.buttons)
self.horizontalLayout.setContentsMargins(4, 0, 4, 0)
self.horizontalLayout.setObjectName("horizontalLayout")
# add the search button
self.searchButton = QPushButton(self)
self.searchButton.setObjectName("searchButton")
# self.searchButton.clicked.connect(self.on_shortcut_find)
self.searchButton.toggled.connect(self.on_toggled_find)
self.searchButton.setText(self._translate("&Find"))
self.searchButton.setToolTip('Open a search dialog (Ctrl+F)')
self.searchButton.setFlat(True)
self.searchButton.setCheckable(True)
self.horizontalLayout.addWidget(self.searchButton)
# add the replace button
self.replaceButton = QPushButton(self)
self.replaceButton.setObjectName("replaceButton")
# self.replaceButton.clicked.connect(self.on_shortcut_replace)
self.replaceButton.toggled.connect(self.on_toggled_replace)
self.replaceButton.setText(self._translate("&Replace"))
self.replaceButton.setToolTip('Open a search&replace dialog (Ctrl+R)')
self.replaceButton.setFlat(True)
self.replaceButton.setCheckable(True)
self.horizontalLayout.addWidget(self.replaceButton)
# add the goto button
self.gotoButton = QPushButton(self)
self.gotoButton.setObjectName("gotoButton")
self.gotoButton.clicked.connect(self.on_shortcut_goto)
self.gotoButton.setText(self._translate("&Goto line"))
self.gotoButton.setShortcut("Ctrl+G")
self.gotoButton.setToolTip('Open a goto dialog (Ctrl+G)')
self.gotoButton.setFlat(True)
self.horizontalLayout.addWidget(self.gotoButton)
# add a tag button
self.tagButton = self._create_tag_button(self)
self.horizontalLayout.addWidget(self.tagButton)
# add spacer
spacerItem = QSpacerItem(515, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem)
# add line number label
self.pos_label = QLabel()
self.horizontalLayout.addWidget(self.pos_label)
# add spacer
spacerItem = QSpacerItem(515, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem)
# add save button
self.saveButton = QPushButton(self)
self.saveButton.setObjectName("saveButton")
self.saveButton.clicked.connect(self.on_saveButton_clicked)
self.saveButton.setText(self._translate("&Save"))
self.saveButton.setShortcut("Ctrl+S")
self.saveButton.setToolTip('Save the changes to the file (Ctrl+S)')
self.saveButton.setFlat(True)
self.horizontalLayout.addWidget(self.saveButton)
return self.buttons