本文整理汇总了Python中python_qt_binding.QtGui.QHBoxLayout.addItem方法的典型用法代码示例。如果您正苦于以下问题:Python QHBoxLayout.addItem方法的具体用法?Python QHBoxLayout.addItem怎么用?Python QHBoxLayout.addItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类python_qt_binding.QtGui.QHBoxLayout
的用法示例。
在下文中一共展示了QHBoxLayout.addItem方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from python_qt_binding.QtGui import QHBoxLayout [as 别名]
# 或者: from python_qt_binding.QtGui.QHBoxLayout import addItem [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)
示例2: Editor
# 需要导入模块: from python_qt_binding.QtGui import QHBoxLayout [as 别名]
# 或者: from python_qt_binding.QtGui.QHBoxLayout import addItem [as 别名]
#.........这里部分代码省略.........
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
def keyPressEvent(self, event):
'''
Enable the shortcats for search and replace
'''
if event.key() == Qt.Key_Escape:
self.reject()
elif event.modifiers() == Qt.ControlModifier and event.key() == Qt.Key_F:
if self.tabWidget.currentWidget().hasFocus():
if not self.searchButton.isChecked():
self.searchButton.setChecked(True)
else:
self.on_toggled_find(True)
else:
self.searchButton.setChecked(not self.searchButton.isChecked())
elif event.modifiers() == Qt.ControlModifier and event.key() == Qt.Key_R:
示例3: MessageBox
# 需要导入模块: from python_qt_binding.QtGui import QHBoxLayout [as 别名]
# 或者: from python_qt_binding.QtGui.QHBoxLayout import addItem [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()
#.........这里部分代码省略.........
示例4: __init__
# 需要导入模块: from python_qt_binding.QtGui import QHBoxLayout [as 别名]
# 或者: from python_qt_binding.QtGui.QHBoxLayout import addItem [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)
#.........这里部分代码省略.........