当前位置: 首页>>代码示例>>Python>>正文


Python QComboBox.insertSeparator方法代码示例

本文整理汇总了Python中PySide.QtGui.QComboBox.insertSeparator方法的典型用法代码示例。如果您正苦于以下问题:Python QComboBox.insertSeparator方法的具体用法?Python QComboBox.insertSeparator怎么用?Python QComboBox.insertSeparator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PySide.QtGui.QComboBox的用法示例。


在下文中一共展示了QComboBox.insertSeparator方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: OptionSection

# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import insertSeparator [as 别名]
class OptionSection(QWidget):
  """
  Collects options and returns proper representation when requested
  """
  def __init__(self, parent=None):
    super(OptionSection, self).__init__(parent)
    #create widgets
    label_buffer_size = QLabel("Buffer Size")
    self.spinbox_buffer_size = ValidatedSpinBox()
    self.spinbox_buffer_size.setSingleStep(10)
    self.spinbox_buffer_size.setMaximum(9999999)
    self.spinbox_buffer_size.setSuffix(" bytes")
    self.spinbox_buffer_size.setValue(55)
    label_timeout = QLabel("Timeout")
    self.spinbox_timeout = ValidatedSpinBox()
    self.spinbox_timeout.setMaximum(9999999)
    self.spinbox_timeout.setSuffix(" ms")
    self.spinbox_timeout.setSingleStep(100)
    self.spinbox_timeout.setValue(1000)
    label_delay = QLabel("Delay Between Packets")
    self.spinbox_delay = ValidatedSpinBox()
    self.spinbox_delay.setMaximum(9999999)
    self.spinbox_delay.setSuffix(" ms")
    self.spinbox_delay.setSingleStep(100)
    self.spinbox_delay.setValue(1000)
    label_delay_distribution = QLabel("Delay Distribution")
    self.combobox_delay_distribution = QComboBox()
    self.combobox_delay_distribution.addItem("Constant")
    self.combobox_delay_distribution.insertSeparator(10)
    self.combobox_delay_distribution.addItems(["Uniform", "Gaussian", "Poisson", "Exponential"])
    label_packet_count = QLabel("Packets to Send")
    self.spinbox_packet_count = ValidatedSpinBox()
    self.spinbox_packet_count.setMaximum(9999999)
    self.spinbox_packet_count.setValue(3)
    #setup layout
    layout = QFormLayout()
    layout.addRow(label_buffer_size, self.spinbox_buffer_size)
    layout.addRow(label_timeout, self.spinbox_timeout)
    layout.addRow(label_delay, self.spinbox_delay)
    layout.addRow(label_delay_distribution, self.combobox_delay_distribution)
    layout.addRow(label_packet_count, self.spinbox_packet_count)
    self.setLayout(layout)
    
  def getOptions(self):
    """
    Return a RequestData object representing selected options
    """
    buf_size = self.spinbox_buffer_size.value()
    timeout = self.spinbox_timeout.value()
    delay = self.spinbox_delay.value() / 1000
    packet_count = self.spinbox_packet_count.value()
    selected_distribution = self.combobox_delay_distribution.currentIndex()
    if selected_distribution == 0:
      distribution = RequestData.DISTRIBUTION_CONSTANT
    elif selected_distribution == 1:
      distribution = RequestData.DISTRIBUTION_UNIFORM
    elif selected_distribution == 2:
      distribution = RequestData.DISTRIBUTION_GAUSSIAN
    elif selected_distribution == 3:
      distribution = RequestData.DISTRIBUTION_POISSON
    elif selected_distribution == 4:
      distribution = RequestData.DISTRIBUTION_EXPONENTIAL
    
    return RequestData(buf_size, timeout, delay, packet_count, distribution)
  
  def disableWidgets(self):
    for widget in [self.spinbox_buffer_size, self.spinbox_delay,
                   self.spinbox_packet_count, self.spinbox_timeout, 
                   self.combobox_delay_distribution]:
      widget.setEnabled(False)
  
  def enableWidgets(self):
    for widget in [self.spinbox_buffer_size, self.spinbox_delay,
                   self.spinbox_packet_count, self.spinbox_timeout, 
                   self.combobox_delay_distribution]:
      widget.setEnabled(True)
开发者ID:github-account-because-they-want-it,项目名称:GridPing,代码行数:78,代码来源:option_section.py


注:本文中的PySide.QtGui.QComboBox.insertSeparator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。