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


Python QLabel.setEnabled方法代码示例

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


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

示例1: AbstractDataSetWidget

# 需要导入模块: from guidata.qt.QtGui import QLabel [as 别名]
# 或者: from guidata.qt.QtGui.QLabel import setEnabled [as 别名]
class AbstractDataSetWidget(object):
    """
    Base class for 'widgets' handled by `DataSetEditLayout` and it's derived 
    classes.
    
    This is a generic representation of an input (or display) widget that
    has a label and one or more entry field.
    
    `DataSetEditLayout` uses a registry of *Item* to *Widget* mapping in order 
    to automatically create a GUI for a `DataSet` structure
    """
    READ_ONLY = False
    def __init__(self, item, parent_layout):
        """Derived constructors should create the necessary widgets
        The base class keeps a reference to item and parent 
        """
        self.item = item
        self.parent_layout = parent_layout
        self.group = None # Layout/Widget grouping items
        self.label = None
        self.build_mode = False

    def place_label(self, layout, row, column):
        """
        Place item label on layout at specified position (row, column)
        """
        label_text = self.item.get_prop_value("display", "label")
        unit = self.item.get_prop_value("display", "unit", '')
        if unit and not self.READ_ONLY:
            label_text += (' (%s)' % unit)
        self.label = QLabel(label_text)
        self.label.setToolTip(self.item.get_help())
        layout.addWidget(self.label, row, column)

    def place_on_grid(self, layout, row, label_column, widget_column,
                      row_span=1, column_span=1):
        """
        Place widget on layout at specified position
        """
        self.place_label(layout, row, label_column)
        layout.addWidget(self.group, row, widget_column, row_span, column_span)
    
    def is_active(self):
        """
        Return True if associated item is active
        """
        return self.item.get_prop_value("display", "active", True)
    
    def check(self):
        """
        Item validator
        """
        return True
    
    def set(self):
        """
        Update data item value from widget contents
        """
        # XXX: consider using item.set instead of item.set_from_string...
        self.item.set_from_string(self.value())
    
    def get(self):
        """
        Update widget contents from data item value
        """
        pass

    def value(self):
        """
        Returns the widget's current value
        """
        return None

    def set_state(self):
        """
        Update the visual status of the widget
        """
        active = self.is_active()
        if self.group:
            self.group.setEnabled(active)
        if self.label:
            self.label.setEnabled(active)
开发者ID:artillan,项目名称:guidata,代码行数:84,代码来源:qtitemwidgets.py


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