本文整理汇总了Python中qtpy.QtWidgets.QWidget类的典型用法代码示例。如果您正苦于以下问题:Python QWidget类的具体用法?Python QWidget怎么用?Python QWidget使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QWidget类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, parent=None, logname=None, level=logging.NOTSET):
QWidget.__init__(self, parent=parent)
# Create Widgets
self.label = QLabel('Minimum displayed log level: ', parent=self)
self.combo = QComboBox(parent=self)
self.text = QPlainTextEdit(parent=self)
self.text.setReadOnly(True)
self.clear_btn = QPushButton("Clear", parent=self)
# Create layout
layout = QVBoxLayout()
level_control = QHBoxLayout()
level_control.addWidget(self.label)
level_control.addWidget(self.combo)
layout.addLayout(level_control)
layout.addWidget(self.text)
layout.addWidget(self.clear_btn)
self.setLayout(layout)
# Allow QCombobox to control log level
for log_level, value in LogLevels.as_dict().items():
self.combo.addItem(log_level, value)
self.combo.currentIndexChanged[str].connect(self.setLevel)
# Allow QPushButton to clear log text
self.clear_btn.clicked.connect(self.clear)
# Create a handler with the default format
self.handler = GuiHandler(level=level, parent=self)
self.logFormat = self.default_format
self.handler.message.connect(self.write)
# Create logger. Either as a root or given logname
self.log = None
self.level = None
self.logName = logname or ''
self.logLevel = level
self.destroyed.connect(functools.partial(logger_destroyed, self.log))
开发者ID:slaclab,项目名称:pydm,代码行数:33,代码来源:logdisplay.py
示例2: create_combobox
def create_combobox(self, text, choices, option, default=NoDefault,
tip=None, restart=False):
"""choices: couples (name, key)"""
label = QLabel(text)
combobox = QComboBox()
if tip is not None:
combobox.setToolTip(tip)
for name, key in choices:
if not (name is None and key is None):
combobox.addItem(name, to_qvariant(key))
# Insert separators
count = 0
for index, item in enumerate(choices):
name, key = item
if name is None and key is None:
combobox.insertSeparator(index + count)
count += 1
self.comboboxes[combobox] = (option, default)
layout = QHBoxLayout()
layout.addWidget(label)
layout.addWidget(combobox)
layout.addStretch(1)
layout.setContentsMargins(0, 0, 0, 0)
widget = QWidget(self)
widget.label = label
widget.combobox = combobox
widget.setLayout(layout)
combobox.restart_required = restart
combobox.label_text = text
return widget
开发者ID:impact27,项目名称:spyder,代码行数:30,代码来源:configdialog.py
示例3: __init__
def __init__(self, parent):
QWidget.__init__(self, parent)
self.shellwidget = None
self.is_internal_shell = None
self.ipyclient = None
self.is_ipykernel = None
self.is_visible = True
self.setup_in_progress = None
# Remote dict editor settings
self.check_all = None
self.exclude_private = None
self.exclude_uppercase = None
self.exclude_capitalized = None
self.exclude_unsupported = None
self.excluded_names = None
self.truncate = None
self.minmax = None
self.remote_editing = None
self.autorefresh = None
self.editor = None
self.exclude_private_action = None
self.exclude_uppercase_action = None
self.exclude_capitalized_action = None
self.exclude_unsupported_action = None
self.filename = None
开发者ID:ChunHungLiu,项目名称:spyder,代码行数:29,代码来源:namespacebrowser.py
示例4: __init__
def __init__(self, parent=None, init_channel=None):
QWidget.__init__(self, parent)
PyDMWidget.__init__(self, init_channel=init_channel)
self.value = 0
self.setLayout(QGridLayout(self))
self._on_color = QColor(0, 255, 0)
self._off_color = QColor(100, 100, 100)
self._disconnected_color = QColor(255, 255, 255)
self._invalid_color = QColor(255, 0, 255)
self._pen_style = Qt.SolidLine
self._line_pen = QPen(self._pen_style)
self._orientation = Qt.Vertical
# This is kind of ridiculous, importing QTabWidget just to get a 4-item enum thats usable in Designer.
# PyQt5 lets you define custom enums that you can use in designer with QtCore.Q_ENUMS(), doesn't exist in PyQt4.
self._labels = []
self._show_labels = True
self._label_position = QTabWidget.East
self._num_bits = 1
self._indicators = []
self._circles = False
self.set_spacing()
self.layout().setOriginCorner(Qt.TopLeftCorner)
self._big_endian = False
self._shift = 0
self.numBits = 1 # Need to set the property to initialize
开发者ID:slaclab,项目名称:pydm,代码行数:32,代码来源:byte.py
示例5: create_file_combobox
def create_file_combobox(self, text, choices, option, default=NoDefault,
tip=None, restart=False, filters=None,
adjust_to_contents=False,
default_line_edit=False):
"""choices: couples (name, key)"""
combobox = FileComboBox(self, adjust_to_contents=adjust_to_contents,
default_line_edit=default_line_edit)
combobox.restart_required = restart
combobox.label_text = text
edit = combobox.lineEdit()
edit.label_text = text
edit.restart_required = restart
self.lineedits[edit] = (option, default)
if tip is not None:
combobox.setToolTip(tip)
combobox.addItems(choices)
msg = _('Invalid file path')
self.validate_data[edit] = (osp.isfile, msg)
browse_btn = QPushButton(ima.icon('FileIcon'), '', self)
browse_btn.setToolTip(_("Select file"))
browse_btn.clicked.connect(lambda: self.select_file(edit, filters))
layout = QGridLayout()
layout.addWidget(combobox, 0, 0, 0, 9)
layout.addWidget(browse_btn, 0, 10)
layout.setContentsMargins(0, 0, 0, 0)
widget = QWidget(self)
widget.combobox = combobox
widget.browse_btn = browse_btn
widget.setLayout(layout)
return widget
开发者ID:impact27,项目名称:spyder,代码行数:34,代码来源:configdialog.py
示例6: create_controls
def create_controls(self):
self.btn_start = QPushButton(tr("Start"))
self.btn_stop = QPushButton(tr("Stop"))
self.btn_stop.setEnabled(False)
self.btn_start.clicked.connect(self.start_recording)
self.btn_stop.clicked.connect(self.stop_recording)
self.chk_actions = QCheckBox(tr("Actions"))
self.chk_code = QCheckBox(tr("Code"))
for c in [self.chk_actions, self.chk_code]:
c.setChecked(True)
c.toggled.connect(self.update_filter)
hbox = QHBoxLayout()
for w in [self.btn_start, self.btn_stop]:
hbox.addWidget(w)
hbox2 = QHBoxLayout()
for w in [self.chk_actions, self.chk_code]:
hbox2.addWidget(w)
vbox = QVBoxLayout()
vbox.addLayout(hbox)
vbox.addLayout(hbox2)
wrap = QWidget()
wrap.setLayout(vbox)
height = vbox.sizeHint().height()
wrap.setFixedHeight(height)
self.setWidget(wrap)
开发者ID:hyperspy,项目名称:hyperspyUI,代码行数:30,代码来源:recorderwidget.py
示例7: __init__
def __init__(self, name, a, b, callback):
QWidget.__init__(self)
self.name = name
self.callback = callback
self.a = a
self.b = b
self.manually_triggered = False
self.slider = QSlider()
self.slider.setRange(0, 1000)
self.slider.setValue(500)
self.slider.valueChanged.connect(self.slider_changed)
self.name_label = QLabel()
self.name_label.setText(self.name)
self.name_label.setAlignment(QtCore.Qt.AlignCenter)
self.value_label = QLabel()
self.value_label.setText('%2.2f' % (self.slider.value() * self.a
+ self.b))
self.value_label.setAlignment(QtCore.Qt.AlignCenter)
self.layout = QGridLayout(self)
self.layout.addWidget(self.name_label, 0, 0)
self.layout.addWidget(self.slider, 1, 0, QtCore.Qt.AlignHCenter)
self.layout.addWidget(self.value_label, 2, 0)
开发者ID:Cadair,项目名称:scikit-image,代码行数:26,代码来源:q_color_mixer.py
示例8: show
def show(self, hide_replace=True):
"""Overrides Qt Method"""
QWidget.show(self)
self.visibility_changed.emit(True)
self.change_number_matches()
if self.editor is not None:
if hide_replace:
if self.replace_widgets[0].isVisible():
self.hide_replace()
text = self.editor.get_selected_text()
# When selecting several lines, and replace box is activated the
# text won't be replaced for the selection
if hide_replace or len(text.splitlines())<=1:
highlighted = True
# If no text is highlighted for search, use whatever word is
# under the cursor
if not text:
highlighted = False
try:
cursor = self.editor.textCursor()
cursor.select(QTextCursor.WordUnderCursor)
text = to_text_string(cursor.selectedText())
except AttributeError:
# We can't do this for all widgets, e.g. WebView's
pass
# Now that text value is sorted out, use it for the search
if text and not self.search_text.currentText() or highlighted:
self.search_text.setEditText(text)
self.search_text.lineEdit().selectAll()
self.refresh()
else:
self.search_text.lineEdit().selectAll()
self.search_text.setFocus()
开发者ID:burrbull,项目名称:spyder,代码行数:34,代码来源:findreplace.py
示例9: __init__
def __init__(self, parent=None):
QWidget.__init__(self, parent)
# Widgets, layouts and signals
self._group = QButtonGroup()
layout = QGridLayout()
layout.setSpacing(0)
## Element
for z, position in _ELEMENT_POSITIONS.items():
widget = ElementPushButton(z)
widget.setCheckable(True)
layout.addWidget(widget, *position)
self._group.addButton(widget, z)
## Labels
layout.addWidget(QLabel(''), 7, 0) # Dummy
layout.addWidget(QLabel('*'), 5, 2, Qt.AlignRight)
layout.addWidget(QLabel('*'), 8, 2, Qt.AlignRight)
layout.addWidget(QLabel('**'), 6, 2, Qt.AlignRight)
layout.addWidget(QLabel('**'), 9, 2, Qt.AlignRight)
for row in [0, 1, 2, 3, 4, 5, 6, 8, 9]:
layout.setRowStretch(row, 1)
self.setLayout(layout)
# Signals
self._group.buttonClicked.connect(self.selectionChanged)
# Default
self.setColorFunction(_category_color_function)
开发者ID:pyhmsa,项目名称:pyhmsa-gui,代码行数:33,代码来源:periodictable.py
示例10: show
def show(self):
"""Overrides Qt Method"""
QWidget.show(self)
self.visibility_changed.emit(True)
if self.editor is not None:
text = self.editor.get_selected_text()
# If no text is highlighted for search, use whatever word is under
# the cursor
if not text:
try:
cursor = self.editor.textCursor()
cursor.select(QTextCursor.WordUnderCursor)
text = to_text_string(cursor.selectedText())
except AttributeError:
# We can't do this for all widgets, e.g. WebView's
pass
# Now that text value is sorted out, use it for the search
if text:
self.search_text.setEditText(text)
self.search_text.lineEdit().selectAll()
self.refresh()
else:
self.search_text.lineEdit().selectAll()
self.search_text.setFocus()
开发者ID:ShenggaoZhu,项目名称:spyder,代码行数:26,代码来源:findreplace.py
示例11: __init__
def __init__(self, parent, name, script="", filemodified=0):
QWidget.__init__(self)
self.parent = parent
self.tabWidget = self.parent.ui.tabWidget
self.gridlayout = QGridLayout(self)
self._dirty = False
self.initialize_editor()
self.gridlayout.addWidget(self.editor)
self.setAcceptDrops(True)
self.filename = name
self.filemodified = filemodified
if self.is_file():
self.title = os.path.basename(name)
# if self.equals_saved():
# self.filemodified = os.path.getmtime(self.filename)
else:
self.filename = ""
self.title = name
# Show this file in the self.editor
self.editor.setText(script)
self.clean_txt = self.saved()
self.update_dirty()
self.editor.keyPressEvent = self.key_press_event
开发者ID:madsmpedersen,项目名称:MMPE,代码行数:29,代码来源:ScriptTab.py
示例12: __init__
def __init__(self, parent=None, show_fullpath=True, fullpath_sorting=True,
show_all_files=True, show_comments=True):
QWidget.__init__(self, parent)
self.treewidget = OutlineExplorerTreeWidget(self,
show_fullpath=show_fullpath,
fullpath_sorting=fullpath_sorting,
show_all_files=show_all_files,
show_comments=show_comments)
self.visibility_action = create_action(self,
_("Show/hide outline explorer"),
icon='outline_explorer_vis.png',
toggled=self.toggle_visibility)
self.visibility_action.setChecked(True)
btn_layout = QHBoxLayout()
btn_layout.setAlignment(Qt.AlignLeft)
for btn in self.setup_buttons():
btn_layout.addWidget(btn)
layout = QVBoxLayout()
layout.setContentsMargins(0, 0, 0, 0)
layout.addLayout(btn_layout)
layout.addWidget(self.treewidget)
self.setLayout(layout)
开发者ID:ShenggaoZhu,项目名称:spyder,代码行数:26,代码来源:editortools.py
示例13: __init__
def __init__(self, parent, options_button=None, plugin_actions=[]):
QWidget.__init__(self, parent)
self.shellwidget = None
self.is_visible = True
self.setup_in_progress = None
# Remote dict editor settings
self.check_all = None
self.exclude_private = None
self.exclude_uppercase = None
self.exclude_capitalized = None
self.exclude_unsupported = None
self.excluded_names = None
self.minmax = None
# Other setting
self.dataframe_format = None
self.editor = None
self.exclude_private_action = None
self.exclude_uppercase_action = None
self.exclude_capitalized_action = None
self.exclude_unsupported_action = None
self.options_button = options_button
self.actions = None
self.plugin_actions = plugin_actions
self.filename = None
开发者ID:burrbull,项目名称:spyder,代码行数:29,代码来源:namespacebrowser.py
示例14: __init__
def __init__(self, parent):
QWidget.__init__(self, parent)
self._parent = parent
self.cp = CondaProcess(self)
# Widgets
self.button_get_conda_version = QPushButton('get_conda_version')
self.button_info = QPushButton('info')
self.button_get_envs = QPushButton('get envs')
self.button_install = QPushButton('install')
self.button_package_info = QPushButton('package info')
self.button_linked = QPushButton('linked')
self.button_pip = QPushButton('pip')
self.button_pip_remove = QPushButton('pip-remove')
self.widgets = [self.button_get_conda_version, self.button_info,
self.button_get_envs, self.button_install,
self.button_package_info, self.button_linked,
self.button_pip]
# Layout setup
layout_top = QHBoxLayout()
layout_top.addWidget(self.button_get_conda_version)
layout_top.addWidget(self.button_get_envs)
layout_top.addWidget(self.button_info)
layout_top.addWidget(self.button_install)
layout_top.addWidget(self.button_package_info)
layout_middle = QHBoxLayout()
layout_middle.addWidget(self.button_linked)
layout_bottom = QHBoxLayout()
layout_bottom.addWidget(self.button_pip)
layout_bottom.addWidget(self.button_pip_remove)
layout = QVBoxLayout()
layout.addLayout(layout_top)
layout.addLayout(layout_middle)
layout.addLayout(layout_bottom)
self.setLayout(layout)
# Signals
self.cp.sig_started.connect(self.disable_widgets)
self.cp.sig_finished.connect(self.on_finished)
self.cp.sig_finished.connect(self.enable_widgets)
self.button_get_conda_version.clicked.connect(
self.cp.get_conda_version)
self.button_get_envs.clicked.connect(self.cp.get_envs)
self.button_info.clicked.connect(self.cp.info)
self.button_install.clicked.connect(self.cp.install)
self.button_package_info.clicked.connect(
lambda: self.cp.package_info('spyder'))
self.button_linked.clicked.connect(
lambda: self.cp.linked(self.cp.ROOT_PREFIX))
self.button_pip.clicked.connect(lambda: self.cp.pip(name='root'))
self.button_pip_remove.clicked.connect(
lambda: self.cp.pip_remove(name='root', pkgs=['grequests']))
开发者ID:ccordoba12,项目名称:conda-manager,代码行数:60,代码来源:conda_api_q.py
示例15: __init__
def __init__(self, parent):
QWidget.__init__(self, parent)
vert_layout = QVBoxLayout()
# Type frame
type_layout = QHBoxLayout()
type_label = QLabel(_("Import as"))
type_layout.addWidget(type_label)
self.array_btn = array_btn = QRadioButton(_("array"))
array_btn.setEnabled(ndarray is not FakeObject)
array_btn.setChecked(ndarray is not FakeObject)
type_layout.addWidget(array_btn)
list_btn = QRadioButton(_("list"))
list_btn.setChecked(not array_btn.isChecked())
type_layout.addWidget(list_btn)
if pd:
self.df_btn = df_btn = QRadioButton(_("DataFrame"))
df_btn.setChecked(False)
type_layout.addWidget(df_btn)
h_spacer = QSpacerItem(40, 20,
QSizePolicy.Expanding, QSizePolicy.Minimum)
type_layout.addItem(h_spacer)
type_frame = QFrame()
type_frame.setLayout(type_layout)
self._table_view = PreviewTable(self)
vert_layout.addWidget(type_frame)
vert_layout.addWidget(self._table_view)
self.setLayout(vert_layout)
开发者ID:ShenggaoZhu,项目名称:spyder,代码行数:34,代码来源:importwizard.py
示例16: __init__
def __init__(self, parent=None, state=None, settings=None, data_type=None, ui_class=None, data_proxy=None):
QWidget.__init__(self, parent)
self._layout = QHBoxLayout()
self.setLayout(self._layout)
if ui_class is not None:
self._content = ui_class(self)
self._layout.addWidget(self._content)
# Data filter for file dialog
self._data_type="Data files (*.xml)"
if data_type is not None:
self._data_type = data_type
# General GUI settings
if settings is None:
settings = GeneralSettings()
self._settings = settings
if ui_class is not None:
self.setLayout(self._layout)
self.initialize_content()
self._instrument_view = None
self._data_set_viewed = ''
self._data_proxy = data_proxy
self._has_instrument_view = HAS_INSTRUMENT_VIEW and self._data_proxy is not None
self._is_running = True
开发者ID:mantidproject,项目名称:mantid,代码行数:30,代码来源:base_widget.py
示例17: __init__
def __init__(self):
QWidget.__init__(self)
vlayout = QVBoxLayout()
self.setLayout(vlayout)
self.explorer = ProjectExplorerWidget(None, show_all=True)
self.explorer.setup_project(osp.dirname(osp.abspath(__file__)))
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)
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)))
开发者ID:0xBADCA7,项目名称:spyder,代码行数:27,代码来源:explorer.py
示例18: __init__
def __init__(self, counts, colormap):
QWidget.__init__(self)
self._validate_input(counts, colormap)
self.counts = counts
self.n = np.sum(self.counts)
self.colormap = colormap
self.setMinimumSize(100, 50)
开发者ID:Cadair,项目名称:scikit-image,代码行数:7,代码来源:q_histogram.py
示例19: create_scedit
def create_scedit(self, text, option, default=NoDefault, tip=None,
without_layout=False):
label = QLabel(text)
clayout = ColorLayout(QColor(Qt.black), self)
clayout.lineedit.setMaximumWidth(80)
if tip is not None:
clayout.setToolTip(tip)
cb_bold = QCheckBox()
cb_bold.setIcon(ima.icon('bold'))
cb_bold.setToolTip(_("Bold"))
cb_italic = QCheckBox()
cb_italic.setIcon(ima.icon('italic'))
cb_italic.setToolTip(_("Italic"))
self.scedits[(clayout, cb_bold, cb_italic)] = (option, default)
if without_layout:
return label, clayout, cb_bold, cb_italic
layout = QHBoxLayout()
layout.addWidget(label)
layout.addLayout(clayout)
layout.addSpacing(10)
layout.addWidget(cb_bold)
layout.addWidget(cb_italic)
layout.addStretch(1)
layout.setContentsMargins(0, 0, 0, 0)
widget = QWidget(self)
widget.setLayout(layout)
return widget
开发者ID:impact27,项目名称:spyder,代码行数:27,代码来源:configdialog.py
示例20: __init__
def __init__(self, parent=None, show_fullpath=True, fullpath_sorting=True,
show_all_files=True, show_comments=True, options_button=None):
QWidget.__init__(self, parent)
self.treewidget = OutlineExplorerTreeWidget(self,
show_fullpath=show_fullpath,
fullpath_sorting=fullpath_sorting,
show_all_files=show_all_files,
show_comments=show_comments)
self.visibility_action = create_action(self,
_("Show/hide outline explorer"),
icon='outline_explorer_vis.png',
toggled=self.toggle_visibility)
self.visibility_action.setChecked(True)
btn_layout = QHBoxLayout()
for btn in self.setup_buttons():
btn.setAutoRaise(True)
btn.setIconSize(QSize(16, 16))
btn_layout.addWidget(btn)
if options_button:
btn_layout.addStretch()
btn_layout.addWidget(options_button, Qt.AlignRight)
layout = create_plugin_layout(btn_layout, self.treewidget)
self.setLayout(layout)
开发者ID:0xBADCA7,项目名称:spyder,代码行数:27,代码来源:editortools.py
注:本文中的qtpy.QtWidgets.QWidget类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论