本文整理汇总了Python中guidata.qt.QtGui.QLabel.setToolTip方法的典型用法代码示例。如果您正苦于以下问题:Python QLabel.setToolTip方法的具体用法?Python QLabel.setToolTip怎么用?Python QLabel.setToolTip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类guidata.qt.QtGui.QLabel
的用法示例。
在下文中一共展示了QLabel.setToolTip方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_image_layout
# 需要导入模块: from guidata.qt.QtGui import QLabel [as 别名]
# 或者: from guidata.qt.QtGui.QLabel import setToolTip [as 别名]
def get_image_layout(imagename, text="", tooltip="", alignment=Qt.AlignLeft):
"""
Construct a QHBoxLayout including image from the file with specified name,
left-aligned text [with specified tooltip]
Return (layout, label)
"""
layout = QHBoxLayout()
if alignment in (Qt.AlignCenter, Qt.AlignRight):
layout.addStretch()
layout.addWidget(get_image_label(imagename))
label = QLabel(text)
label.setToolTip(tooltip)
layout.addWidget(label)
if alignment in (Qt.AlignCenter, Qt.AlignLeft):
layout.addStretch()
return (layout, label)
示例2: DataSetShowWidget
# 需要导入模块: from guidata.qt.QtGui import QLabel [as 别名]
# 或者: from guidata.qt.QtGui.QLabel import setToolTip [as 别名]
class DataSetShowWidget(AbstractDataSetWidget):
"""Read-only base widget"""
READ_ONLY = True
def __init__(self, item, parent_layout):
AbstractDataSetWidget.__init__(self, item, parent_layout)
self.group = QLabel()
wordwrap = item.get_prop_value("display", "wordwrap", False)
self.group.setWordWrap(wordwrap)
self.group.setToolTip(item.get_help())
self.group.setStyleSheet( LABEL_CSS )
self.group.setTextInteractionFlags(Qt.TextSelectableByMouse)
#self.group.setEnabled(False)
def get(self):
"""Override AbstractDataSetWidget method"""
self.set_state()
text = self.item.get_string_value()
self.group.setText(text)
def set(self):
"""Read only..."""
pass
示例3: AbstractDataSetWidget
# 需要导入模块: from guidata.qt.QtGui import QLabel [as 别名]
# 或者: from guidata.qt.QtGui.QLabel import setToolTip [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)