本文整理汇总了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)