本文整理汇总了Python中python_qt_binding.QtGui.QHBoxLayout.setContentsMargins方法的典型用法代码示例。如果您正苦于以下问题:Python QHBoxLayout.setContentsMargins方法的具体用法?Python QHBoxLayout.setContentsMargins怎么用?Python QHBoxLayout.setContentsMargins使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类python_qt_binding.QtGui.QHBoxLayout
的用法示例。
在下文中一共展示了QHBoxLayout.setContentsMargins方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: restore_settings
# 需要导入模块: from python_qt_binding.QtGui import QHBoxLayout [as 别名]
# 或者: from python_qt_binding.QtGui.QHBoxLayout import setContentsMargins [as 别名]
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__
# 需要导入模块: from python_qt_binding.QtGui import QHBoxLayout [as 别名]
# 或者: from python_qt_binding.QtGui.QHBoxLayout import setContentsMargins [as 别名]
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()
示例3: PathEditor
# 需要导入模块: from python_qt_binding.QtGui import QHBoxLayout [as 别名]
# 或者: from python_qt_binding.QtGui.QHBoxLayout import setContentsMargins [as 别名]
class PathEditor(QWidget):
'''
This is a path editor used as ItemDeligate in settings view. This editor
provides an additional button for directory selection dialog.
'''
editing_finished_signal = Signal()
def __init__(self, path, parent=None):
QWidget.__init__(self, parent)
self.path = path
self._layout = QHBoxLayout(self)
self._layout.setContentsMargins(0, 0, 0, 0)
self._layout.setSpacing(0)
self._button = QPushButton('...')
self._button.setMaximumSize(QSize(24, 20))
self._button.clicked.connect(self._on_path_select_clicked)
self._layout.addWidget(self._button)
self._lineedit = QLineEdit(path)
self._lineedit.returnPressed.connect(self._on_editing_finished)
self._layout.addWidget(self._lineedit)
self.setLayout(self._layout)
self.setFocusProxy(self._button)
self.setAutoFillBackground(True)
def _on_path_select_clicked(self):
# Workaround for QFileDialog.getExistingDirectory because it do not
# select the configuration folder in the dialog
self.dialog = QFileDialog(self, caption='Select a new settings folder')
self.dialog.setOption(QFileDialog.HideNameFilterDetails, True)
self.dialog.setFileMode(QFileDialog.Directory)
self.dialog.setDirectory(self.path)
if self.dialog.exec_():
fileNames = self.dialog.selectedFiles()
path = fileNames[0]
if os.path.isfile(path):
path = os.path.basename(path)
self._lineedit.setText(path)
self.path = dir
self.editing_finished_signal.emit()
def _on_editing_finished(self):
if self._lineedit.text():
self.path = self._lineedit.text()
self.editing_finished_signal.emit()
示例4: _create_replace_frame
# 需要导入模块: from python_qt_binding.QtGui import QHBoxLayout [as 别名]
# 或者: from python_qt_binding.QtGui.QHBoxLayout import setContentsMargins [as 别名]
def _create_replace_frame(self):
# create frame with replace row
self.rplc_frame = rplc_frame = QFrame(self)
rplc_hbox_layout = QHBoxLayout(rplc_frame)
rplc_hbox_layout.setContentsMargins(0, 0, 0, 0)
rplc_hbox_layout.setSpacing(1)
self.replace_field = EnchancedLineEdit(rplc_frame)
self.replace_field.setPlaceholderText('replace text')
self.replace_field.returnPressed.connect(self.on_replace)
rplc_hbox_layout.addWidget(self.replace_field)
self.replace_result_label = QLabel(rplc_frame)
self.replace_result_label.setText(' ')
rplc_hbox_layout.addWidget(self.replace_result_label)
self.replace_button = replace_button = QPushButton("> &Replace >")
replace_button.setFixedWidth(90)
replace_button.clicked.connect(self.on_replace_click)
rplc_hbox_layout.addWidget(replace_button)
rplc_frame.setVisible(False)
return rplc_frame
示例5: __init__
# 需要导入模块: from python_qt_binding.QtGui import QHBoxLayout [as 别名]
# 或者: from python_qt_binding.QtGui.QHBoxLayout import setContentsMargins [as 别名]
def __init__(self, masteruri, cfg, ns, nodes, parent=None):
QFrame.__init__(self, parent)
self._masteruri = masteruri
self._nodes = {cfg: {ns: nodes}}
frame_layout = QVBoxLayout(self)
frame_layout.setContentsMargins(0, 0, 0, 0)
# create frame for warning label
self.warning_frame = warning_frame = QFrame(self)
warning_layout = QHBoxLayout(warning_frame)
warning_layout.setContentsMargins(0, 0, 0, 0)
warning_layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding))
self.warning_label = QLabel()
icon = QIcon(':/icons/crystal_clear_warning.png')
self.warning_label.setPixmap(icon.pixmap(QSize(40, 40)))
self.warning_label.setToolTip('Multiple configuration for same node found!\nA first one will be selected for the start a node!')
warning_layout.addWidget(self.warning_label)
warning_layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding))
frame_layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding))
frame_layout.addWidget(warning_frame)
# create frame for start/stop buttons
buttons_frame = QFrame()
buttons_layout = QHBoxLayout(buttons_frame)
buttons_layout.setContentsMargins(0, 0, 0, 0)
buttons_layout.addItem(QSpacerItem(20, 20))
self.on_button = QPushButton()
self.on_button.setFlat(False)
self.on_button.setText("On")
self.on_button.clicked.connect(self.on_on_clicked)
buttons_layout.addWidget(self.on_button)
self.off_button = QPushButton()
self.off_button.setFlat(True)
self.off_button.setText("Off")
self.off_button.clicked.connect(self.on_off_clicked)
buttons_layout.addWidget(self.off_button)
buttons_layout.addItem(QSpacerItem(20, 20))
frame_layout.addWidget(buttons_frame)
frame_layout.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding))
self.warning_frame.setVisible(False)
示例6: __init__
# 需要导入模块: from python_qt_binding.QtGui import QHBoxLayout [as 别名]
# 或者: from python_qt_binding.QtGui.QHBoxLayout import setContentsMargins [as 别名]
def __init__(self, parent = None, topic_type = str(), is_action_topic = False):
QWidget.__init__(self, parent)
if is_action_topic:
self.topic_type = topic_type + "Goal"
else:
self.topic_type = topic_type
self.is_action_topic = is_action_topic
# start widget
hbox = QHBoxLayout()
hbox.setMargin(0)
hbox.setContentsMargins(0, 0, 0, 0)
# topic combo box
self.topic_combo_box = QComboBox()
self.topic_combo_box.setEnabled(False)
self.topic_combo_box.blockSignals(True)
self.topic_combo_box.setValidator(QRegExpValidator(QRegExp('((\d|\w|/)(?!//))*'), self))
self.topic_combo_box.currentIndexChanged[str].connect(self.topic_changed)
hbox.addWidget(self.topic_combo_box)
# get system icon
icon = QIcon.fromTheme("view-refresh")
size = icon.actualSize(QSize(32, 32))
# add refresh button
refresh_topics_button = QPushButton()
refresh_topics_button.clicked.connect(self.update_topic_list)
refresh_topics_button.setIcon(icon)
refresh_topics_button.setFixedSize(size.width()+2, size.height()+2)
hbox.addWidget(refresh_topics_button)
# end widget
self.setLayout(hbox)
# init widget
self.update_topic_list()
示例7: _create_find_frame
# 需要导入模块: from python_qt_binding.QtGui import QHBoxLayout [as 别名]
# 或者: from python_qt_binding.QtGui.QHBoxLayout import setContentsMargins [as 别名]
def _create_find_frame(self):
find_frame = QFrame(self)
find_hbox_layout = QHBoxLayout(find_frame)
find_hbox_layout.setContentsMargins(0, 0, 0, 0)
find_hbox_layout.setSpacing(1)
self.search_field = EnchancedLineEdit(find_frame)
self.search_field.setPlaceholderText('search text')
self.search_field.textChanged.connect(self.on_search_text_changed)
self.search_field.returnPressed.connect(self.on_search)
find_hbox_layout.addWidget(self.search_field)
self.search_result_label = QLabel(find_frame)
self.search_result_label.setText(' ')
find_hbox_layout.addWidget(self.search_result_label)
self.find_button_back = QPushButton("<")
self.find_button_back.setFixedWidth(44)
self.find_button_back.clicked.connect(self.on_search_back)
find_hbox_layout.addWidget(self.find_button_back)
self.find_button = QPushButton(">")
self.find_button.setDefault(True)
# self.find_button.setFlat(True)
self.find_button.setFixedWidth(44)
self.find_button.clicked.connect(self.on_search)
find_hbox_layout.addWidget(self.find_button)
return find_frame
示例8: __init__
# 需要导入模块: from python_qt_binding.QtGui import QHBoxLayout [as 别名]
# 或者: from python_qt_binding.QtGui.QHBoxLayout import setContentsMargins [as 别名]
def __init__(self, updater, config, nodename):
'''
:param config:
:type config: Dictionary? defined in dynamic_reconfigure.client.Client
:type nodename: str
'''
#TODO figure out what data type 'config' is. It is afterall returned
# from dynamic_reconfigure.client.get_parameter_descriptions()
# ros.org/doc/api/dynamic_reconfigure/html/dynamic_reconfigure.client-pysrc.html#Client
super(GroupWidget, self).__init__()
self.state = config['state']
self.name = config['name']
self._toplevel_treenode_name = nodename
# TODO: .ui file needs to be back into usage in later phase.
# ui_file = os.path.join(rp.get_path('rqt_reconfigure'),
# 'resource', 'singlenode_parameditor.ui')
# loadUi(ui_file, self)
verticalLayout = QVBoxLayout(self)
verticalLayout.setContentsMargins(QMargins(0, 0, 0, 0))
_widget_nodeheader = QWidget()
_h_layout_nodeheader = QHBoxLayout(_widget_nodeheader)
_h_layout_nodeheader.setContentsMargins(QMargins(0, 0, 0, 0))
self.nodename_qlabel = QLabel(self)
font = QFont('Trebuchet MS, Bold')
font.setUnderline(True)
font.setBold(True)
# Button to close a node.
_icon_disable_node = QIcon.fromTheme('window-close')
_bt_disable_node = QPushButton(_icon_disable_node, '', self)
_bt_disable_node.setToolTip('Hide this node')
_bt_disable_node_size = QSize(36, 24)
_bt_disable_node.setFixedSize(_bt_disable_node_size)
_bt_disable_node.pressed.connect(self._node_disable_bt_clicked)
_h_layout_nodeheader.addWidget(self.nodename_qlabel)
_h_layout_nodeheader.addWidget(_bt_disable_node)
self.nodename_qlabel.setAlignment(Qt.AlignCenter)
font.setPointSize(10)
self.nodename_qlabel.setFont(font)
grid_widget = QWidget(self)
self.grid = QFormLayout(grid_widget)
verticalLayout.addWidget(_widget_nodeheader)
verticalLayout.addWidget(grid_widget, 1)
# Again, these UI operation above needs to happen in .ui file.
self.tab_bar = None # Every group can have one tab bar
self.tab_bar_shown = False
self.updater = updater
self.editor_widgets = []
self._param_names = []
self._create_node_widgets(config)
rospy.logdebug('Groups node name={}'.format(nodename))
self.nodename_qlabel.setText(nodename)
示例9: __init__
# 需要导入模块: from python_qt_binding.QtGui import QHBoxLayout [as 别名]
# 或者: from python_qt_binding.QtGui.QHBoxLayout import setContentsMargins [as 别名]
def __init__(self, items=list(), buttons=QDialogButtonBox.Cancel | QDialogButtonBox.Ok, exclusive=False,
preselect_all=False, title='', description='', icon='', parent=None, select_if_single=True,
checkitem1='', checkitem2=''):
'''
Creates an input dialog.
@param items: a list with strings
@type items: C{list()}
'''
QDialog.__init__(self, parent=parent)
self.setObjectName(' - '.join(['SelectDialog', str(items)]))
self.verticalLayout = QVBoxLayout(self)
self.verticalLayout.setObjectName("verticalLayout")
self.verticalLayout.setContentsMargins(1, 1, 1, 1)
# add filter row
self.filter_frame = QFrame(self)
filterLayout = QHBoxLayout(self.filter_frame)
filterLayout.setContentsMargins(1, 1, 1, 1)
label = QLabel("Filter:", self.filter_frame)
self.filter_field = EnchancedLineEdit(self.filter_frame)
filterLayout.addWidget(label)
filterLayout.addWidget(self.filter_field)
self.filter_field.textChanged.connect(self._on_filter_changed)
self.verticalLayout.addWidget(self.filter_frame)
if description:
self.description_frame = QFrame(self)
descriptionLayout = QHBoxLayout(self.description_frame)
# descriptionLayout.setContentsMargins(1, 1, 1, 1)
if icon:
self.icon_label = QLabel(self.description_frame)
self.icon_label.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
self.icon_label.setPixmap(QPixmap(icon).scaled(30, 30, Qt.KeepAspectRatio))
descriptionLayout.addWidget(self.icon_label)
self.description_label = QLabel(self.description_frame)
self.description_label.setWordWrap(True)
self.description_label.setText(description)
descriptionLayout.addWidget(self.description_label)
self.verticalLayout.addWidget(self.description_frame)
# create area for the parameter
self.content = MainBox(self)
if items:
self.scroll_area = QScrollArea(self)
self.scroll_area.setFocusPolicy(Qt.NoFocus)
self.scroll_area.setObjectName("scroll_area")
self.scroll_area.setWidgetResizable(True)
self.scroll_area.setWidget(self.content)
self.verticalLayout.addWidget(self.scroll_area)
self.checkitem1 = checkitem1
self.checkitem1_result = False
self.checkitem2 = checkitem2
self.checkitem2_result = False
# add select all option
if not exclusive and items:
self._ignore_next_toggle = False
self.select_all_checkbox = QCheckBox('all entries')
self.select_all_checkbox.setTristate(True)
self.select_all_checkbox.stateChanged.connect(self._on_select_all_checkbox_stateChanged)
self.verticalLayout.addWidget(self.select_all_checkbox)
self.content.toggled.connect(self._on_main_toggle)
if self.checkitem1:
self.checkitem1_checkbox = QCheckBox(self.checkitem1)
self.checkitem1_checkbox.stateChanged.connect(self._on_select_checkitem1_checkbox_stateChanged)
self.verticalLayout.addWidget(self.checkitem1_checkbox)
if self.checkitem2:
self.checkitem2_checkbox = QCheckBox(self.checkitem2)
self.checkitem2_checkbox.stateChanged.connect(self._on_select_checkitem2_checkbox_stateChanged)
self.verticalLayout.addWidget(self.checkitem2_checkbox)
if not items:
spacerItem = QSpacerItem(1, 1, QSizePolicy.Expanding, QSizePolicy.Expanding)
self.verticalLayout.addItem(spacerItem)
# create buttons
self.buttonBox = QDialogButtonBox(self)
self.buttonBox.setObjectName("buttonBox")
self.buttonBox.setOrientation(Qt.Horizontal)
self.buttonBox.setStandardButtons(buttons)
self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject)
self.verticalLayout.addWidget(self.buttonBox)
# set the input fields
if items:
self.content.createFieldsFromValues(items, exclusive)
if (select_if_single and len(items) == 1) or preselect_all:
self.select_all_checkbox.setCheckState(Qt.Checked)
if not items or len(items) < 7:
self.filter_frame.setVisible(False)
示例10: Editor
# 需要导入模块: from python_qt_binding.QtGui import QHBoxLayout [as 别名]
# 或者: from python_qt_binding.QtGui.QHBoxLayout import setContentsMargins [as 别名]
class Editor(QMainWindow):
'''
Creates a dialog to edit a launch file.
'''
finished_signal = Signal(list)
'''
finished_signal has as parameter the filenames of the initialization and is emitted, if this
dialog was closed.
'''
def __init__(self, filenames, search_text='', parent=None):
'''
@param filenames: a list with filenames. The last one will be activated.
@type filenames: C{[str, ...]}
@param search_text: if not empty, searches in new document for first occurrence of the given text
@type search_text: C{str} (Default: C{Empty String})
'''
QMainWindow.__init__(self, parent)
self.setObjectName(' - '.join(['Editor', str(filenames)]))
self.setAttribute(Qt.WA_DeleteOnClose, True)
self.setWindowFlags(Qt.Window)
self.mIcon = QIcon(":/icons/crystal_clear_edit_launch.png")
self._error_icon = QIcon(":/icons/crystal_clear_warning.png")
self._empty_icon = QIcon()
self.setWindowIcon(self.mIcon)
window_title = "ROSLaunch Editor"
if filenames:
window_title = self.__getTabName(filenames[0])
self.setWindowTitle(window_title)
self.init_filenames = list(filenames)
self._search_thread = None
# list with all open files
self.files = []
# create tabs for files
self.main_widget = QWidget(self)
self.verticalLayout = QVBoxLayout(self.main_widget)
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.verticalLayout.setSpacing(1)
self.verticalLayout.setObjectName("verticalLayout")
self.tabWidget = EditorTabWidget(self)
self.tabWidget.setTabPosition(QTabWidget.North)
self.tabWidget.setDocumentMode(True)
self.tabWidget.setTabsClosable(True)
self.tabWidget.setMovable(False)
self.tabWidget.setObjectName("tabWidget")
self.tabWidget.tabCloseRequested.connect(self.on_close_tab)
self.verticalLayout.addWidget(self.tabWidget)
self.buttons = self._create_buttons()
self.verticalLayout.addWidget(self.buttons)
self.setCentralWidget(self.main_widget)
self.find_dialog = TextSearchFrame(self.tabWidget, self)
self.find_dialog.search_result_signal.connect(self.on_search_result)
self.find_dialog.replace_signal.connect(self.on_replace)
self.addDockWidget(Qt.RightDockWidgetArea, self.find_dialog)
# open the files
for f in filenames:
if f:
self.on_load_request(os.path.normpath(f), search_text)
self.readSettings()
self.find_dialog.setVisible(False)
# def __del__(self):
# print "******** destroy", self.objectName()
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)')
#.........这里部分代码省略.........
示例11: __init__
# 需要导入模块: from python_qt_binding.QtGui import QHBoxLayout [as 别名]
# 或者: from python_qt_binding.QtGui.QHBoxLayout import setContentsMargins [as 别名]
def __init__(self, context, node=None):
"""
This class is intended to be called by rqt plugin framework class.
Currently (12/12/2012) the whole widget is splitted into 2 panes:
one on left allows you to choose the node(s) you work on. Right side
pane lets you work with the parameters associated with the node(s) you
select on the left.
(12/27/2012) Despite the pkg name is changed to rqt_reconfigure to
reflect the available functionality, file & class names remain
'param', expecting all the parameters will become handle-able.
"""
super(ParamWidget, self).__init__()
self.setObjectName(self._TITLE_PLUGIN)
self.setWindowTitle(self._TITLE_PLUGIN)
rp = rospkg.RosPack()
#TODO: .ui file needs to replace the GUI components declaration
# below. For unknown reason, referring to another .ui files
# from a .ui that is used in this class failed. So for now,
# I decided not use .ui in this class.
# If someone can tackle this I'd appreciate.
_hlayout_top = QHBoxLayout(self)
_hlayout_top.setContentsMargins(QMargins(0, 0, 0, 0))
self._splitter = QSplitter(self)
_hlayout_top.addWidget(self._splitter)
_vlayout_nodesel_widget = QWidget()
_vlayout_nodesel_side = QVBoxLayout()
_hlayout_filter_widget = QWidget(self)
_hlayout_filter = QHBoxLayout()
self._text_filter = TextFilter()
self.filter_lineedit = TextFilterWidget(self._text_filter, rp)
self.filterkey_label = QLabel("&Filter key:")
self.filterkey_label.setBuddy(self.filter_lineedit)
_hlayout_filter.addWidget(self.filterkey_label)
_hlayout_filter.addWidget(self.filter_lineedit)
_hlayout_filter_widget.setLayout(_hlayout_filter)
self._nodesel_widget = NodeSelectorWidget(self, rp, self.sig_sysmsg)
_vlayout_nodesel_side.addWidget(_hlayout_filter_widget)
_vlayout_nodesel_side.addWidget(self._nodesel_widget)
_vlayout_nodesel_side.setSpacing(1)
_vlayout_nodesel_widget.setLayout(_vlayout_nodesel_side)
reconf_widget = ParameditWidget(rp)
self._splitter.insertWidget(0, _vlayout_nodesel_widget)
self._splitter.insertWidget(1, reconf_widget)
# 1st column, _vlayout_nodesel_widget, to minimize width.
# 2nd col to keep the possible max width.
self._splitter.setStretchFactor(0, 0)
self._splitter.setStretchFactor(1, 1)
# Signal from paramedit widget to node selector widget.
reconf_widget.sig_node_disabled_selected.connect(
self._nodesel_widget.node_deselected)
# Pass name of node to editor widget
self._nodesel_widget.sig_node_selected.connect(
reconf_widget.show_reconf)
if not node:
title = self._TITLE_PLUGIN
else:
title = self._TITLE_PLUGIN + ' %s' % node
self.setObjectName(title)
#Connect filter signal-slots.
self._text_filter.filter_changed_signal.connect(
self._filter_key_changed)
# Open any clients indicated from command line
self.sig_selected.connect(self._nodesel_widget.node_selected)
for rn in [rospy.resolve_name(c) for c in context.argv()]:
if rn in self._nodesel_widget.get_paramitems():
self.sig_selected.emit(rn)
else:
rospy.logwarn('Could not find a dynamic reconfigure client named \'%s\'', str(rn))
示例12: MessageBox
# 需要导入模块: from python_qt_binding.QtGui import QHBoxLayout [as 别名]
# 或者: from python_qt_binding.QtGui.QHBoxLayout import setContentsMargins [as 别名]
class MessageBox(QDialog):
NoIcon = 0
Information = 1
Warning = 2
Critical = 3
Question = 4
NoButton = 0
Ok = 1 # An "OK" button defined with the AcceptRole .
Open = 2 # A "Open" button defined with the AcceptRole .
Save = 4 # A "Save" button defined with the AcceptRole .
Cancel = 8 # A "Cancel" button defined with the RejectRole .
Close = 16 # A "Close" button defined with the RejectRole .
Discard = 32 # A "Discard" or "Don't Save" button, depending on the platform, defined with the DestructiveRole .
Apply = 64 # An "Apply" button defined with the ApplyRole .
Reset = 128 # A "Reset" button defined with the ResetRole .
RestoreDefaults = 256 # A "Restore Defaults" button defined with the ResetRole .
Help = 512 # A "Help" button defined with the HelpRole .
SaveAll = 1024 # A "Save All" button defined with the AcceptRole .
Yes = 2048 # A "Yes" button defined with the YesRole .
YesToAll = 4096 # A "Yes to All" button defined with the YesRole .
No = 8192 # A "No" button defined with the NoRole .
NoToAll = 16384 # A "No to All" button defined with the NoRole .
Abort = 32768 # An "Abort" button defined with the RejectRole .
Retry = 65536 # A "Retry" button defined with the AcceptRole .
Ignore = 131072 # An "Ignore" button defined with the AcceptRole .
Avoid = 262144 # An "'Don't show again'" button defined with the HelpRole, returns a default AcceptButton .
def __init__(self, icon, title, text, detailed_text="", buttons=Cancel | Ok, parent=None):
QDialog.__init__(self, parent=parent)
self.setWindowFlags(self.windowFlags() & ~Qt.WindowTitleHint)
self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint & ~Qt.WindowMinimizeButtonHint)
self.setObjectName('MessageBox')
self._use_checkbox = True
self.text = text
self.verticalLayout = QVBoxLayout(self)
self.verticalLayout.setObjectName("verticalLayout")
self.verticalLayout.setContentsMargins(1, 1, 1, 1)
self.horizontalLayout = QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.horizontalLayout.setContentsMargins(1, 1, 1, 1)
# create icon
pixmap = None
if icon == self.NoIcon:
pass
elif icon == self.Question:
pixmap = QApplication.style().standardPixmap(QStyle.SP_MessageBoxQuestion)
elif icon == self.Information:
pixmap = QApplication.style().standardPixmap(QStyle.SP_MessageBoxInformation)
elif icon == self.Warning:
pixmap = QPixmap(":icons/crystal_clear_warning_56.png")
elif icon == self.Critical:
pixmap = QApplication.style().standardPixmap(QStyle.SP_MessageBoxCritical)
spacerItem = QSpacerItem(10, 60, QSizePolicy.Minimum, QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem)
self.icon_label = QLabel()
if pixmap is not None:
self.icon_label.setPixmap(pixmap)
self.icon_label.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
self.horizontalLayout.addWidget(self.icon_label)
spacerItem = QSpacerItem(10, 60, QSizePolicy.Minimum, QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem)
# add message
self.message_label = QLabel(text)
self.message_label.setWordWrap(True)
self.message_label.setScaledContents(True)
self.message_label.setOpenExternalLinks(True)
self.horizontalLayout.addWidget(self.message_label)
self.verticalLayout.addLayout(self.horizontalLayout)
# create buttons
self.buttonBox = QDialogButtonBox(self)
self.buttonBox.setObjectName("buttonBox")
self.buttonBox.setOrientation(Qt.Horizontal)
self._accept_button = None
self._reject_button = None
self._buttons = buttons
self._create_buttons(buttons)
self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject)
self.verticalLayout.addWidget(self.buttonBox)
if detailed_text:
self.btn_show_details = QPushButton(self.tr('Details...'))
self.btn_show_details.setCheckable(True)
self.btn_show_details.setChecked(True)
self.btn_show_details.toggled.connect(self.on_toggled_details)
self.buttonBox.addButton(self.btn_show_details, QDialogButtonBox.ActionRole)
# create area for detailed text
self.textEdit = textEdit = QTextEdit(self)
textEdit.setObjectName("textEdit")
textEdit.setReadOnly(True)
textEdit.setText(detailed_text)
# textEdit.setVisible(False)
self.verticalLayout.addWidget(self.textEdit)
self.resize(480, self.verticalLayout.totalSizeHint().height())
buttons_in_box = self.buttonBox.buttons()
#.........这里部分代码省略.........
示例13: __init__
# 需要导入模块: from python_qt_binding.QtGui import QHBoxLayout [as 别名]
# 或者: from python_qt_binding.QtGui.QHBoxLayout import setContentsMargins [as 别名]
def __init__(self, topic, msg_type, show_only_rate=False, masteruri=None, use_ssh=False, parent=None):
"""
Creates an input dialog.
@param topic: the name of the topic
@type topic: C{str}
@param msg_type: the type of the topic
@type msg_type: C{str}
@raise Exception: if no topic class was found for the given type
"""
QDialog.__init__(self, parent=parent)
self._masteruri = masteruri
masteruri_str = "" if masteruri is None else "[%s]" % masteruri
self.setObjectName(" - ".join(["EchoDialog", topic, masteruri_str]))
self.setAttribute(Qt.WA_DeleteOnClose, True)
self.setWindowFlags(Qt.Window)
self.setWindowTitle("%s %s %s" % ("Echo --- " if not show_only_rate else "Hz --- ", topic, masteruri_str))
self.resize(728, 512)
self.verticalLayout = QVBoxLayout(self)
self.verticalLayout.setObjectName("verticalLayout")
self.verticalLayout.setContentsMargins(1, 1, 1, 1)
self.mIcon = QIcon(":/icons/crystal_clear_prop_run_echo.png")
self.setWindowIcon(self.mIcon)
self.topic = topic
self.show_only_rate = show_only_rate
self.lock = threading.RLock()
self.last_printed_count = 0
self.msg_t0 = -1.0
self.msg_tn = 0
self.times = []
self.message_count = 0
self._rate_message = ""
self._scrapped_msgs = 0
self._scrapped_msgs_sl = 0
self._last_received_ts = 0
self.receiving_hz = self.MESSAGE_HZ_LIMIT
self.line_limit = self.MESSAGE_LINE_LIMIT
self.field_filter_fn = None
options = QWidget(self)
if not show_only_rate:
hLayout = QHBoxLayout(options)
hLayout.setContentsMargins(1, 1, 1, 1)
self.no_str_checkbox = no_str_checkbox = QCheckBox("Hide strings")
no_str_checkbox.toggled.connect(self.on_no_str_checkbox_toggled)
hLayout.addWidget(no_str_checkbox)
self.no_arr_checkbox = no_arr_checkbox = QCheckBox("Hide arrays")
no_arr_checkbox.toggled.connect(self.on_no_arr_checkbox_toggled)
hLayout.addWidget(no_arr_checkbox)
self.combobox_reduce_ch = QComboBox(self)
self.combobox_reduce_ch.addItems([str(self.MESSAGE_LINE_LIMIT), "0", "80", "256", "1024"])
self.combobox_reduce_ch.activated[str].connect(self.combobox_reduce_ch_activated)
self.combobox_reduce_ch.setEditable(True)
self.combobox_reduce_ch.setToolTip("Set maximum line width. 0 disables the limit.")
hLayout.addWidget(self.combobox_reduce_ch)
# reduce_ch_label = QLabel('ch', self)
# hLayout.addWidget(reduce_ch_label)
# add spacer
spacerItem = QSpacerItem(515, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
hLayout.addItem(spacerItem)
# add combobox for displaying frequency of messages
self.combobox_displ_hz = QComboBox(self)
self.combobox_displ_hz.addItems([str(self.MESSAGE_HZ_LIMIT), "0", "0.1", "1", "50", "100", "1000"])
self.combobox_displ_hz.activated[str].connect(self.on_combobox_hz_activated)
self.combobox_displ_hz.setEditable(True)
hLayout.addWidget(self.combobox_displ_hz)
displ_hz_label = QLabel("Hz", self)
hLayout.addWidget(displ_hz_label)
# add combobox for count of displayed messages
self.combobox_msgs_count = QComboBox(self)
self.combobox_msgs_count.addItems([str(self.MAX_DISPLAY_MSGS), "0", "50", "100"])
self.combobox_msgs_count.activated[str].connect(self.on_combobox_count_activated)
self.combobox_msgs_count.setEditable(True)
self.combobox_msgs_count.setToolTip("Set maximum displayed message count. 0 disables the limit.")
hLayout.addWidget(self.combobox_msgs_count)
displ_count_label = QLabel("#", self)
hLayout.addWidget(displ_count_label)
# add topic control button for unsubscribe and subscribe
self.topic_control_button = QToolButton(self)
self.topic_control_button.setText("stop")
self.topic_control_button.setIcon(QIcon(":/icons/deleket_deviantart_stop.png"))
self.topic_control_button.clicked.connect(self.on_topic_control_btn_clicked)
hLayout.addWidget(self.topic_control_button)
# add clear button
clearButton = QToolButton(self)
clearButton.setText("clear")
clearButton.clicked.connect(self.on_clear_btn_clicked)
hLayout.addWidget(clearButton)
self.verticalLayout.addWidget(options)
self.display = QTextBrowser(self)
self.display.setReadOnly(True)
self.verticalLayout.addWidget(self.display)
self.display.document().setMaximumBlockCount(500)
self.max_displayed_msgs = self.MAX_DISPLAY_MSGS
self._blocks_in_msg = None
self.display.setOpenLinks(False)
#.........这里部分代码省略.........