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


Python QCheckBox.setFont方法代码示例

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


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

示例1: qLabeledCheck

# 需要导入模块: from PySide.QtGui import QCheckBox [as 别名]
# 或者: from PySide.QtGui.QCheckBox import setFont [as 别名]
class qLabeledCheck(QWidget): 
    def __init__(self, name, arg_dict, 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.cbox = QCheckBox()
        # self.efield.setMaximumWidth(max_size)
        self.cbox.setFont(QFont('SansSerif', 12))
        self.label = QLabel(name)
        # self.label.setAlignment(Qt.AlignLeft)
        self.label.setFont(QFont('SansSerif', 12))
        self.layout1.addWidget(self.label)
        self.layout1.addWidget(self.cbox)
        self.arg_dict = arg_dict
        self.name = name
        self.mytype = type(self.arg_dict[name])
        if self.mytype != bool:
            self.cbox.setChecked(bool(self.arg_dict[name]))
        else:
            self.cbox.setChecked(self.arg_dict[name])
        self.cbox.toggled.connect(self.when_modified)
        self.when_modified()
        
    def when_modified(self):
        self.arg_dict[self.name]  = self.cbox.isChecked()
        
    def hide(self):
        QWidget.hide(self)
开发者ID:bsherin,项目名称:shared_tools,代码行数:36,代码来源:mywidgets.py

示例2: __init__

# 需要导入模块: from PySide.QtGui import QCheckBox [as 别名]
# 或者: from PySide.QtGui.QCheckBox import setFont [as 别名]
    def __init__(self, group_name, name_list, param_dict, help_instance = None, handler = None, help_dict = None):
        QGroupBox.__init__(self, group_name)
        the_layout = QVBoxLayout()
        the_layout.setSpacing(5)
        the_layout.setContentsMargins(1, 1, 1, 1)
        self.setLayout(the_layout)
        self.widget_dict = {}
        self.is_popup = False
        self.param_dict = param_dict
        for txt in name_list:
            qh = QHBoxLayout()
            cb = QCheckBox(txt)
            qh.addWidget(cb)
            cb.setFont(QFont('SansSerif', 12))
            param_widgets = {}
            for key, val in param_dict.items():
                if type(val) == list: #
                    param_widgets[key] = qHotField(key, type(val[0]), val[0],  value_list=val, pos="top")
                else:
                    param_widgets[key] = qHotField(key, type(val), val, pos="top")
                qh.addWidget(param_widgets[key])

            qh.addStretch()
            the_layout.addLayout(qh)
            if handler != None:
                cb.toggled.connect(handler)
            self.widget_dict[txt] = [cb, param_widgets]
            if (help_dict != None) and (help_instance != None):
                if txt in help_dict:
                    help_button_widget = help_instance.create_button(txt, help_dict[txt])
                    qh.addWidget(help_button_widget)
        return
开发者ID:bsherin,项目名称:shared_tools,代码行数:34,代码来源:mywidgets.py

示例3: CheckWithHelp

# 需要导入模块: from PySide.QtGui import QCheckBox [as 别名]
# 或者: from PySide.QtGui.QCheckBox import setFont [as 别名]
class CheckWithHelp(QHBoxLayout):
    def __init__(self, the_text, help_dict = None, help_instance = None):
        QHBoxLayout.__init__(self)
        # new_layout = QHBoxLayout()
        self.cb = QCheckBox(the_text)
        self.cb.setFont(QFont('SansSerif', 12))
        self.addWidget(self.cb)
        if help_dict != None:
            if the_text in help_dict.keys():
                if (help_instance == None):
                    print "No help instance specified."
                else:
                    help_button_widget = help_instance.create_button(the_text, help_dict[the_text])
                    self.addWidget(help_button_widget)
开发者ID:bsherin,项目名称:shared_tools,代码行数:16,代码来源:mywidgets.py

示例4: create_check_boxes

# 需要导入模块: from PySide.QtGui import QCheckBox [as 别名]
# 或者: from PySide.QtGui.QCheckBox import setFont [as 别名]
 def create_check_boxes(self, name_list):
     for txt in name_list:
         qh = QHBoxLayout()
         cb = QCheckBox(txt)
         cb.setFont(regular_small_font)
         qh.addWidget(cb)
         qh.addStretch()
         self.the_layout.addLayout(qh)
         if self.handler != None:
             cb.toggled.connect(self.handler)
         self.widget_dict[txt] = cb
         if (self.help_dict != None) and (self.help_instance != None):
             if txt in self.help_dict:
                 help_button_widget = self.help_instance.create_button(txt, self.help_dict[txt])
                 qh.addWidget(help_button_widget)
开发者ID:bsherin,项目名称:shared_tools,代码行数:17,代码来源:mywidgets.py

示例5: qHotField

# 需要导入模块: from PySide.QtGui import QCheckBox [as 别名]
# 或者: from PySide.QtGui.QCheckBox 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)
#.........这里部分代码省略.........
开发者ID:bsherin,项目名称:shared_tools,代码行数:103,代码来源:mywidgets.py


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