本文整理汇总了Python中PySide.QtGui.QComboBox.setFont方法的典型用法代码示例。如果您正苦于以下问题:Python QComboBox.setFont方法的具体用法?Python QComboBox.setFont怎么用?Python QComboBox.setFont使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QComboBox
的用法示例。
在下文中一共展示了QComboBox.setFont方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: aLabeledPopup
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import setFont [as 别名]
class aLabeledPopup(QWidget):
def __init__(self, var, text, item_list, pos = "side", max_size = 200):
QWidget.__init__(self)
self.setContentsMargins(1, 1, 1, 1)
if pos == "side":
self.layout1=QHBoxLayout()
else:
self.layout1 = QVBoxLayout()
self.layout1.setContentsMargins(1, 1, 1, 1)
self.layout1.setSpacing(1)
self.setLayout(self.layout1)
self.item_combo = QComboBox()
self.item_combo.addItems(item_list)
self.item_combo.setFont(QFont('SansSerif', 12))
self.label = QLabel(text)
# self.label.setAlignment(Qt.AlignLeft)
self.label.setFont(QFont('SansSerif', 12))
self.layout1.addWidget(self.label)
self.layout1.addWidget(self.item_combo)
self.var = var
self.item_combo.textChanged.connect(self.when_modified)
self.item_combo.currentIndexChanged.connect(self.when_modified)
self.when_modified()
def when_modified(self):
self.var.set(self.item_combo.currentText())
def hide(self):
QWidget.hide(self)
示例2: AnalysisSelector
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import setFont [as 别名]
class AnalysisSelector(QWidget):
def __init__(self, my_parent, max_size = 200):
QWidget.__init__(self)
myframe = QHBoxLayout()
self.setLayout(myframe)
self.popup = QComboBox()
self.popup.setSizeAdjustPolicy(QComboBox.AdjustToContents)
myframe.addWidget(self.popup)
myframe.addStretch()
self.my_parent = my_parent
self.popup.addItems(self.my_parent._lcvsa_dict.keys())
self.popup.setFont(QFont('SansSerif', 12))
self.popup.currentIndexChanged.connect(self.when_modified)
self.when_modified()
def when_modified(self):
self.my_parent._lcvsa = self.my_parent._lcvsa_dict[self.popup.currentText()]
self.my_parent.gprint("Working with analysis %s" % self.popup.currentText(), "h2")
def hide(self):
QWidget.hide(self)
示例3: qHotField
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import setFont [as 别名]
class qHotField(QWidget):
def __init__(self, name, mytype, initial_value, value_list = None, pos = "left", help_text = None, help_instance = None, min_size = 0, max_size = None, handler = None, multiline=False):
QWidget.__init__(self)
if max_size == None:
max_size = 300
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) # Let it expand horizontally but not vertically
self.name = name
self.mytype = mytype
self.multiline = multiline
self.setContentsMargins(1, 1, 1, 1)
self.is_popup = (value_list != None)
if self.is_popup:
self.value_list = [str(v) for v in value_list] # It's possible the values won't be strings.
if pos == "top":
self.layout1 = QVBoxLayout()
else:
self.layout1=QHBoxLayout()
self.layout1.setContentsMargins(1, 1, 1, 1)
self.layout1.setSpacing(1)
self.setLayout(self.layout1)
if mytype == bool:
self.cb = QCheckBox(name)
self.cb.setFont(regular_small_font)
self.layout1.addWidget(self.cb)
self.cb.setChecked(initial_value)
if handler != None:
self.cb.toggled.connect(handler)
else:
if not self.is_popup:
if multiline:
self.efield=QPlainTextEdit("")
self.efield.appendPlainText(str(initial_value))
else:
self.efield = QLineEdit("Default Text")
self.efield.setText(str(initial_value))
if handler != None:
self.efield.textChanged.connect(handler)
else:
self.efield = QComboBox()
self.efield.addItems(value_list)
if len(value_list) != 0:
self.efield.setCurrentIndex(value_list.index(initial_value))
self.efield.setSizeAdjustPolicy(QComboBox.AdjustToContents)
if handler != None:
self.efield.currentIndexChanged.connect(handler)
self.layout1.setContentsMargins(5, 5, 5, 5) # Popups need a little more space
self.layout1.setSpacing(2)
self.efield.setFont(regular_small_font)
self.label = QLabel(name)
self.label.setFont(regular_small_font)
if pos == "right":
self.layout1.addWidget(self.efield)
self.layout1.addWidget(self.label)
else:
self.layout1.addWidget(self.label)
self.layout1.addWidget(self.efield)
self.efield.setMaximumWidth(max_size)
if min_size != 0:
self.efield.setMinimumWidth(min_size)
self.layout1.addStretch()
if help_text != None:
if (help_instance == None):
print "No help instance specified."
else:
help_button_widget = help_instance.create_button(name, help_text)
self.layout1.addWidget(help_button_widget)
def repopulate_list(self, initial_value, value_list):
if not self.is_popup:
print "This qHotField is not a popup list. So it can't be repopulated"
return
self.value_list = [str(v) for v in value_list] # It's possible the values won't be strings
self.efield.clear()
self.efield.addItems(value_list)
self.efield.setCurrentIndex(value_list.index(initial_value))
return
def get_myvalue(self):
if self.mytype == bool:
return self.cb.isChecked()
else:
if self.is_popup:
the_txt = self.efield.currentText()
else:
if self.multiline:
the_txt = self.efield.toPlainText()
else:
the_txt = self.efield.text()
if (self.mytype == str) or (self.mytype == unicode):
return (self.mytype)(the_txt)
else: # if we have a numerical type, the user might have entered a list separated by spaces. Handle that specially
the_val = re.findall(r"\S+", the_txt) # We might have a list of values separated by spaces if this is a numerical variable
if len(the_val) == 1: # it's just a single value
result = (self.mytype)(the_txt)
else: # it's a list. We want to convert treat this as a monte sequence
res = []
for v in the_val:
res.append((self.mytype)(v))
result = MonteSequence(res)
#.........这里部分代码省略.........