本文整理汇总了Python中spyderlib.qt.QtGui.QLabel.setAlignment方法的典型用法代码示例。如果您正苦于以下问题:Python QLabel.setAlignment方法的具体用法?Python QLabel.setAlignment怎么用?Python QLabel.setAlignment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spyderlib.qt.QtGui.QLabel
的用法示例。
在下文中一共展示了QLabel.setAlignment方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DependenciesDialog
# 需要导入模块: from spyderlib.qt.QtGui import QLabel [as 别名]
# 或者: from spyderlib.qt.QtGui.QLabel import setAlignment [as 别名]
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())
示例2: DependenciesDialog
# 需要导入模块: from spyderlib.qt.QtGui import QLabel [as 别名]
# 或者: from spyderlib.qt.QtGui.QLabel import setAlignment [as 别名]
class DependenciesDialog(QDialog):
def __init__(self, parent):
QDialog.__init__(self, parent)
self.setWindowTitle("Spyder %s: %s" % (__version__,
_("Dependencies")))
self.setWindowIcon(ima.icon('tooloptions'))
self.setModal(True)
self.view = DependenciesTableView(self, [])
opt_mods = ['NumPy', 'Matplotlib', 'Pandas', 'SymPy']
self.label = QLabel(_("Spyder depends on several Python modules to "
"provide the right functionality for all its "
"panes. The table below shows the required "
"and installed versions (if any) of all of "
"them.<br><br>"
"<b>Note</b>: You can safely use Spyder "
"without the following modules installed: "
"<b>%s</b> and <b>%s</b>")
% (', '.join(opt_mods[:-1]), opt_mods[-1]))
self.label.setWordWrap(True)
self.label.setAlignment(Qt.AlignJustify)
self.label.setContentsMargins(5, 8, 12, 10)
btn = QPushButton(_("Copy to clipboard"), )
btn.clicked.connect(self.copy_to_clipboard)
bbox = QDialogButtonBox(QDialogButtonBox.Ok)
bbox.accepted.connect(self.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(630, 420)
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())
示例3: __init__
# 需要导入模块: from spyderlib.qt.QtGui import QLabel [as 别名]
# 或者: from spyderlib.qt.QtGui.QLabel import setAlignment [as 别名]
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(".."))
示例4: FadingTipBox
# 需要导入模块: from spyderlib.qt.QtGui import QLabel [as 别名]
# 或者: from spyderlib.qt.QtGui.QLabel import setAlignment [as 别名]
class FadingTipBox(FadingDialog):
""" """
def __init__(self, parent, opacity, duration, easing_curve):
super(FadingTipBox, self).__init__(parent, opacity, duration,
easing_curve)
self.holder = self.anim # needed for qt to work
self.parent = parent
self.frames = None
self.color_top = QColor.fromRgb(230, 230, 230)
self.color_back = QColor.fromRgb(255, 255, 255)
self.offset_shadow = 0
self.fixed_width = 300
self.key_pressed = None
self.setAttribute(Qt.WA_TranslucentBackground)
self.setWindowFlags(Qt.Dialog | Qt.FramelessWindowHint |
Qt.WindowStaysOnTopHint)
self.setModal(False)
# Widgets
self.button_home = QPushButton("<<")
self.button_close = QPushButton("X")
self.button_previous = QPushButton(" < ")
self.button_end = QPushButton(">>")
self.button_next = QPushButton(" > ")
self.button_run = QPushButton(_('Run code'))
self.button_disable = None
self.button_current = QToolButton()
self.label_image = QLabel()
self.label_title = QLabel()
self.combo_title = QComboBox()
self.label_current = QLabel()
self.label_content = QLabel()
self.label_content.setMinimumWidth(self.fixed_width)
self.label_content.setMaximumWidth(self.fixed_width)
self.label_current.setAlignment(Qt.AlignCenter)
self.label_content.setWordWrap(True)
self.widgets = [self.label_content, self.label_title,
self.label_current, self.combo_title,
self.button_close, self.button_run, self.button_next,
self.button_previous, self.button_end,
self.button_home, self.button_current]
arrow = get_image_path('hide.png')
self.stylesheet = '''QPushButton {
background-color: rgbs(200,200,200,100%);
color: rgbs(0,0,0,100%);
border-style: outset;
border-width: 1px;
border-radius: 3px;
border-color: rgbs(100,100,100,100%);
padding: 2px;
}
QPushButton:hover {
background-color: rgbs(150, 150, 150, 100%);
}
QPushButton:disabled {
background-color: rgbs(230,230,230,100%);
color: rgbs(200,200,200,100%);
border-color: rgbs(200,200,200,100%);
}
QComboBox {
padding-left: 5px;
background-color: rgbs(230,230,230,100%);
border-width: 0px;
border-radius: 0px;
min-height:20px;
max-height:20px;
}
QComboBox::drop-down {
subcontrol-origin: padding;
subcontrol-position: top left;
border-width: 0px;
}
QComboBox::down-arrow {
image: url(''' + arrow + ''');
}
'''
# Windows fix, slashes should be always in unix-style
self.stylesheet = self.stylesheet.replace('\\', '/')
for widget in self.widgets:
widget.setFocusPolicy(Qt.NoFocus)
widget.setStyleSheet(self.stylesheet)
layout_top = QHBoxLayout()
#.........这里部分代码省略.........
示例5: __init__
# 需要导入模块: from spyderlib.qt.QtGui import QLabel [as 别名]
# 或者: from spyderlib.qt.QtGui.QLabel import setAlignment [as 别名]
def __init__(self, parent=None):
super(KernelConnectionDialog, self).__init__(parent)
self.setWindowTitle(_('Connect to an existing kernel'))
main_label = QLabel(_("Please enter the connection info of the kernel "
"you want to connect to. For that you can "
"either select its JSON connection file using "
"the <tt>Browse</tt> button, or write directly "
"its id, in case it's a local kernel (for "
"example <tt>kernel-3764.json</tt> or just "
"<tt>3764</tt>)."))
main_label.setWordWrap(True)
main_label.setAlignment(Qt.AlignJustify)
# connection file
cf_label = QLabel(_('Connection info:'))
self.cf = QLineEdit()
self.cf.setPlaceholderText(_('Path to connection file or kernel id'))
self.cf.setMinimumWidth(250)
cf_open_btn = QPushButton(_('Browse'))
self.connect(cf_open_btn, SIGNAL('clicked()'),
self.select_connection_file)
cf_layout = QHBoxLayout()
cf_layout.addWidget(cf_label)
cf_layout.addWidget(self.cf)
cf_layout.addWidget(cf_open_btn)
# remote kernel checkbox
self.rm_cb = QCheckBox(_('This is a remote kernel'))
# ssh connection
self.hn = QLineEdit()
self.hn.setPlaceholderText(_('[email protected]:port'))
self.kf = QLineEdit()
self.kf.setPlaceholderText(_('Path to ssh key file'))
kf_open_btn = QPushButton(_('Browse'))
self.connect(kf_open_btn, SIGNAL('clicked()'), self.select_ssh_key)
kf_layout = QHBoxLayout()
kf_layout.addWidget(self.kf)
kf_layout.addWidget(kf_open_btn)
self.pw = QLineEdit()
self.pw.setPlaceholderText(_('Password or ssh key passphrase'))
self.pw.setEchoMode(QLineEdit.Password)
ssh_form = QFormLayout()
ssh_form.addRow(_('Host name'), self.hn)
ssh_form.addRow(_('Ssh key'), kf_layout)
ssh_form.addRow(_('Password'), self.pw)
# Ok and Cancel buttons
accept_btns = QDialogButtonBox(
QDialogButtonBox.Ok | QDialogButtonBox.Cancel,
Qt.Horizontal, self)
self.connect(accept_btns, SIGNAL('accepted()'), self.accept)
self.connect(accept_btns, SIGNAL('rejected()'), self.reject)
# Dialog layout
layout = QVBoxLayout(self)
layout.addWidget(main_label)
layout.addLayout(cf_layout)
layout.addWidget(self.rm_cb)
layout.addLayout(ssh_form)
layout.addWidget(accept_btns)
# remote kernel checkbox enables the ssh_connection_form
def ssh_set_enabled(state):
for wid in [self.hn, self.kf, kf_open_btn, self.pw]:
wid.setEnabled(state)
for i in range(ssh_form.rowCount()):
ssh_form.itemAt(2 * i).widget().setEnabled(state)
ssh_set_enabled(self.rm_cb.checkState())
self.connect(self.rm_cb, SIGNAL('stateChanged(int)'), ssh_set_enabled)