本文整理汇总了Python中qtpy.QtWidgets.QVBoxLayout.addSpacing方法的典型用法代码示例。如果您正苦于以下问题:Python QVBoxLayout.addSpacing方法的具体用法?Python QVBoxLayout.addSpacing怎么用?Python QVBoxLayout.addSpacing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtWidgets.QVBoxLayout
的用法示例。
在下文中一共展示了QVBoxLayout.addSpacing方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from qtpy.QtWidgets import QVBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QVBoxLayout import addSpacing [as 别名]
def __init__(self, *args, **kwargs):
super(ClosePackageManagerDialog, self).__init__(*args, **kwargs)
self.label_icon = QLabel()
self.label_about = QLabel('Conda is still busy.\n\n'
'Do you want to cancel the process?')
self.button_ok = QPushButton('Yes')
self.button_cancel = QPushButton('No')
self.buttonbox = QDialogButtonBox(Qt.Horizontal)
# Widget setup
self.buttonbox.addButton(self.button_ok, QDialogButtonBox.ActionRole)
self.buttonbox.addButton(self.button_cancel,
QDialogButtonBox.ActionRole)
# self.label_icon.setPixmap(QPixmap(images.ANACONDA_ICON_64_PATH))
self.setWindowTitle("Cancel Process")
# Layouts
h_layout = QHBoxLayout()
h_layout.addWidget(self.label_icon, 0, Qt.AlignTop)
h_layout.addSpacing(10)
h_layout.addWidget(self.label_about)
main_layout = QVBoxLayout()
main_layout.addLayout(h_layout)
main_layout.addSpacing(20)
main_layout.addWidget(self.buttonbox)
self.setLayout(main_layout)
# Signals
self.button_ok.clicked.connect(self.accept)
self.button_cancel.clicked.connect(self.reject)
示例2: setup_page
# 需要导入模块: from qtpy.QtWidgets import QVBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QVBoxLayout import addSpacing [as 别名]
def setup_page(self):
about_label = QLabel(_("The <b>current working directory</b> is "
"the working directory for IPython consoles "
"and the current directory for the File Explorer."))
about_label.setWordWrap(True)
console_group = QGroupBox(_("Console directory"))
console_label = QLabel(_("The working directory for new consoles is:"))
console_label.setWordWrap(True)
console_bg = QButtonGroup(console_group)
console_project_radio = self.create_radiobutton(
_("The current project directory "
"or user home directory "
"(if no project is active)"),
'console/use_project_or_home_directory',
True,
button_group=console_bg)
console_cwd_radio = self.create_radiobutton(
_("The current working directory"),
'console/use_cwd',
False,
button_group=console_bg)
console_dir_radio = self.create_radiobutton(
_("the following directory:"),
'console/use_fixed_directory', False,
_("The directory when a new console "
"is open will be the specified path"),
button_group=console_bg)
console_dir_bd = self.create_browsedir("", 'console/fixed_directory',
getcwd())
console_dir_radio.toggled.connect(console_dir_bd.setEnabled)
console_project_radio.toggled.connect(console_dir_bd.setDisabled)
console_cwd_radio.toggled.connect(console_dir_bd.setDisabled)
console_dir_layout = QHBoxLayout()
console_dir_layout.addWidget(console_dir_radio)
console_dir_layout.addWidget(console_dir_bd)
console_layout = QVBoxLayout()
console_layout.addWidget(console_label)
console_layout.addWidget(console_project_radio)
console_layout.addWidget(console_cwd_radio)
console_layout.addLayout(console_dir_layout)
console_group.setLayout(console_layout)
vlayout = QVBoxLayout()
vlayout.addWidget(about_label)
vlayout.addSpacing(10)
vlayout.addWidget(console_group)
vlayout.addStretch(1)
self.setLayout(vlayout)
示例3: setup_ui
# 需要导入模块: from qtpy.QtWidgets import QVBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QVBoxLayout import addSpacing [as 别名]
def setup_ui(self):
self.setWindowTitle("Add New Grain")
self.setWindowIcon(QIcon(RESOURCE_PATH + "icons/nakka-finocyl.gif"))
self.resize(400, 400)
controls = QGridLayout()
gb_frame = QGroupBox(self.tr("Grain Design"))
gb_frame.setLayout(controls)
self.cb_grain_type = QComboBox()
# TODO: make grain types auto propagate combobox
self.cb_grain_type.addItems([self.tr("Cylindrical (BATES)")])
controls.addWidget(QLabel(self.tr("Core Shape")), 0, 0)
controls.addWidget(self.cb_grain_type, 0, 1)
self.cb_propellant_type = QComboBox()
self.cb_propellant_type.addItems(app_context.propellant_db.propellant_names())
controls.addWidget(QLabel(self.tr("Propellant Type")), 1, 0)
controls.addWidget(self.cb_propellant_type, 1, 1)
# ok and cancel buttons
btn_ok = QPushButton(self.tr("Apply"))
btn_ok.clicked.connect(self.confirm_grain)
btn_cancel = QPushButton(self.tr("Close"))
btn_cancel.clicked.connect(self.close)
lay_btns = QHBoxLayout()
lay_btns.addWidget(btn_ok)
lay_btns.addWidget(btn_cancel)
frame_btns = QFrame()
frame_btns.setLayout(lay_btns)
# master layout
master = QVBoxLayout()
master.addWidget(gb_frame)
master.addSpacing(10)
master.addWidget(frame_btns)
self.setLayout(master)
示例4: setup_page
# 需要导入模块: from qtpy.QtWidgets import QVBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QVBoxLayout import addSpacing [as 别名]
def setup_page(self):
about_label = QLabel(_("The <b>global working directory</b> is "
"the working directory for newly opened <i>consoles</i> "
"(Python/IPython consoles and terminals), for the "
"<i>file explorer</i>, for the <i>find in files</i> "
"plugin and for new files created in the <i>editor</i>."))
about_label.setWordWrap(True)
startup_group = QGroupBox(_("Startup"))
startup_bg = QButtonGroup(startup_group)
startup_label = QLabel(_("At startup, the global working "
"directory is:"))
startup_label.setWordWrap(True)
lastdir_radio = self.create_radiobutton(
_("the same as in last session"),
'startup/use_last_directory', True,
_("At startup, Spyder will restore the "
"global directory from last session"),
button_group=startup_bg)
thisdir_radio = self.create_radiobutton(
_("the following directory:"),
'startup/use_fixed_directory', False,
_("At startup, the global working "
"directory will be the specified path"),
button_group=startup_bg)
thisdir_bd = self.create_browsedir("", 'startup/fixed_directory',
getcwd())
thisdir_radio.toggled.connect(thisdir_bd.setEnabled)
lastdir_radio.toggled.connect(thisdir_bd.setDisabled)
thisdir_layout = QHBoxLayout()
thisdir_layout.addWidget(thisdir_radio)
thisdir_layout.addWidget(thisdir_bd)
editor_o_group = QGroupBox(_("Open file"))
editor_o_label = QLabel(_("Files are opened from:"))
editor_o_label.setWordWrap(True)
editor_o_bg = QButtonGroup(editor_o_group)
editor_o_radio1 = self.create_radiobutton(
_("the current file directory"),
'editor/open/browse_scriptdir',
button_group=editor_o_bg)
editor_o_radio2 = self.create_radiobutton(
_("the global working directory"),
'editor/open/browse_workdir',
button_group=editor_o_bg)
editor_n_group = QGroupBox(_("New file"))
editor_n_label = QLabel(_("Files are created in:"))
editor_n_label.setWordWrap(True)
editor_n_bg = QButtonGroup(editor_n_group)
editor_n_radio1 = self.create_radiobutton(
_("the current file directory"),
'editor/new/browse_scriptdir',
button_group=editor_n_bg)
editor_n_radio2 = self.create_radiobutton(
_("the global working directory"),
'editor/new/browse_workdir',
button_group=editor_n_bg)
# Note: default values for the options above are set in plugin's
# constructor (see below)
other_group = QGroupBox(_("Change to file base directory"))
newcb = self.create_checkbox
open_box = newcb(_("When opening a file"),
'editor/open/auto_set_to_basedir')
save_box = newcb(_("When saving a file"),
'editor/save/auto_set_to_basedir')
startup_layout = QVBoxLayout()
startup_layout.addWidget(startup_label)
startup_layout.addWidget(lastdir_radio)
startup_layout.addLayout(thisdir_layout)
startup_group.setLayout(startup_layout)
editor_o_layout = QVBoxLayout()
editor_o_layout.addWidget(editor_o_label)
editor_o_layout.addWidget(editor_o_radio1)
editor_o_layout.addWidget(editor_o_radio2)
editor_o_group.setLayout(editor_o_layout)
editor_n_layout = QVBoxLayout()
editor_n_layout.addWidget(editor_n_label)
editor_n_layout.addWidget(editor_n_radio1)
editor_n_layout.addWidget(editor_n_radio2)
editor_n_group.setLayout(editor_n_layout)
other_layout = QVBoxLayout()
other_layout.addWidget(open_box)
other_layout.addWidget(save_box)
other_group.setLayout(other_layout)
vlayout = QVBoxLayout()
vlayout.addWidget(about_label)
vlayout.addSpacing(10)
vlayout.addWidget(startup_group)
vlayout.addWidget(editor_o_group)
vlayout.addWidget(editor_n_group)
vlayout.addWidget(other_group)
vlayout.addStretch(1)
self.setLayout(vlayout)
示例5: __init__
# 需要导入模块: from qtpy.QtWidgets import QVBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QVBoxLayout import addSpacing [as 别名]
def __init__(self, frameworks, config, parent=None):
"""
Construct a dialog window.
Parameters
----------
frameworks : dict of (str, type)
Names of all supported frameworks with their associated class
(assumed to be a subclass of RunnerBase)
config : Config
Initial configuration
parent : QWidget
"""
super(ConfigDialog, self).__init__(parent)
self.setWindowTitle(_('Configure tests'))
layout = QVBoxLayout(self)
framework_layout = QHBoxLayout()
framework_label = QLabel(_('Test framework'))
framework_layout.addWidget(framework_label)
self.framework_combobox = QComboBox(self)
for ix, (name, runner) in enumerate(sorted(frameworks.items())):
installed = runner.is_installed()
if installed:
label = name
else:
label = '{} ({})'.format(name, _('not available'))
self.framework_combobox.addItem(label)
self.framework_combobox.model().item(ix).setEnabled(installed)
framework_layout.addWidget(self.framework_combobox)
layout.addLayout(framework_layout)
layout.addSpacing(10)
wdir_label = QLabel(_('Directory from which to run tests'))
layout.addWidget(wdir_label)
wdir_layout = QHBoxLayout()
self.wdir_lineedit = QLineEdit(self)
wdir_layout.addWidget(self.wdir_lineedit)
self.wdir_button = QPushButton(ima.icon('DirOpenIcon'), '', self)
self.wdir_button.setToolTip(_("Select directory"))
self.wdir_button.clicked.connect(lambda: self.select_directory())
wdir_layout.addWidget(self.wdir_button)
layout.addLayout(wdir_layout)
layout.addSpacing(20)
self.buttons = QDialogButtonBox(QDialogButtonBox.Ok |
QDialogButtonBox.Cancel)
layout.addWidget(self.buttons)
self.buttons.accepted.connect(self.accept)
self.buttons.rejected.connect(self.reject)
self.ok_button = self.buttons.button(QDialogButtonBox.Ok)
self.ok_button.setEnabled(False)
self.framework_combobox.currentIndexChanged.connect(
self.framework_changed)
self.framework_combobox.setCurrentIndex(-1)
if config.framework:
index = self.framework_combobox.findText(config.framework)
if index != -1:
self.framework_combobox.setCurrentIndex(index)
self.wdir_lineedit.setText(config.wdir)
示例6: setup_page
# 需要导入模块: from qtpy.QtWidgets import QVBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QVBoxLayout import addSpacing [as 别名]
def setup_page(self):
about_label = QLabel(_("The following are the default options for "
"running files.These options may be overriden "
"using the <b>Configuration per file</b> entry "
"of the <b>Run</b> menu."))
about_label.setWordWrap(True)
interpreter_group = QGroupBox(_("Console"))
interpreter_bg = QButtonGroup(interpreter_group)
self.current_radio = self.create_radiobutton(CURRENT_INTERPRETER,
CURRENT_INTERPRETER_OPTION, True,
button_group=interpreter_bg)
self.dedicated_radio = self.create_radiobutton(DEDICATED_INTERPRETER,
DEDICATED_INTERPRETER_OPTION, False,
button_group=interpreter_bg)
self.systerm_radio = self.create_radiobutton(SYSTERM_INTERPRETER,
SYSTERM_INTERPRETER_OPTION, False,
button_group=interpreter_bg)
interpreter_layout = QVBoxLayout()
interpreter_group.setLayout(interpreter_layout)
interpreter_layout.addWidget(self.current_radio)
interpreter_layout.addWidget(self.dedicated_radio)
interpreter_layout.addWidget(self.systerm_radio)
general_group = QGroupBox(_("General settings"))
post_mortem = self.create_checkbox(POST_MORTEM, 'post_mortem', False)
clear_variables = self.create_checkbox(CLEAR_ALL_VARIABLES,
'clear_namespace', False)
general_layout = QVBoxLayout()
general_layout.addWidget(clear_variables)
general_layout.addWidget(post_mortem)
general_group.setLayout(general_layout)
wdir_group = QGroupBox(_("Working Directory settings"))
wdir_bg = QButtonGroup(wdir_group)
wdir_label = QLabel(_("Default working directory is:"))
wdir_label.setWordWrap(True)
dirname_radio = self.create_radiobutton(
FILE_DIR,
WDIR_USE_SCRIPT_DIR_OPTION, True,
button_group=wdir_bg)
cwd_radio = self.create_radiobutton(
CW_DIR,
WDIR_USE_CWD_DIR_OPTION, False,
button_group=wdir_bg)
thisdir_radio = self.create_radiobutton(
FIXED_DIR,
WDIR_USE_FIXED_DIR_OPTION, False,
button_group=wdir_bg)
thisdir_bd = self.create_browsedir("", WDIR_FIXED_DIR_OPTION,
getcwd_or_home())
thisdir_radio.toggled.connect(thisdir_bd.setEnabled)
dirname_radio.toggled.connect(thisdir_bd.setDisabled)
cwd_radio.toggled.connect(thisdir_bd.setDisabled)
thisdir_layout = QHBoxLayout()
thisdir_layout.addWidget(thisdir_radio)
thisdir_layout.addWidget(thisdir_bd)
wdir_layout = QVBoxLayout()
wdir_layout.addWidget(wdir_label)
wdir_layout.addWidget(dirname_radio)
wdir_layout.addWidget(cwd_radio)
wdir_layout.addLayout(thisdir_layout)
wdir_group.setLayout(wdir_layout)
external_group = QGroupBox(_("External system terminal"))
interact_after = self.create_checkbox(INTERACT, 'interact', False)
external_layout = QVBoxLayout()
external_layout.addWidget(interact_after)
external_group.setLayout(external_layout)
firstrun_cb = self.create_checkbox(
ALWAYS_OPEN_FIRST_RUN % _("Run Settings dialog"),
ALWAYS_OPEN_FIRST_RUN_OPTION, False)
vlayout = QVBoxLayout()
vlayout.addWidget(about_label)
vlayout.addSpacing(10)
vlayout.addWidget(interpreter_group)
vlayout.addWidget(general_group)
vlayout.addWidget(wdir_group)
vlayout.addWidget(external_group)
vlayout.addWidget(firstrun_cb)
vlayout.addStretch(1)
self.setLayout(vlayout)
示例7: setup_grain_design
# 需要导入模块: from qtpy.QtWidgets import QVBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QVBoxLayout import addSpacing [as 别名]
def setup_grain_design():
# grain table view
master = QHBoxLayout(self)
master.addWidget(QTableView())
# grain design controls
controls = QVBoxLayout(self)
# add a push button
self.btn_new_grain = QPushButton(self.tr("New Grain"))
self.btn_new_grain.setMinimumHeight(50)
controls.addWidget(self.btn_new_grain)
# add a dividing line
line = QFrame()
line.setFrameShape(QFrame.HLine)
line.setFrameShadow(QFrame.Sunken)
controls.addSpacing(5)
controls.addWidget(line)
# rest of the controls buttons
self.btn_edit_grain = QPushButton(self.tr("Edit"))
self.btn_edit_grain.setMinimumHeight(30)
controls.addWidget(self.btn_edit_grain)
self.btn_delete_Grain = QPushButton(self.tr("Delete"))
self.btn_delete_Grain.setMinimumHeight(30)
controls.addWidget(self.btn_delete_Grain)
# move grain up and down
moveup = QHBoxLayout()
self.btn_move_up = QToolButton()
self.btn_move_up.setArrowType(Qt.UpArrow)
moveup.addWidget(self.btn_move_up)
moveup.addWidget(QLabel(self.tr("Move Up")))
controls.addLayout(moveup)
movedown = QHBoxLayout()
self.btn_move_down = QToolButton()
self.btn_move_down.setArrowType(Qt.DownArrow)
movedown.addWidget(self.btn_move_down)
movedown.addWidget(QLabel(self.tr("Move Down")))
controls.addLayout(movedown)
controls.addStretch()
# add info for motor design
fl_propellant_info = QFormLayout()
gb_motor_info = QGroupBox(self.tr("Propellant Info"))
gb_motor_info.setLayout(fl_propellant_info)
self.lbl_num_grains = QLabel()
fl_propellant_info.addRow(QLabel(self.tr("Number of Segments:")), self.lbl_num_grains)
self.lbl_motor_dia = QLabel()
fl_propellant_info.addRow(QLabel(self.tr("Motor Diameter:")), self.lbl_motor_dia)
self.lbl_motor_len = QLabel()
fl_propellant_info.addRow(QLabel(self.tr("Propellant Length:")), self.lbl_motor_len)
self.lbl_prop_mass = QLabel()
fl_propellant_info.addRow(QLabel(self.tr("Propellant Mass:")), self.lbl_prop_mass)
self.lbl_volume_loading = QLabel()
fl_propellant_info.addRow(QLabel(self.tr("Volume Loading:")), self.lbl_volume_loading)
# set group box's layout
controls.addWidget(gb_motor_info)
# setup master layout
master.addLayout(controls)
self.gb_design = QGroupBox(self.tr("Grain Design"))
self.gb_design.setLayout(master)
示例8: __init__
# 需要导入模块: from qtpy.QtWidgets import QVBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QVBoxLayout import addSpacing [as 别名]
def __init__(self, parent, context, name, sequence, shortcuts):
super(ShortcutEditor, self).__init__(parent)
self._parent = parent
self.context = context
self.npressed = 0
self.keys = set()
self.key_modifiers = set()
self.key_non_modifiers = list()
self.key_text = list()
self.sequence = sequence
self.new_sequence = None
self.edit_state = True
self.shortcuts = shortcuts
# Widgets
self.label_info = QLabel()
self.label_info.setText(_("Press the new shortcut and select 'Ok': \n"
"(Press 'Tab' once to switch focus between the shortcut entry \n"
"and the buttons below it)"))
self.label_current_sequence = QLabel(_("Current shortcut:"))
self.text_current_sequence = QLabel(sequence)
self.label_new_sequence = QLabel(_("New shortcut:"))
self.text_new_sequence = CustomLineEdit(self)
self.text_new_sequence.setPlaceholderText(sequence)
self.helper_button = HelperToolButton()
self.helper_button.hide()
self.label_warning = QLabel()
self.label_warning.hide()
bbox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
self.button_ok = bbox.button(QDialogButtonBox.Ok)
self.button_cancel = bbox.button(QDialogButtonBox.Cancel)
# Setup widgets
self.setWindowTitle(_('Shortcut: {0}').format(name))
self.button_ok.setFocusPolicy(Qt.NoFocus)
self.button_ok.setEnabled(False)
self.button_cancel.setFocusPolicy(Qt.NoFocus)
self.helper_button.setToolTip('')
self.helper_button.setFocusPolicy(Qt.NoFocus)
style = """
QToolButton {
margin:1px;
border: 0px solid grey;
padding:0px;
border-radius: 0px;
}"""
self.helper_button.setStyleSheet(style)
self.text_new_sequence.setFocusPolicy(Qt.NoFocus)
self.label_warning.setFocusPolicy(Qt.NoFocus)
# Layout
spacing = 5
layout_sequence = QGridLayout()
layout_sequence.addWidget(self.label_info, 0, 0, 1, 3)
layout_sequence.addItem(QSpacerItem(spacing, spacing), 1, 0, 1, 2)
layout_sequence.addWidget(self.label_current_sequence, 2, 0)
layout_sequence.addWidget(self.text_current_sequence, 2, 2)
layout_sequence.addWidget(self.label_new_sequence, 3, 0)
layout_sequence.addWidget(self.helper_button, 3, 1)
layout_sequence.addWidget(self.text_new_sequence, 3, 2)
layout_sequence.addWidget(self.label_warning, 4, 2, 1, 2)
layout = QVBoxLayout()
layout.addLayout(layout_sequence)
layout.addSpacing(spacing)
layout.addWidget(bbox)
self.setLayout(layout)
# Signals
bbox.accepted.connect(self.accept)
bbox.rejected.connect(self.reject)
示例9: setup_page
# 需要导入模块: from qtpy.QtWidgets import QVBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QVBoxLayout import addSpacing [as 别名]
def setup_page(self):
run_dlg = _("Run Settings")
run_menu = _("Run")
about_label = QLabel(
_(
"The following are the default <i>%s</i>. "
"These options may be overriden using the "
"<b>%s</b> dialog box (see the <b>%s</b> menu)"
)
% (run_dlg, run_dlg, run_menu)
)
about_label.setWordWrap(True)
interpreter_group = QGroupBox(_("Console"))
interpreter_bg = QButtonGroup(interpreter_group)
self.current_radio = self.create_radiobutton(
CURRENT_INTERPRETER, CURRENT_INTERPRETER_OPTION, True, button_group=interpreter_bg
)
self.dedicated_radio = self.create_radiobutton(
DEDICATED_INTERPRETER, DEDICATED_INTERPRETER_OPTION, False, button_group=interpreter_bg
)
self.systerm_radio = self.create_radiobutton(
SYSTERM_INTERPRETER, SYSTERM_INTERPRETER_OPTION, False, button_group=interpreter_bg
)
interpreter_layout = QVBoxLayout()
interpreter_group.setLayout(interpreter_layout)
interpreter_layout.addWidget(self.current_radio)
interpreter_layout.addWidget(self.dedicated_radio)
interpreter_layout.addWidget(self.systerm_radio)
general_group = QGroupBox("General settings")
wdir_bg = QButtonGroup(general_group)
wdir_label = QLabel(_("Default working directory is:"))
wdir_label.setWordWrap(True)
dirname_radio = self.create_radiobutton(
_("the script directory"), WDIR_USE_SCRIPT_DIR_OPTION, True, button_group=wdir_bg
)
thisdir_radio = self.create_radiobutton(
_("the following directory:"), WDIR_USE_FIXED_DIR_OPTION, False, button_group=wdir_bg
)
thisdir_bd = self.create_browsedir("", WDIR_FIXED_DIR_OPTION, getcwd())
thisdir_radio.toggled.connect(thisdir_bd.setEnabled)
dirname_radio.toggled.connect(thisdir_bd.setDisabled)
thisdir_layout = QHBoxLayout()
thisdir_layout.addWidget(thisdir_radio)
thisdir_layout.addWidget(thisdir_bd)
post_mortem = self.create_checkbox(
_("Enter debugging mode when errors appear during execution"), "post_mortem", False
)
general_layout = QVBoxLayout()
general_layout.addWidget(wdir_label)
general_layout.addWidget(dirname_radio)
general_layout.addLayout(thisdir_layout)
general_layout.addWidget(post_mortem)
general_group.setLayout(general_layout)
dedicated_group = QGroupBox(_("Dedicated Python console"))
interact_after = self.create_checkbox(_("Interact with the Python console after execution"), "interact", False)
show_warning = self.create_checkbox(_("Show warning when killing running processes"), "show_kill_warning", True)
dedicated_layout = QVBoxLayout()
dedicated_layout.addWidget(interact_after)
dedicated_layout.addWidget(show_warning)
dedicated_group.setLayout(dedicated_layout)
firstrun_cb = self.create_checkbox(
ALWAYS_OPEN_FIRST_RUN % _("Run Settings dialog"), ALWAYS_OPEN_FIRST_RUN_OPTION, False
)
vlayout = QVBoxLayout()
vlayout.addWidget(about_label)
vlayout.addSpacing(10)
vlayout.addWidget(interpreter_group)
vlayout.addWidget(general_group)
vlayout.addWidget(dedicated_group)
vlayout.addWidget(firstrun_cb)
vlayout.addStretch(1)
self.setLayout(vlayout)
示例10: setup
# 需要导入模块: from qtpy.QtWidgets import QVBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QVBoxLayout import addSpacing [as 别名]
def setup(self):
"""Setup the ShortcutEditor with the provided arguments."""
# Widgets
icon_info = HelperToolButton()
icon_info.setIcon(get_std_icon('MessageBoxInformation'))
layout_icon_info = QVBoxLayout()
layout_icon_info.setContentsMargins(0, 0, 0, 0)
layout_icon_info.setSpacing(0)
layout_icon_info.addWidget(icon_info)
layout_icon_info.addStretch(100)
self.label_info = QLabel()
self.label_info.setText(
_("Press the new shortcut and select 'Ok' to confirm, "
"click 'Cancel' to revert to the previous state, "
"or use 'Clear' to unbind the command from a shortcut."))
self.label_info.setAlignment(Qt.AlignTop | Qt.AlignLeft)
self.label_info.setWordWrap(True)
layout_info = QHBoxLayout()
layout_info.setContentsMargins(0, 0, 0, 0)
layout_info.addLayout(layout_icon_info)
layout_info.addWidget(self.label_info)
layout_info.setStretch(1, 100)
self.label_current_sequence = QLabel(_("Current shortcut:"))
self.text_current_sequence = QLabel(self.current_sequence)
self.label_new_sequence = QLabel(_("New shortcut:"))
self.text_new_sequence = ShortcutLineEdit(self)
self.text_new_sequence.setPlaceholderText(_("Press shortcut."))
self.helper_button = HelperToolButton()
self.helper_button.setIcon(QIcon())
self.label_warning = QLabel()
self.label_warning.setWordWrap(True)
self.label_warning.setAlignment(Qt.AlignTop | Qt.AlignLeft)
self.button_default = QPushButton(_('Default'))
self.button_ok = QPushButton(_('Ok'))
self.button_ok.setEnabled(False)
self.button_clear = QPushButton(_('Clear'))
self.button_cancel = QPushButton(_('Cancel'))
button_box = QHBoxLayout()
button_box.addWidget(self.button_default)
button_box.addStretch(100)
button_box.addWidget(self.button_ok)
button_box.addWidget(self.button_clear)
button_box.addWidget(self.button_cancel)
# New Sequence button box
self.btn_clear_sequence = create_toolbutton(
self, icon=ima.icon('editclear'),
tip=_("Clear all entered key sequences"),
triggered=self.clear_new_sequence)
self.button_back_sequence = create_toolbutton(
self, icon=ima.icon('ArrowBack'),
tip=_("Remove last key sequence entered"),
triggered=self.back_new_sequence)
newseq_btnbar = QHBoxLayout()
newseq_btnbar.setSpacing(0)
newseq_btnbar.setContentsMargins(0, 0, 0, 0)
newseq_btnbar.addWidget(self.button_back_sequence)
newseq_btnbar.addWidget(self.btn_clear_sequence)
# Setup widgets
self.setWindowTitle(_('Shortcut: {0}').format(self.name))
self.helper_button.setToolTip('')
style = """
QToolButton {
margin:1px;
border: 0px solid grey;
padding:0px;
border-radius: 0px;
}"""
self.helper_button.setStyleSheet(style)
icon_info.setToolTip('')
icon_info.setStyleSheet(style)
# Layout
layout_sequence = QGridLayout()
layout_sequence.setContentsMargins(0, 0, 0, 0)
layout_sequence.addLayout(layout_info, 0, 0, 1, 4)
layout_sequence.addItem(QSpacerItem(15, 15), 1, 0, 1, 4)
layout_sequence.addWidget(self.label_current_sequence, 2, 0)
layout_sequence.addWidget(self.text_current_sequence, 2, 2)
layout_sequence.addWidget(self.label_new_sequence, 3, 0)
layout_sequence.addWidget(self.helper_button, 3, 1)
layout_sequence.addWidget(self.text_new_sequence, 3, 2)
layout_sequence.addLayout(newseq_btnbar, 3, 3)
layout_sequence.addWidget(self.label_warning, 4, 2, 1, 2)
layout_sequence.setColumnStretch(2, 100)
layout_sequence.setRowStretch(4, 100)
layout = QVBoxLayout()
layout.addLayout(layout_sequence)
layout.addSpacing(5)
layout.addLayout(button_box)
self.setLayout(layout)
#.........这里部分代码省略.........
示例11: setup_page
# 需要导入模块: from qtpy.QtWidgets import QVBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QVBoxLayout import addSpacing [as 别名]
#.........这里部分代码省略.........
_("Please don't modify these values unless "
"you know what you're doing!"))
advanced_label.setWordWrap(True)
advanced_label.setAlignment(Qt.AlignJustify)
# Advanced options
advanced_command_launch = self.create_lineedit(
_("Command to launch the Python language server: "),
'advanced/command_launch', alignment=Qt.Horizontal,
word_wrap=False)
advanced_host = self.create_lineedit(
_("IP Address and port to bind the server to: "),
'advanced/host', alignment=Qt.Horizontal,
word_wrap=False)
advanced_port = self.create_spinbox(
":", "", 'advanced/port', min_=1, max_=65535, step=1)
# Advanced layout
advanced_g_layout = QGridLayout()
advanced_g_layout.addWidget(advanced_command_launch.label, 1, 0)
advanced_g_layout.addWidget(advanced_command_launch.textbox, 1, 1)
advanced_g_layout.addWidget(advanced_host.label, 2, 0)
advanced_host_port_g_layout = QGridLayout()
advanced_host_port_g_layout.addWidget(advanced_host.textbox, 1, 0)
advanced_host_port_g_layout.addWidget(advanced_port.plabel, 1, 1)
advanced_host_port_g_layout.addWidget(advanced_port.spinbox, 1, 2)
advanced_g_layout.addLayout(advanced_host_port_g_layout, 2, 1)
advanced_widget = QWidget()
advanced_layout = QVBoxLayout()
advanced_layout.addWidget(advanced_label)
advanced_layout.addLayout(advanced_g_layout)
advanced_widget.setLayout(advanced_layout)
# --- Other servers tab ---
# Section label
servers_label = QLabel(
_("Spyder uses the <a href=\"{lsp_url}\">Language Server "
"Protocol</a> to provide code completion and linting "
"for its Editor. Here, you can setup and configure LSP servers "
"for languages other than Python, so Spyder can provide such "
"features for those languages as well."
).format(lsp_url=LSP_URL))
servers_label.setOpenExternalLinks(True)
servers_label.setWordWrap(True)
servers_label.setAlignment(Qt.AlignJustify)
# Servers table
table_group = QGroupBox(_('Available servers:'))
self.table = LSPServerTable(self, text_color=ima.MAIN_FG_COLOR)
table_layout = QVBoxLayout()
table_layout.addWidget(self.table)
table_group.setLayout(table_layout)
# Buttons
self.reset_btn = QPushButton(_("Reset to default values"))
self.new_btn = QPushButton(_("Set up a new server"))
self.delete_btn = QPushButton(_("Delete currently selected server"))
self.delete_btn.setEnabled(False)
# Slots connected to buttons
self.new_btn.clicked.connect(self.create_new_server)
self.reset_btn.clicked.connect(self.reset_to_default)
self.delete_btn.clicked.connect(self.delete_server)
# Buttons layout
btns = [self.new_btn, self.delete_btn, self.reset_btn]
buttons_layout = QGridLayout()
for i, btn in enumerate(btns):
buttons_layout.addWidget(btn, i, 1)
buttons_layout.setColumnStretch(0, 1)
buttons_layout.setColumnStretch(1, 2)
buttons_layout.setColumnStretch(2, 1)
# Combined layout
servers_widget = QWidget()
servers_layout = QVBoxLayout()
servers_layout.addSpacing(-10)
servers_layout.addWidget(servers_label)
servers_layout.addWidget(table_group)
servers_layout.addSpacing(10)
servers_layout.addLayout(buttons_layout)
servers_widget.setLayout(servers_layout)
# --- Tabs organization ---
tabs = QTabWidget()
tabs.addTab(self.create_tab(basic_features_group, advanced_group),
_('Introspection'))
tabs.addTab(self.create_tab(linting_widget), _('Linting'))
tabs.addTab(self.create_tab(code_style_widget), _('Code style'))
tabs.addTab(self.create_tab(docstring_style_widget),
_('Docstring style'))
tabs.addTab(self.create_tab(advanced_widget),
_('Advanced'))
tabs.addTab(self.create_tab(servers_widget), _('Other languages'))
vlayout = QVBoxLayout()
vlayout.addWidget(tabs)
self.setLayout(vlayout)
示例12: __init__
# 需要导入模块: from qtpy.QtWidgets import QVBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QVBoxLayout import addSpacing [as 别名]
#.........这里部分代码省略.........
"quicker solution."
).format(title=title, trouble_url=__trouble_url__,
project_url=__project_url__))
main_label.setOpenExternalLinks(True)
main_label.setWordWrap(True)
main_label.setAlignment(Qt.AlignJustify)
main_label.setStyleSheet('font-size: 12px;')
# Issue title
self.title = QLineEdit()
self.title.textChanged.connect(self._contents_changed)
self.title_chars_label = QLabel(_("{} more characters "
"to go...").format(TITLE_MIN_CHARS))
form_layout = QFormLayout()
form_layout.setFieldGrowthPolicy(QFormLayout.ExpandingFieldsGrow)
red_asterisk = '<font color="Red">*</font>'
title_label = QLabel(_("<b>Title</b>: {}").format(red_asterisk))
form_layout.setWidget(0, QFormLayout.LabelRole, title_label)
form_layout.setWidget(0, QFormLayout.FieldRole, self.title)
# Description
steps_header = QLabel(
_("<b>Steps to reproduce:</b> {}").format(red_asterisk))
steps_text = QLabel(_("Please enter a detailed step-by-step "
"description (in English) of what led up to "
"the problem below. Issue reports without a "
"clear way to reproduce them will be closed."))
steps_text.setWordWrap(True)
steps_text.setAlignment(Qt.AlignJustify)
steps_text.setStyleSheet('font-size: 12px;')
# Field to input the description of the problem
self.input_description = DescriptionWidget(self)
# Only allow to submit to Github if we have a long enough description
self.input_description.textChanged.connect(self._contents_changed)
# Widget to show errors
self.details = ShowErrorWidget(self)
self.details.set_pythonshell_font(get_font())
self.details.hide()
# Label to show missing chars
self.initial_chars = len(self.input_description.toPlainText())
self.desc_chars_label = QLabel(_("{} more characters "
"to go...").format(DESC_MIN_CHARS))
# Checkbox to dismiss future errors
self.dismiss_box = QCheckBox(_("Hide all future errors during this "
"session"))
if self.is_report:
self.dismiss_box.hide()
# Dialog buttons
gh_icon = ima.icon('github')
self.submit_btn = QPushButton(gh_icon, _('Submit to Github'))
self.submit_btn.setEnabled(False)
self.submit_btn.clicked.connect(self._submit_to_github)
self.details_btn = QPushButton(_('Show details'))
self.details_btn.clicked.connect(self._show_details)
if self.is_report:
self.details_btn.hide()
self.close_btn = QPushButton(_('Close'))
if self.is_report:
self.close_btn.clicked.connect(self.reject)
# Buttons layout
buttons_layout = QHBoxLayout()
buttons_layout.addWidget(self.submit_btn)
buttons_layout.addWidget(self.details_btn)
buttons_layout.addWidget(self.close_btn)
# Main layout
layout = QVBoxLayout()
layout.addWidget(main_label)
layout.addSpacing(20)
layout.addLayout(form_layout)
layout.addWidget(self.title_chars_label)
layout.addSpacing(12)
layout.addWidget(steps_header)
layout.addSpacing(-1)
layout.addWidget(steps_text)
layout.addSpacing(1)
layout.addWidget(self.input_description)
layout.addWidget(self.details)
layout.addWidget(self.desc_chars_label)
layout.addSpacing(15)
layout.addWidget(self.dismiss_box)
layout.addSpacing(15)
layout.addLayout(buttons_layout)
layout.setContentsMargins(25, 20, 25, 10)
self.setLayout(layout)
self.resize(570, 600)
self.title.setFocus()
# Set Tab key focus order
self.setTabOrder(self.title, self.input_description)
示例13: __init__
# 需要导入模块: from qtpy.QtWidgets import QVBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QVBoxLayout import addSpacing [as 别名]
def __init__(self, parent):
"""Project creation dialog."""
super(ProjectDialog, self).__init__(parent=parent)
# Variables
current_python_version = '.'.join([to_text_string(sys.version_info[0]),
to_text_string(sys.version_info[1])])
python_versions = ['2.7', '3.4', '3.5']
if current_python_version not in python_versions:
python_versions.append(current_python_version)
python_versions = sorted(python_versions)
self.project_name = None
self.location = get_home_dir()
# Widgets
self.groupbox = QGroupBox()
self.radio_new_dir = QRadioButton(_("New directory"))
self.radio_from_dir = QRadioButton(_("Existing directory"))
self.label_project_name = QLabel(_('Project name'))
self.label_location = QLabel(_('Location'))
self.label_project_type = QLabel(_('Project type'))
self.label_python_version = QLabel(_('Python version'))
self.text_project_name = QLineEdit()
self.text_location = QLineEdit(get_home_dir())
self.combo_project_type = QComboBox()
self.combo_python_version = QComboBox()
self.button_select_location = QToolButton()
self.button_cancel = QPushButton(_('Cancel'))
self.button_create = QPushButton(_('Create'))
self.bbox = QDialogButtonBox(Qt.Horizontal)
self.bbox.addButton(self.button_cancel, QDialogButtonBox.ActionRole)
self.bbox.addButton(self.button_create, QDialogButtonBox.ActionRole)
# Widget setup
self.combo_python_version.addItems(python_versions)
self.radio_new_dir.setChecked(True)
self.text_location.setEnabled(True)
self.text_location.setReadOnly(True)
self.button_select_location.setIcon(get_std_icon('DirOpenIcon'))
self.button_cancel.setDefault(True)
self.button_cancel.setAutoDefault(True)
self.button_create.setEnabled(False)
self.combo_project_type.addItems(self._get_project_types())
self.combo_python_version.setCurrentIndex(
python_versions.index(current_python_version))
self.setWindowTitle(_('Create new project'))
self.setFixedWidth(500)
self.label_python_version.setVisible(False)
self.combo_python_version.setVisible(False)
# Layouts
layout_top = QHBoxLayout()
layout_top.addWidget(self.radio_new_dir)
layout_top.addWidget(self.radio_from_dir)
layout_top.addStretch(1)
self.groupbox.setLayout(layout_top)
layout_grid = QGridLayout()
layout_grid.addWidget(self.label_project_name, 0, 0)
layout_grid.addWidget(self.text_project_name, 0, 1, 1, 2)
layout_grid.addWidget(self.label_location, 1, 0)
layout_grid.addWidget(self.text_location, 1, 1)
layout_grid.addWidget(self.button_select_location, 1, 2)
layout_grid.addWidget(self.label_project_type, 2, 0)
layout_grid.addWidget(self.combo_project_type, 2, 1, 1, 2)
layout_grid.addWidget(self.label_python_version, 3, 0)
layout_grid.addWidget(self.combo_python_version, 3, 1, 1, 2)
layout = QVBoxLayout()
layout.addWidget(self.groupbox)
layout.addSpacing(10)
layout.addLayout(layout_grid)
layout.addStretch()
layout.addSpacing(20)
layout.addWidget(self.bbox)
self.setLayout(layout)
# Signals and slots
self.button_select_location.clicked.connect(self.select_location)
self.button_create.clicked.connect(self.create_project)
self.button_cancel.clicked.connect(self.close)
self.radio_from_dir.clicked.connect(self.update_location)
self.radio_new_dir.clicked.connect(self.update_location)
self.text_project_name.textChanged.connect(self.update_location)
示例14: __init__
# 需要导入模块: from qtpy.QtWidgets import QVBoxLayout [as 别名]
# 或者: from qtpy.QtWidgets.QVBoxLayout import addSpacing [as 别名]
#.........这里部分代码省略.........
self.table_first_row = FirstRowWidget(
widget_before=self.textbox_search)
self.table_last_row = LastRowWidget(
widgets_after=[self.button_apply, self.button_clear,
self.button_cancel, self.combobox_filter])
# Widget setup
self.button_options.setPopupMode(QToolButton.InstantPopup)
self.button_options.setIcon(icon_options)
self.button_options.setAutoRaise(True)
max_height = self.status_bar.fontMetrics().height()
max_width = self.textbox_search.fontMetrics().width('M'*23)
self.bbox.addButton(self.button_ok, QDialogButtonBox.ActionRole)
self.button_ok.setAutoDefault(True)
self.button_ok.setDefault(True)
self.button_ok.setMaximumSize(QSize(0, 0))
self.button_ok.setVisible(False)
self.combobox_filter.addItems([k for k in C.COMBOBOX_VALUES_ORDERED])
self.combobox_filter.setMinimumWidth(120)
self.progress_bar.setMaximumHeight(max_height*1.2)
self.progress_bar.setMaximumWidth(max_height*12)
self.progress_bar.setTextVisible(False)
self.progress_bar.setVisible(False)
self.setMinimumSize(QSize(480, 300))
self.setWindowTitle(_("Conda Package Manager"))
self.status_bar.setFixedHeight(max_height*1.5)
self.textbox_search.setMaximumWidth(max_width)
self.textbox_search.setPlaceholderText('Search Packages')
self.table_first_row.setMaximumHeight(0)
self.table_last_row.setMaximumHeight(0)
self.table_last_row.setVisible(False)
self.table_first_row.setVisible(False)
# Layout
top_layout = QHBoxLayout()
top_layout.addWidget(self.combobox_filter)
top_layout.addWidget(self.button_channels)
top_layout.addWidget(self.button_update)
top_layout.addWidget(self.textbox_search)
top_layout.addStretch()
top_layout.addWidget(self.button_options)
middle_layout = QVBoxLayout()
middle_layout.addWidget(self.table_first_row)
middle_layout.addWidget(self.table)
middle_layout.addWidget(self.table_last_row)
bottom_layout = QHBoxLayout()
bottom_layout.addWidget(self.status_bar)
bottom_layout.addStretch()
bottom_layout.addWidget(self.progress_bar)
bottom_layout.addWidget(self.button_cancel)
bottom_layout.addWidget(self.button_apply)
bottom_layout.addWidget(self.button_clear)
layout = QVBoxLayout(self)
layout.addLayout(top_layout)
layout.addLayout(middle_layout)
layout.addLayout(bottom_layout)
layout.addSpacing(6)
self.setLayout(layout)
self.setTabOrder(self.combobox_filter, self.button_channels)
self.setTabOrder(self.button_channels, self.button_update)
self.setTabOrder(self.button_update, self.textbox_search)
self.setTabOrder(self.textbox_search, self.table_first_row)
self.setTabOrder(self.table, self.table_last_row)
self.setTabOrder(self.table_last_row, self.button_apply)
self.setTabOrder(self.button_apply, self.button_clear)
self.setTabOrder(self.button_clear, self.button_cancel)
# Signals and slots
self.api.sig_repodata_updated.connect(self._repodata_updated)
self.combobox_filter.currentIndexChanged.connect(self.filter_package)
self.button_apply.clicked.connect(self.apply_multiple_actions)
self.button_clear.clicked.connect(self.clear_actions)
self.button_cancel.clicked.connect(self.cancel_process)
self.button_channels.clicked.connect(self.show_channels_dialog)
self.button_update.clicked.connect(self.update_package_index)
self.textbox_search.textChanged.connect(self.search_package)
self.table.sig_conda_action_requested.connect(self._run_conda_action)
self.table.sig_actions_updated.connect(self.update_actions)
self.table.sig_pip_action_requested.connect(self._run_pip_action)
self.table.sig_status_updated.connect(self.update_status)
self.table.sig_next_focus.connect(self.table_last_row.handle_tab)
self.table.sig_previous_focus.connect(
lambda: self.table_first_row.widget_before.setFocus())
self.table_first_row.sig_enter_first.connect(self._handle_tab_focus)
self.table_last_row.sig_enter_last.connect(self._handle_backtab_focus)
# Setup
self.api.client_set_domain(conda_api_url)
self.api.set_data_directory(self.data_directory)
self._load_bundled_metadata()
self.update_actions(0)
if setup:
self.set_environment(name=name, prefix=prefix)
self.setup()