本文整理汇总了Python中spyderlib.qt.QtGui.QLabel类的典型用法代码示例。如果您正苦于以下问题:Python QLabel类的具体用法?Python QLabel怎么用?Python QLabel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QLabel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self):
QWidget.__init__(self)
vlayout = QVBoxLayout()
self.setLayout(vlayout)
self.explorer = ExplorerWidget(self, show_cd_only=None)
vlayout.addWidget(self.explorer)
hlayout1 = QHBoxLayout()
vlayout.addLayout(hlayout1)
label = QLabel("<b>Open file:</b>")
label.setAlignment(Qt.AlignRight)
hlayout1.addWidget(label)
self.label1 = QLabel()
hlayout1.addWidget(self.label1)
self.explorer.sig_open_file.connect(self.label1.setText)
hlayout2 = QHBoxLayout()
vlayout.addLayout(hlayout2)
label = QLabel("<b>Open dir:</b>")
label.setAlignment(Qt.AlignRight)
hlayout2.addWidget(label)
self.label2 = QLabel()
hlayout2.addWidget(self.label2)
self.explorer.open_dir.connect(self.label2.setText)
hlayout3 = QHBoxLayout()
vlayout.addLayout(hlayout3)
label = QLabel("<b>Option changed:</b>")
label.setAlignment(Qt.AlignRight)
hlayout3.addWidget(label)
self.label3 = QLabel()
hlayout3.addWidget(self.label3)
self.explorer.sig_option_changed.connect(lambda x, y: self.label3.setText("option_changed: %r, %r" % (x, y)))
self.explorer.open_dir.connect(lambda: self.explorer.treewidget.refresh(".."))
示例2: __init__
def __init__(self, parent=None):
QWidget.__init__(self, parent)
self.runconf = RunConfiguration()
common_group = QGroupBox(_("General settings"))
common_layout = QGridLayout()
common_group.setLayout(common_layout)
self.clo_cb = QCheckBox(_("Command line options:"))
common_layout.addWidget(self.clo_cb, 0, 0)
self.clo_edit = QLineEdit()
self.connect(self.clo_cb, SIGNAL("toggled(bool)"), self.clo_edit.setEnabled)
self.clo_edit.setEnabled(False)
common_layout.addWidget(self.clo_edit, 0, 1)
self.wd_cb = QCheckBox(_("Working directory:"))
common_layout.addWidget(self.wd_cb, 1, 0)
wd_layout = QHBoxLayout()
self.wd_edit = QLineEdit()
self.connect(self.wd_cb, SIGNAL("toggled(bool)"), self.wd_edit.setEnabled)
self.wd_edit.setEnabled(False)
wd_layout.addWidget(self.wd_edit)
browse_btn = QPushButton(get_std_icon("DirOpenIcon"), "", self)
browse_btn.setToolTip(_("Select directory"))
self.connect(browse_btn, SIGNAL("clicked()"), self.select_directory)
wd_layout.addWidget(browse_btn)
common_layout.addLayout(wd_layout, 1, 1)
radio_group = QGroupBox(_("Interpreter"))
radio_layout = QVBoxLayout()
radio_group.setLayout(radio_layout)
self.current_radio = QRadioButton(_("Execute in current Python " "or IPython interpreter"))
radio_layout.addWidget(self.current_radio)
self.new_radio = QRadioButton(_("Execute in a new dedicated " "Python interpreter"))
radio_layout.addWidget(self.new_radio)
self.systerm_radio = QRadioButton(_("Execute in an external " "system terminal"))
radio_layout.addWidget(self.systerm_radio)
new_group = QGroupBox(_("Dedicated Python interpreter"))
self.connect(self.current_radio, SIGNAL("toggled(bool)"), new_group.setDisabled)
new_layout = QGridLayout()
new_group.setLayout(new_layout)
self.interact_cb = QCheckBox(_("Interact with the Python " "interpreter after execution"))
new_layout.addWidget(self.interact_cb, 1, 0, 1, -1)
self.pclo_cb = QCheckBox(_("Command line options:"))
new_layout.addWidget(self.pclo_cb, 2, 0)
self.pclo_edit = QLineEdit()
self.connect(self.pclo_cb, SIGNAL("toggled(bool)"), self.pclo_edit.setEnabled)
self.pclo_edit.setEnabled(False)
new_layout.addWidget(self.pclo_edit, 2, 1)
pclo_label = QLabel(_("The <b>-u</b> option is " "added to these commands"))
pclo_label.setWordWrap(True)
new_layout.addWidget(pclo_label, 3, 1)
# TODO: Add option for "Post-mortem debugging"
layout = QVBoxLayout()
layout.addWidget(common_group)
layout.addWidget(radio_group)
layout.addWidget(new_group)
self.setLayout(layout)
示例3: __init__
def __init__(self, parent, statusbar):
StatusBarWidget.__init__(self, parent, statusbar)
layout = self.layout()
layout.addWidget(QLabel(_("Line:")))
self.line = QLabel()
self.line.setFont(self.label_font)
layout.addWidget(self.line)
layout.addWidget(QLabel(_("Column:")))
self.column = QLabel()
self.column.setFont(self.label_font)
layout.addWidget(self.column)
self.setLayout(layout)
示例4: EncodingStatus
class EncodingStatus(StatusBarWidget):
def __init__(self, parent, statusbar):
StatusBarWidget.__init__(self, parent, statusbar)
layout = self.layout()
layout.addWidget(QLabel(_("Encoding:")))
self.encoding = QLabel()
self.encoding.setFont(self.label_font)
layout.addWidget(self.encoding)
layout.addSpacing(20)
def encoding_changed(self, encoding):
self.encoding.setText(str(encoding).upper().ljust(15))
示例5: EOLStatus
class EOLStatus(StatusBarWidget):
def __init__(self, parent, statusbar):
StatusBarWidget.__init__(self, parent, statusbar)
layout = self.layout()
layout.addWidget(QLabel(_("End-of-lines:")))
self.eol = QLabel()
self.eol.setFont(self.label_font)
layout.addWidget(self.eol)
layout.addSpacing(20)
def eol_changed(self, os_name):
os_name = to_text_string(os_name)
self.eol.setText({"nt": "CRLF", "posix": "LF"}.get(os_name, "CR"))
示例6: ReadWriteStatus
class ReadWriteStatus(StatusBarWidget):
def __init__(self, parent, statusbar):
StatusBarWidget.__init__(self, parent, statusbar)
layout = self.layout()
layout.addWidget(QLabel(_("Permissions:")))
self.readwrite = QLabel()
self.readwrite.setFont(self.label_font)
layout.addWidget(self.readwrite)
layout.addSpacing(20)
def readonly_changed(self, readonly):
readwrite = "R" if readonly else "RW"
self.readwrite.setText(readwrite.ljust(3))
示例7: fix_size
def fix_size(self, content, extra=50):
"""Adjusts the width of the file switcher, based on the content."""
# Update size of dialog based on longest shortened path
strings = []
if content:
for rich_text in content:
label = QLabel(rich_text)
label.setTextFormat(Qt.PlainText)
strings.append(label.text())
fm = label.fontMetrics()
max_width = max([fm.width(s)*1.3 for s in strings])
self.list.setMinimumWidth(max_width + extra)
self.set_dialog_position()
示例8: setup_page
def setup_page(self):
settings_group = QGroupBox(_("Settings"))
use_color_box = self.create_checkbox(
_("Use deterministic colors to differentiate functions"),
'use_colors', default=True)
results_group = QGroupBox(_("Results"))
results_label1 = QLabel(_("Memory profiler plugin results "
"(the output of memory_profiler)\n"
"is stored here:"))
results_label1.setWordWrap(True)
# Warning: do not try to regroup the following QLabel contents with
# widgets above -- this string was isolated here in a single QLabel
# on purpose: to fix Issue 863 of Profiler plugon
results_label2 = QLabel(MemoryProfilerWidget.DATAPATH)
results_label2.setTextInteractionFlags(Qt.TextSelectableByMouse)
results_label2.setWordWrap(True)
settings_layout = QVBoxLayout()
settings_layout.addWidget(use_color_box)
settings_group.setLayout(settings_layout)
results_layout = QVBoxLayout()
results_layout.addWidget(results_label1)
results_layout.addWidget(results_label2)
results_group.setLayout(results_layout)
vlayout = QVBoxLayout()
vlayout.addWidget(settings_group)
vlayout.addWidget(results_group)
vlayout.addStretch(1)
self.setLayout(vlayout)
示例9: setup_page
def setup_page(self):
"""
Create the Spyder Config page for this plugin.
As of Dec 2014, there are no options available to set, so we only
display the data path.
"""
results_group = QGroupBox(_("Results"))
results_label1 = QLabel(_("Results are stored here:"))
results_label1.setWordWrap(True)
# Warning: do not try to regroup the following QLabel contents with
# widgets above -- this string was isolated here in a single QLabel
# on purpose: to fix Issue 863
results_label2 = QLabel(CoverageWidget.DATAPATH)
results_label2.setTextInteractionFlags(Qt.TextSelectableByMouse)
results_label2.setWordWrap(True)
results_layout = QVBoxLayout()
results_layout.addWidget(results_label1)
results_layout.addWidget(results_label2)
results_group.setLayout(results_layout)
vlayout = QVBoxLayout()
vlayout.addWidget(results_group)
vlayout.addStretch(1)
self.setLayout(vlayout)
示例10: create_lineedit
def create_lineedit(self, text, option, default=NoDefault,
tip=None, alignment=Qt.Vertical):
label = QLabel(text)
label.setWordWrap(True)
edit = QLineEdit()
layout = QVBoxLayout() if alignment == Qt.Vertical else QHBoxLayout()
layout.addWidget(label)
layout.addWidget(edit)
layout.setContentsMargins(0, 0, 0, 0)
if tip:
edit.setToolTip(tip)
self.lineedits[edit] = (option, default)
widget = QWidget(self)
widget.setLayout(layout)
return widget
示例11: BaseTimerStatus
class BaseTimerStatus(StatusBarWidget):
TITLE = None
TIP = None
def __init__(self, parent, statusbar):
StatusBarWidget.__init__(self, parent, statusbar)
self.setToolTip(self.TIP)
layout = self.layout()
layout.addWidget(QLabel(self.TITLE))
self.label = QLabel()
self.label.setFont(self.label_font)
layout.addWidget(self.label)
layout.addSpacing(20)
if self.is_supported():
self.timer = QTimer()
self.timer.timeout.connect(self.update_label)
self.timer.start(2000)
else:
self.timer = None
self.hide()
def set_interval(self, interval):
"""Set timer interval (ms)"""
if self.timer is not None:
self.timer.setInterval(interval)
def import_test(self):
"""Raise ImportError if feature is not supported"""
raise NotImplementedError
def is_supported(self):
"""Return True if feature is supported"""
try:
self.import_test()
return True
except ImportError:
return False
def get_value(self):
"""Return value (e.g. CPU or memory usage)"""
raise NotImplementedError
def update_label(self):
"""Update status label widget, if widget is visible"""
if self.isVisible():
self.label.setText('%d %%' % self.get_value())
示例12: setup_page
def setup_page(self):
""" Setup of the configuration page. All widgets need to be added here"""
setup_group = QGroupBox(_("RateLaw Plugin Configuration"))
setup_label = QLabel(_("RateLaw plugin configuration needs to be "\
"implemented here.\n"))
setup_label.setWordWrap(True)
# Warning: do not try to regroup the following QLabel contents with
# widgets above -- this string was isolated here in a single QLabel
# on purpose: to fix Issue 863
setup_layout = QVBoxLayout()
setup_layout.addWidget(setup_label)
setup_group.setLayout(setup_layout)
vlayout = QVBoxLayout()
vlayout.addWidget(setup_group)
vlayout.addStretch(1)
self.setLayout(vlayout)
示例13: __init__
def __init__(self, parent):
QWidget.__init__(self, parent)
layout = QHBoxLayout()
row_nb = 14
cindex = 0
for child in dir(QStyle):
if child.startswith('SP_'):
if cindex == 0:
col_layout = QVBoxLayout()
icon_layout = QHBoxLayout()
icon = get_std_icon(child)
label = QLabel()
label.setPixmap(icon.pixmap(32, 32))
icon_layout.addWidget( label )
icon_layout.addWidget( QLineEdit(child.replace('SP_', '')) )
col_layout.addLayout(icon_layout)
cindex = (cindex+1) % row_nb
if cindex == 0:
layout.addLayout(col_layout)
self.setLayout(layout)
self.setWindowTitle('Standard Platform Icons')
self.setWindowIcon(get_std_icon('TitleBarMenuButton'))
示例14: CursorPositionStatus
class CursorPositionStatus(StatusBarWidget):
def __init__(self, parent, statusbar):
StatusBarWidget.__init__(self, parent, statusbar)
layout = self.layout()
layout.addWidget(QLabel(_("Line:")))
self.line = QLabel()
self.line.setFont(self.label_font)
layout.addWidget(self.line)
layout.addWidget(QLabel(_("Column:")))
self.column = QLabel()
self.column.setFont(self.label_font)
layout.addWidget(self.column)
self.setLayout(layout)
def cursor_position_changed(self, line, index):
self.line.setText("%-6d" % (line+1))
self.column.setText("%-4d" % (index+1))
示例15: DependenciesDialog
class DependenciesDialog(QDialog):
def __init__(self, parent):
QDialog.__init__(self, parent)
self.setWindowTitle("Spyder %s: %s" % (__version__, _("Optional Dependencies")))
self.setModal(True)
self.view = DependenciesTableView(self, [])
important_mods = ["rope", "pyflakes", "IPython", "matplotlib"]
self.label = QLabel(
_(
"Spyder depends on several Python modules to "
"provide additional functionality for its "
"plugins. The table below shows the required "
"and installed versions (if any) of all of "
"them.<br><br>"
"Although Spyder can work without any of these "
"modules, it's strongly recommended that at "
"least you try to install <b>%s</b> and "
"<b>%s</b> to have a much better experience."
)
% (", ".join(important_mods[:-1]), important_mods[-1])
)
self.label.setWordWrap(True)
self.label.setAlignment(Qt.AlignJustify)
self.label.setContentsMargins(5, 8, 12, 10)
btn = QPushButton(_("Copy to clipboard"))
self.connect(btn, SIGNAL("clicked()"), self.copy_to_clipboard)
bbox = QDialogButtonBox(QDialogButtonBox.Ok)
self.connect(bbox, SIGNAL("accepted()"), SLOT("accept()"))
hlayout = QHBoxLayout()
hlayout.addWidget(btn)
hlayout.addStretch()
hlayout.addWidget(bbox)
vlayout = QVBoxLayout()
vlayout.addWidget(self.label)
vlayout.addWidget(self.view)
vlayout.addLayout(hlayout)
self.setLayout(vlayout)
self.resize(560, 350)
def set_data(self, dependencies):
self.view.model.set_data(dependencies)
self.view.adjust_columns()
self.view.sortByColumn(0, Qt.DescendingOrder)
def copy_to_clipboard(self):
from spyderlib.dependencies import status
QApplication.clipboard().setText(status())