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)
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)
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)
class BPMMain(BaseWidget): def __init__(self, parent=None, prefix='', bpm=''): super().__init__(parent=parent, prefix=prefix, bpm=bpm) self.setupui() def setupui(self): self.layoutv = QVBoxLayout(self) lab = QLabel('<h2>' + self.bpm + '</h2>', self, alignment=Qt.AlignCenter) self.layoutv.addWidget(lab) self.layoutv.addSpacing(30) grpbx = CustomGroupBox('BPM General Status', self) hbl = QHBoxLayout(grpbx) hbl.addSpacing(10) hbl.addStretch() chan2vals = { 'asyn.CNCT': 1, 'asyn.ENBL': 1, 'RFFEasyn.CNCT': 1, 'RFFEasyn.ENBL': 1, 'ADCAD9510PllStatus-Mon': 1 } chan2vals = {self.get_pvname(k): v for k, v in chan2vals.items()} led = PyDMLedMultiChannel(self, channels2values=chan2vals) hbl.addWidget(led) hbl.addSpacing(10) hbl.addStretch() pbt = QPushButton('Open Settings') Window = create_window_from_widget(ParamsSettings, title=self.bpm + ': Settings') util.connect_window(pbt, Window, parent=grpbx, prefix=self.prefix, bpm=self.bpm) hbl.addWidget(pbt) hbl.addSpacing(10) hbl.addStretch() self.layoutv.addWidget(grpbx) self.layoutv.addSpacing(20) self.layoutv.addStretch() grpbx = CustomGroupBox('Triggered Acquisitions', self) hbl = QHBoxLayout(grpbx) hbl.addSpacing(10) hbl.addStretch() pbt = QPushButton('MultiBunch/SinglePass') Window = create_window_from_widget( TriggeredAcquisition, title=self.bpm + ': MultiBunch/SinglePass Acquisitions') util.connect_window(pbt, Window, parent=grpbx, prefix=self.prefix, bpm=self.bpm) hbl.addWidget(pbt) hbl.addSpacing(10) hbl.addStretch() pbt = QPushButton('PostMortem') Window = create_window_from_widget(PostMortemAcquisition, title=self.bpm + ': PostMortem Acquisitions') util.connect_window(pbt, Window, parent=grpbx, prefix=self.prefix, bpm=self.bpm) hbl.addWidget(pbt) hbl.addSpacing(10) hbl.addStretch() self.layoutv.addWidget(grpbx) self.layoutv.addSpacing(20) self.layoutv.addStretch() grpbx = self._create_formlayout_groupbox('Monitoring', (('PosX-Mon', 'Position X'), ('PosY-Mon', 'Position Y'), ('PosQ-Mon', 'Position Q'), ('Sum-Mon', 'Sum'))) hbl = QHBoxLayout() hbl.addStretch() pbt = QPushButton('Open Graphics', grpbx) hbl.addWidget(pbt) hbl.addStretch() Window = create_window_from_widget(MonitData, title=self.bpm + ': Monit Data') util.connect_window(pbt, Window, parent=grpbx, prefix=self.prefix, bpm=self.bpm) grpbx.layoutf.addRow(hbl) grpbx.layoutf.setSpacing(10) self.layoutv.addWidget(grpbx) self.layoutv.addSpacing(20) self.layoutv.addStretch() if 'SI' in self.bpm: grpbx = CustomGroupBox('Orbit Interlock', self) hbl = QHBoxLayout(grpbx) pbt = QPushButton('Open Interlock Settings', grpbx) util.connect_window(pbt, BPMOrbIntlkDetailWindow, parent=grpbx, prefix=self.prefix, device=self.bpm) hbl.addStretch() hbl.addWidget(pbt) hbl.addStretch() self.layoutv.addWidget(grpbx) self.layoutv.addSpacing(20) self.layoutv.addStretch()
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)
def create_control_panel(self): # define Qt GUI elements layout = QHBoxLayout() layout_L = QVBoxLayout() layout_L1 = QHBoxLayout() # layout_L1.addSpacing(10) layout_L1.addWidget( QLabel("Electrode: ", alignment=Qt.AlignVCenter | Qt.AlignRight)) # Channel selection self.chan_select = QComboBox() self.chan_select.addItem("None") self.chan_select.setMinimumWidth(70) self.chan_select.setEnabled(False) layout_L1.addWidget(self.chan_select) layout_L1.addSpacing(20) # features selection layout_L1.addWidget( QLabel("Feature set: ", alignment=Qt.AlignVCenter | Qt.AlignRight)) self.feature_select = QComboBox() self.feature_select.setMinimumWidth(60) self.feature_select.addItems(['Raw', 'Mapping']) self.feature_select.setCurrentIndex(0) layout_L1.addWidget(self.feature_select) layout_L.addLayout(layout_L1) layout_L.addSpacing(5) layout_L2 = QHBoxLayout() layout_L2.addSpacing(10) layout_L2.addWidget( QLabel("+/- ", alignment=Qt.AlignVCenter | Qt.AlignRight)) self.range_edit = QLineEdit("{:.2f}".format(uVRANGE)) self.range_edit.setMaximumWidth(50) layout_L2.addWidget(self.range_edit) layout_L2.addSpacing(30) self.do_hp = QCheckBox('HP') self.do_hp.setChecked(True) layout_L2.addWidget(self.do_hp) layout_L2.addSpacing(30) self.sweep_control = QCheckBox("Match SweepGUI.") self.sweep_control.setChecked(True) self.sweep_control.setEnabled(True) layout_L2.addWidget(self.sweep_control) layout_L.addLayout(layout_L2) layout_R = QHBoxLayout() self.bt_refresh = QPushButton("Refresh") self.bt_refresh.setMaximumWidth(50) layout_R.addWidget(self.bt_refresh) layout_R.addSpacing(20) self.btn_settings = QPushButton("Settings") self.btn_settings.setMaximumWidth(50) layout_R.addWidget(self.btn_settings) layout_R.addSpacing(20) self.features_process_btn = QPushButton('Features') self.features_process_btn.setMaximumWidth(50) self.features_process_btn.setStyleSheet("QPushButton { color: white; " "background-color : red; " "border-color : red; " "border-width: 2px}") self.features_process_btn.clicked.connect( self.features_process_btn_callback) layout_R.addWidget(self.features_process_btn) layout_R.addSpacing(5) self.depth_process_btn = QPushButton('Record') self.depth_process_btn.setMaximumWidth(50) self.depth_process_btn.setStyleSheet("QPushButton { color: white; " "background-color : red; " "border-color : red; " "border-width: 2px}") self.depth_process_btn.clicked.connect(self.depth_process_btn_callback) layout_R.addWidget(self.depth_process_btn) layout_R.addSpacing(20) self.status_label = QLabel() self.status_label.setPixmap(self.status_icons[0]) layout_R.addWidget(self.status_label) layout_R.addSpacing(10) layout.addLayout(layout_L) layout.addStretch() layout.addLayout(layout_R) # layout.addSpacing(10) self.layout().addLayout(layout) # callbacks self.btn_settings.clicked.connect(self.call_manage_settings.emit) self.chan_select.currentIndexChanged.connect( self.manage_feat_chan_select) self.feature_select.currentIndexChanged.connect( self.manage_feat_chan_select) self.sweep_control.clicked.connect(self.manage_sweep_control) self.range_edit.editingFinished.connect(self.manage_range_edit) self.bt_refresh.clicked.connect(self.manage_refresh)
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)
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) # Signals self.button_ok.clicked.connect(self.accept_override) self.button_clear.clicked.connect(self.unbind_shortcut) self.button_cancel.clicked.connect(self.reject) self.button_default.clicked.connect(self.set_sequence_to_default) # Set all widget to no focus so that we can register <Tab> key # press event. widgets = ( self.label_warning, self.helper_button, self.text_new_sequence, self.button_clear, self.button_default, self.button_cancel, self.button_ok, self.btn_clear_sequence, self.button_back_sequence) for w in widgets: w.setFocusPolicy(Qt.NoFocus) w.clearFocus()
def __init__(self, parent=None, is_report=False): QDialog.__init__(self, parent) self.is_report = is_report self.setWindowTitle(_("Issue reporter")) self.setModal(True) # To save the traceback sent to the internal console self.error_traceback = "" # Dialog main label if self.is_report: title = _("Please fill the following information") else: title = _("Spyder has encountered an internal problem!") main_label = QLabel( _("<h3>{title}</h3>" "Before reporting this problem, <i>please</i> consult our " "comprehensive " "<b><a href=\"{trouble_url}\">Troubleshooting Guide</a></b> " "which should help solve most issues, and search for " "<b><a href=\"{project_url}\">known bugs</a></b> " "matching your error message or problem description for a " "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() 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)
def display_loaded_standards(self): calib_data = self.gpc.get_quant_calibration_data() calib_settings = self.gpc.get_quant_calibration_settings() # Create the new widget (this deletes the old widget) self.loaded_standards = QWidget() self.loaded_standards.setMinimumWidth(700) # Also delete references to all components self.frames_calib_data = [] self.pbs_view = [] self.pbs_remove = [] # All 'View' buttons are added to the group in order to be connected to the same slot self.group_view = QButtonGroup() self.group_view.setExclusive(False) self.group_view.buttonClicked.connect(self.pb_view_clicked) # The same for the 'Remove' buttons self.group_remove = QButtonGroup() self.group_remove.setExclusive(False) self.group_remove.buttonClicked.connect(self.pb_remove_clicked) vbox = QVBoxLayout() class _LabelBlack(QLabel): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.setStyleSheet("color: black") for cdata, csettings in zip(calib_data, calib_settings): frame = QFrame() frame.setFrameStyle(QFrame.StyledPanel) frame.setStyleSheet( get_background_css((200, 255, 200), widget="QFrame")) _vbox = QVBoxLayout() name = cdata["name"] # Standard name (can be arbitrary string # If name is long, then print it in a separate line _name_is_long = len(name) > 30 pb_view = QPushButton("View ...") self.group_view.addButton(pb_view) pb_remove = QPushButton("Remove") self.group_remove.addButton(pb_remove) # Row 1: serial, name serial = cdata["serial"] _hbox = QHBoxLayout() _hbox.addWidget(_LabelBlack(f"<b>Standard</b> #{serial}")) if not _name_is_long: _hbox.addWidget(_LabelBlack(f"'{name}'")) _hbox.addStretch(1) _hbox.addWidget(pb_view) _hbox.addWidget(pb_remove) _vbox.addLayout(_hbox) # Optional row if _name_is_long: # Wrap name if it is extemely long name = textwrap.fill(name, width=80) _hbox = QHBoxLayout() _hbox.addWidget(_LabelBlack("<b>Name:</b> "), 0, Qt.AlignTop) _hbox.addWidget(_LabelBlack(name), 0, Qt.AlignTop) _hbox.addStretch(1) _vbox.addLayout(_hbox) # Row 2: description description = textwrap.fill(cdata["description"], width=80) _hbox = QHBoxLayout() _hbox.addWidget(_LabelBlack("<b>Description:</b>"), 0, Qt.AlignTop) _hbox.addWidget(_LabelBlack(f"{description}"), 0, Qt.AlignTop) _hbox.addStretch(1) _vbox.addLayout(_hbox) # Row 3: incident_energy = cdata["incident_energy"] scaler = cdata["scaler_name"] detector_channel = cdata["detector_channel"] distance_to_sample = cdata["distance_to_sample"] _hbox = QHBoxLayout() _hbox.addWidget( _LabelBlack(f"<b>Incident energy, keV:</b> {incident_energy}")) _hbox.addWidget(_LabelBlack(f" <b>Scaler:</b> {scaler}")) _hbox.addWidget( _LabelBlack(f" <b>Detector channel:</b> {detector_channel}")) _hbox.addWidget( _LabelBlack( f" <b>Distance-to-sample:</b> {distance_to_sample}")) _hbox.addStretch(1) _vbox.addLayout(_hbox) # Row 4: file name fln = textwrap.fill(csettings["file_path"], width=80) _hbox = QHBoxLayout() _hbox.addWidget(_LabelBlack("<b>Source file:</b>"), 0, Qt.AlignTop) _hbox.addWidget(_LabelBlack(fln), 0, Qt.AlignTop) _hbox.addStretch(1) _vbox.addLayout(_hbox) frame.setLayout(_vbox) # Now the group box is added to the upper level layout vbox.addWidget(frame) vbox.addSpacing(5) self.frames_calib_data.append(frame) self.pbs_view.append(pb_view) self.pbs_remove.append(pb_remove) # Add the layout to the widget self.loaded_standards.setLayout(vbox) # ... and put the widget inside the scroll area. This will update the # contents of the scroll area. self.scroll.setWidget(self.loaded_standards)
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) console_namespace = self.create_checkbox(CONSOLE_NAMESPACE, 'console_namespace', False) general_layout = QVBoxLayout() general_layout.addWidget(clear_variables) general_layout.addWidget(console_namespace) 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)
def __init__(self, parent=None, is_report=False): QDialog.__init__(self, parent) self.is_report = is_report self.setWindowTitle(_("Issue reporter")) self.setModal(True) # To save the traceback sent to the internal console self.error_traceback = "" # Dialog main label if self.is_report: title = _("Please fill the following information") else: title = _("Spyder has encountered an internal problem!") main_label = QLabel( _("<h3>{title}</h3>" "Before reporting this problem, <i>please</i> consult our " "comprehensive " "<b><a href=\"{trouble_url}\">Troubleshooting Guide</a></b> " "which should help solve most issues, and search for " "<b><a href=\"{project_url}\">known bugs</a></b> " "matching your error message or problem description for a " "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)
def __init__(self, parent, project_types): """Project creation dialog.""" super(ProjectDialog, self).__init__(parent=parent) self.plugin = parent self._project_types = project_types self.project_data = {} self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) self.project_name = None self.location = get_home_dir() # Widgets projects_url = "http://docs.spyder-ide.org/current/panes/projects.html" self.description_label = QLabel( _("Select a new or existing directory to create a new Spyder " "project in it. To learn more about projects, take a look at " "our <a href=\"{0}\">documentation</a>.").format(projects_url)) self.description_label.setOpenExternalLinks(True) self.description_label.setWordWrap(True) 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.text_project_name = QLineEdit() self.text_location = QLineEdit(get_home_dir()) self.combo_project_type = QComboBox() self.label_information = QLabel("") self.label_information.hide() self.button_select_location = create_toolbutton( self, triggered=self.select_location, icon=ima.icon('DirOpenIcon'), tip=_("Select directory")) 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.radio_new_dir.setChecked(True) self.text_location.setEnabled(True) self.text_location.setReadOnly(True) self.button_cancel.setDefault(True) self.button_cancel.setAutoDefault(True) self.button_create.setEnabled(False) for (id_, name) in [(pt_id, pt.get_name()) for pt_id, pt in project_types.items()]: self.combo_project_type.addItem(name, id_) self.setWindowTitle(_('Create new project')) # Layouts layout_top = QHBoxLayout() layout_top.addWidget(self.radio_new_dir) layout_top.addSpacing(15) layout_top.addWidget(self.radio_from_dir) layout_top.addSpacing(200) 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_information, 3, 0, 1, 3) layout = QVBoxLayout() layout.addWidget(self.description_label) layout.addSpacing(3) layout.addWidget(self.groupbox) layout.addSpacing(8) layout.addLayout(layout_grid) layout.addSpacing(8) layout.addWidget(self.bbox) layout.setSizeConstraint(layout.SetFixedSize) self.setLayout(layout) # Signals and slots 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)
def __init__(self, parent): """Create About Spyder dialog with general information.""" QDialog.__init__(self, parent) self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) versions = get_versions() # Show Git revision for development version revlink = '' if versions['revision']: rev = versions['revision'] revlink = " (<a href='https://github.com/spyder-ide/spyder/" \ "commit/%s'>Commit: %s</a>)" % (rev, rev) # Get current font properties font = self.font() font_family = font.family() font_size = font.pointSize() if sys.platform == 'darwin': font_size -= 2 self.label = QLabel((""" <div style='font-family: "{font_family}"; font-size: {font_size}pt; font-weight: normal; '> <p> <b>Spyder {spyder_ver}</b> {revision} <br> The Scientific Python Development Environment | <a href="{website_url}">Spyder-IDE.org</a> <br> Copyright © 2009-2020 Spyder Project Contributors and <a href="{github_url}/blob/master/AUTHORS.txt">others</a>. <br> Distributed under the terms of the <a href="{github_url}/blob/master/LICENSE.txt">MIT License</a>. </p> <p> Created by Pierre Raybaut; current maintainer is Carlos Cordoba. Developed by the <a href="{github_url}/graphs/contributors">international Spyder community</a>. Many thanks to all the Spyder beta testers and dedicated users. </p> <p>For help with Spyder errors and crashes, please read our <a href="{trouble_url}">Troubleshooting Guide</a>, and for bug reports and feature requests, visit our <a href="{github_url}">Github site</a>. For project discussion, see our <a href="{forum_url}">Google Group</a>. </p> <p> This project is part of a larger effort to promote and facilitate the use of Python for scientific and engineering software development. The popular Python distributions <a href="https://www.anaconda.com/download/">Anaconda</a> and <a href="https://winpython.github.io/">WinPython</a> also contribute to this plan. </p> <p> Python {python_ver} {bitness}-bit | Qt {qt_ver} | {qt_api} {qt_api_ver} | {os_name} {os_ver} </p> <p><small>Certain source files under other compatible permissive licenses and/or originally by other authors. Spyder 3 theme icons derived from <a href="https://fontawesome.com/">Font Awesome</a> 4.7 (© 2016 David Gandy; SIL OFL 1.1) and <a href="http://materialdesignicons.com/">Material Design</a> (© 2014 Austin Andrews; SIL OFL 1.1). Most Spyder 2 theme icons sourced from the <a href="https://www.everaldo.com">Crystal Project iconset</a> (© 2006-2007 Everaldo Coelho; LGPL 2.1+). Other icons from <a href="http://p.yusukekamiyamane.com/">Yusuke Kamiyamane</a> (© 2013 Yusuke Kamiyamane; CC-BY 3.0), the <a href="http://www.famfamfam.com/lab/icons/silk/">FamFamFam Silk icon set</a> 1.3 (© 2006 Mark James; CC-BY 2.5), and the <a href="https://www.kde.org/">KDE Oxygen icons</a> (© 2007 KDE Artists; LGPL 3.0+).</small> </p> <p> See the <a href="{github_url}/blob/master/NOTICE.txt">NOTICE</a> file for full legal information. </p> </div> """).format( spyder_ver=versions['spyder'], revision=revlink, website_url=__website_url__, github_url=__project_url__, trouble_url=__trouble_url__, forum_url=__forum_url__, python_ver=versions['python'], bitness=versions['bitness'], qt_ver=versions['qt'], qt_api=versions['qt_api'], qt_api_ver=versions['qt_api_ver'], os_name=versions['system'], os_ver=versions['release'], font_family=font_family, font_size=font_size, )) self.label.setWordWrap(True) self.label.setAlignment(Qt.AlignTop) self.label.setOpenExternalLinks(True) self.label.setTextInteractionFlags(Qt.TextBrowserInteraction) self.label.setFixedWidth(350) if is_dark_interface(): icon_filename = "spyder.svg" else: icon_filename = "spyder_dark.svg" pixmap = QPixmap(get_image_path(icon_filename)) self.label_pic = QLabel(self) self.label_pic.setPixmap( pixmap.scaledToWidth(64, Qt.SmoothTransformation)) self.label_pic.setAlignment(Qt.AlignTop) btn = QPushButton(_("Copy to clipboard"), ) bbox = QDialogButtonBox(QDialogButtonBox.Ok) # Widget setup self.setWindowIcon(ima.icon('MessageBoxInformation')) self.setModal(False) # Layout tophlayout = QHBoxLayout() tophlayout.addWidget(self.label_pic) tophlayout.addWidget(self.label) btmhlayout = QHBoxLayout() btmhlayout.addWidget(btn) btmhlayout.addStretch() btmhlayout.addWidget(bbox) vlayout = QVBoxLayout(self) vlayout.addLayout(tophlayout) vlayout.addSpacing(25) vlayout.addLayout(btmhlayout) vlayout.setSizeConstraint(vlayout.SetFixedSize) # Signals btn.clicked.connect(self.copy_to_clipboard) bbox.accepted.connect(self.accept)
def _setupUi(self): label = QLabel('<h2>'+self.section+' Tune<h2>', self, alignment=Qt.AlignHCenter) label.setObjectName('label') label.setStyleSheet('#label{min-height: 1.29em; max-height: 1.29em;}') if self.section == 'SI': # Tune self.wid_tune_mon = SITuneMonitor(self, self.prefix) # Settings self.tabCtrl = QTabWidget(self) hcolor = QColor(179, 229, 255) vcolor = QColor(255, 179, 179) self.ctrlH = TuneControls(parent=self, prefix=self.prefix, section=self.section, orientation='H', background=hcolor) self.tabCtrl.addTab(self.ctrlH, 'Horizontal') self.ctrlV = TuneControls(parent=self, prefix=self.prefix, section=self.section, orientation='V', background=vcolor) self.tabCtrl.addTab(self.ctrlV, 'Vertical') self.tabCtrl.setStyleSheet(""" QTabWidget::pane { border-left: 2px solid gray; border-bottom: 2px solid gray; border-right: 2px solid gray; } QTabBar::tab:first { background-color: #B3E5FF; } QTabBar::tab:last { background-color: #FFB3B3; } """) self.settings = QWidget() vbox_sett = QVBoxLayout(self.settings) vbox_sett.addWidget(self.tabCtrl) # Spectra view self.spectra_view = TuneSpectraControls( self, self.prefix, self.section) self.spectra_view.setObjectName('spectra_view') if self.section == 'BO': self.trig_gbox = QGroupBox('Trigger', self) self.trig_gbox.setLayout(QHBoxLayout()) self.trig_gbox.layout().addWidget(HLTriggerSimple( self.trig_gbox, device='BO-Glob:TI-TuneProc', prefix=self.prefix, duration=True, nrpulses=True)) vbox_sett.addWidget(self.trig_gbox) # Sepctrograms self.specH = BOTuneSpectrogramControls( parent=self, prefix=self.prefix, orientation='H', title='<h3>Horizontal</h3>', background=hcolor) self.specH.setObjectName('specH') self.specV = BOTuneSpectrogramControls( parent=self, prefix=self.prefix, orientation='V', title='<h3>Vertical</h3>', background=vcolor) self.specV.setObjectName('specV') vbox_meas = QVBoxLayout() vbox_meas.addWidget(self.specH) vbox_meas.addSpacing(10) vbox_meas.addWidget(self.specV) # Connect signals self.specH.spectrogram.idx2send_changed.connect( self.specV.update_idx2plot) self.specH.sb_idx2plot.editingFinished.connect( self.specV.update_idx2plot) self.specH.pb_resetbuff.clicked.connect( self.specV.spectrogram.resetBuffer) self.specH.sb_buffsz.editingFinished.connect( self.specV.update_buffsize) self.specV.spectrogram.idx2send_changed.connect( self.specH.update_idx2plot) self.specV.sb_idx2plot.editingFinished.connect( self.specH.update_idx2plot) self.specV.pb_resetbuff.clicked.connect( self.specH.spectrogram.resetBuffer) self.specV.sb_buffsz.editingFinished.connect( self.specH.update_buffsize) self.specH.spectrogram.new_data.connect( self.spectra_view.spectra.receiveDataH) self.specV.spectrogram.new_data.connect( self.spectra_view.spectra.receiveDataV) self.pb_showsett = QPushButton('>', self) self.pb_showsett.setObjectName('showsett') self.pb_showsett.setToolTip('Hide settings') self.pb_showsett.setStyleSheet( '#showsett{min-width:0.7em;max-width:0.7em;}') self.pb_showsett.released.connect(self._handle_settings_vis) hbox_vis = QHBoxLayout() hbox_vis.addWidget(self.pb_showsett, alignment=Qt.AlignLeft) self.setStyleSheet( "#specH, #specV {min-width:40em; min-height: 18em;}" "#spectra_view {min-width:40em; min-height: 36em;}" "#wid_tuneh, #wid_tunev {border:2px solid gray;}") cw = QWidget(self) self.setCentralWidget(cw) lay = QVBoxLayout(cw) if self.section == 'BO': hbox = QHBoxLayout() hbox.addWidget(self.settings) hbox.addLayout(vbox_meas) hbox.addWidget(self.spectra_view) hbox.setStretch(0, 1) hbox.setStretch(1, 1) hbox.setStretch(2, 1) lay.addWidget(label) lay.addLayout(hbox) lay.addLayout(hbox_vis) else: hbox = QHBoxLayout() hbox.addWidget(self.settings) hbox.addWidget(self.spectra_view) hbox.setStretch(0, 1) hbox.setStretch(1, 1) lay.addWidget(label) lay.addWidget(self.wid_tune_mon) lay.addLayout(hbox) lay.addLayout(hbox_vis)
def __init__(self): super().__init__() self.setWindowTitle("About PyXRF") self.setFixedSize(500, 500) text_name = "PyXRF" text_description = "X-Ray Fluorescence Analysis Tool" text_ver = f"Version: {pyxrf.__version__}" text_latest_ver = "Latest stable version:" text_credit = "Credits:" text_credit_org = ( "Data Acquisition, Management and Analysis Group\n" "National Synchrontron Light Source II\n" "Brookhaven National Laboratory" ) text_copyright = f"\u00A92015\u2014{datetime.now().year} Brookhaven National Laboratory" label_name = QLabel(text_name) label_name.setStyleSheet("QLabel {font-weight: bold; font-size: 32px}") label_description = QLabel(text_description) label_description.setStyleSheet("QLabel {font-style: italic; font-size: 18px}") label_ver = QLabel(text_ver) label_latest_ver = QLabel(text_latest_ver) label_credit = QLabel(text_credit) label_org = QLabel(text_credit_org) label_copyright = QLabel(text_copyright) button_box = QDialogButtonBox(QDialogButtonBox.Close) button_box.accepted.connect(self.accept) button_box.rejected.connect(self.reject) vbox = QVBoxLayout() vbox.addStretch(1) hbox = QHBoxLayout() hbox.addStretch(1) hbox.addWidget(label_name) hbox.addStretch(1) vbox.addLayout(hbox) hbox = QHBoxLayout() hbox.addStretch(1) hbox.addWidget(label_description) hbox.addStretch(1) vbox.addLayout(hbox) vbox.addStretch(1) hbox = QHBoxLayout() hbox.addSpacing(30) hbox.addWidget(label_ver) hbox.addStretch(1) vbox.addLayout(hbox) hbox = QHBoxLayout() hbox.addSpacing(30) hbox.addWidget(label_latest_ver) hbox.addStretch(1) vbox.addLayout(hbox) vbox.addStretch(1) hbox = QHBoxLayout() hbox.addSpacing(30) hbox.addWidget(label_credit, 0, Qt.AlignTop) hbox.addWidget(label_org, 0, Qt.AlignTop) hbox.addStretch(1) vbox.addLayout(hbox) vbox.addSpacing(20) hbox = QHBoxLayout() hbox.addSpacing(30) hbox.addWidget(label_copyright) hbox.addStretch(1) vbox.addLayout(hbox) vbox.addSpacing(20) vbox.addWidget(button_box) self.setLayout(vbox)
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)
def __init__(self, parent, tour_function): super().__init__(parent) if MAC: flags = (self.windowFlags() | Qt.WindowStaysOnTopHint & ~Qt.WindowContextHelpButtonHint) else: flags = self.windowFlags() & ~Qt.WindowContextHelpButtonHint self.setWindowFlags(flags) self.tour_function = tour_function # Image images_layout = QHBoxLayout() icon_filename = 'tour-spyder-logo' image_path = get_image_path(icon_filename) image = QPixmap(image_path) image_label = QLabel() image_height = image.height() * self.ICON_SCALE_FACTOR image_width = image.width() * self.ICON_SCALE_FACTOR image = image.scaled(image_width, image_height, Qt.KeepAspectRatio, Qt.SmoothTransformation) image_label.setPixmap(image) images_layout.addStretch() images_layout.addWidget(image_label) images_layout.addStretch() if MAC: images_layout.setContentsMargins(0, -5, 20, 0) else: images_layout.setContentsMargins(0, -8, 35, 0) # Label tour_label_title = QLabel(_("Welcome to Spyder!")) tour_label_title.setStyleSheet(f"font-size: {self.TITLE_FONT_SIZE}") tour_label_title.setWordWrap(True) tour_label = QLabel( _("Check out our interactive tour to " "explore some of Spyder's panes and features.")) tour_label.setStyleSheet(f"font-size: {self.CONTENT_FONT_SIZE}") tour_label.setWordWrap(True) tour_label.setFixedWidth(340) # Buttons buttons_layout = QHBoxLayout() dialog_tour_color = QStylePalette.COLOR_BACKGROUND_2 start_tour_color = QStylePalette.COLOR_ACCENT_2 start_tour_hover = QStylePalette.COLOR_ACCENT_3 start_tour_pressed = QStylePalette.COLOR_ACCENT_4 dismiss_tour_color = QStylePalette.COLOR_BACKGROUND_4 dismiss_tour_hover = QStylePalette.COLOR_BACKGROUND_5 dismiss_tour_pressed = QStylePalette.COLOR_BACKGROUND_6 font_color = QStylePalette.COLOR_TEXT_1 self.launch_tour_button = QPushButton(_('Start tour')) self.launch_tour_button.setStyleSheet( ("QPushButton {{ " "background-color: {background_color};" "border-color: {border_color};" "font-size: {font_size};" "color: {font_color};" "padding: {padding}}}" "QPushButton:hover:!pressed {{ " "background-color: {color_hover}}}" "QPushButton:pressed {{ " "background-color: {color_pressed}}}").format( background_color=start_tour_color, border_color=start_tour_color, font_size=self.BUTTONS_FONT_SIZE, font_color=font_color, padding=self.BUTTONS_PADDING, color_hover=start_tour_hover, color_pressed=start_tour_pressed)) self.launch_tour_button.setAutoDefault(False) self.dismiss_button = QPushButton(_('Dismiss')) self.dismiss_button.setStyleSheet( ("QPushButton {{ " "background-color: {background_color};" "border-color: {border_color};" "font-size: {font_size};" "color: {font_color};" "padding: {padding}}}" "QPushButton:hover:!pressed {{ " "background-color: {color_hover}}}" "QPushButton:pressed {{ " "background-color: {color_pressed}}}").format( background_color=dismiss_tour_color, border_color=dismiss_tour_color, font_size=self.BUTTONS_FONT_SIZE, font_color=font_color, padding=self.BUTTONS_PADDING, color_hover=dismiss_tour_hover, color_pressed=dismiss_tour_pressed)) self.dismiss_button.setAutoDefault(False) buttons_layout.addStretch() buttons_layout.addWidget(self.launch_tour_button) if not MAC: buttons_layout.addSpacing(10) buttons_layout.addWidget(self.dismiss_button) layout = QHBoxLayout() layout.addLayout(images_layout) label_layout = QVBoxLayout() label_layout.addWidget(tour_label_title) if not MAC: label_layout.addSpacing(3) label_layout.addWidget(tour_label) else: label_layout.addWidget(tour_label) label_layout.addSpacing(10) vertical_layout = QVBoxLayout() if not MAC: vertical_layout.addStretch() vertical_layout.addLayout(label_layout) vertical_layout.addSpacing(20) vertical_layout.addLayout(buttons_layout) vertical_layout.addStretch() else: vertical_layout.addLayout(label_layout) vertical_layout.addLayout(buttons_layout) general_layout = QHBoxLayout() if not MAC: general_layout.addStretch() general_layout.addLayout(layout) general_layout.addSpacing(1) general_layout.addLayout(vertical_layout) general_layout.addStretch() else: general_layout.addLayout(layout) general_layout.addLayout(vertical_layout) self.setLayout(general_layout) self.launch_tour_button.clicked.connect(self._start_tour) self.dismiss_button.clicked.connect(self.close) self.setStyleSheet(f"background-color:{dialog_tour_color}") self.setContentsMargins(18, 40, 18, 40) if not MAC: self.setFixedSize(640, 280)
def __init__(self, config_file): QWidget.__init__(self) self._config_file = config_file self._ee_config = None if FeatureToggling.is_enabled("prefect") or FeatureToggling.is_enabled( "ensemble-evaluator"): self._ee_config = EvaluatorServerConfig() self.setObjectName("Simulation_panel") layout = QVBoxLayout() self._simulation_mode_combo = QComboBox() self._simulation_mode_combo.setObjectName("Simulation_mode") addHelpToWidget(self._simulation_mode_combo, "run/simulation_mode") self._simulation_mode_combo.currentIndexChanged.connect( self.toggleSimulationMode) simulation_mode_layout = QHBoxLayout() simulation_mode_layout.addSpacing(10) simulation_mode_layout.addWidget(QLabel("Simulation mode:"), 0, Qt.AlignVCenter) simulation_mode_layout.addWidget(self._simulation_mode_combo, 0, Qt.AlignVCenter) simulation_mode_layout.addSpacing(20) self.run_button = QToolButton() self.run_button.setObjectName('start_simulation') self.run_button.setIconSize(QSize(32, 32)) self.run_button.setText("Start Simulation") self.run_button.setIcon(resourceIcon("ide/gear_in_play")) self.run_button.clicked.connect(self.runSimulation) self.run_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) addHelpToWidget(self.run_button, "run/start_simulation") simulation_mode_layout.addWidget(self.run_button) simulation_mode_layout.addStretch(1) layout.addSpacing(5) layout.addLayout(simulation_mode_layout) layout.addSpacing(10) self._simulation_stack = QStackedWidget() self._simulation_stack.setLineWidth(1) self._simulation_stack.setFrameStyle(QFrame.StyledPanel) layout.addWidget(self._simulation_stack) self._simulation_widgets = OrderedDict() """ :type: OrderedDict[BaseRunModel,SimulationConfigPanel]""" if not FeatureToggling.is_enabled("prefect"): self.addSimulationConfigPanel(SingleTestRunPanel()) self.addSimulationConfigPanel(EnsembleExperimentPanel()) if FeatureToggling.is_enabled("prefect"): prefect_config = os.path.basename(config_file) self.addSimulationConfigPanel( PrefectEnsembleExperimentPanel(prefect_config)) if ERT.ert.have_observations( ) and not FeatureToggling.is_enabled("prefect"): self.addSimulationConfigPanel(EnsembleSmootherPanel()) self.addSimulationConfigPanel(MultipleDataAssimilationPanel()) self.addSimulationConfigPanel(IteratedEnsembleSmootherPanel()) self.setLayout(layout)
def __init__(self, parent): super(KiteIntegrationInfo, self).__init__(parent) # Images images_layout = QHBoxLayout() icon_filename = 'kite_completions' image_path = get_image_path(icon_filename) image = QPixmap(image_path) image_label = QLabel() screen = QApplication.primaryScreen() image_label = QLabel() image_height = int(image.height() * self.ICON_SCALE_FACTOR) image_width = int(image.width() * self.ICON_SCALE_FACTOR) image = image.scaled(image_width, image_height, Qt.KeepAspectRatio, Qt.SmoothTransformation) image_label.setPixmap(image) images_layout.addStretch() images_layout.addWidget(image_label) images_layout.addStretch() ilayout = QHBoxLayout() ilayout.addLayout(images_layout) # Label integration_label_title = QLabel( "Get better code completions in Spyder") integration_label_title.setStyleSheet( f"font-size: {self.TITLE_FONT_SIZE}") integration_label_title.setWordWrap(True) integration_label = QLabel( _("Now Spyder can use Kite to provide better code " "completions for key packages in the scientific Python " "Ecosystem. Install Kite for a better editor experience in " "Spyder. <br><br>Kite is free to use but is not open " "source. <a href=\"{kite_url}\">Learn more about Kite </a>") .format(kite_url=KITE_SPYDER_URL)) integration_label.setStyleSheet(f"font-size: {self.CONTENT_FONT_SIZE}") integration_label.setOpenExternalLinks(True) integration_label.setWordWrap(True) integration_label.setFixedWidth(360) label_layout = QVBoxLayout() label_layout.addWidget(integration_label_title) label_layout.addWidget(integration_label) # Buttons buttons_layout = QHBoxLayout() install_button = QPushButton(_('Install Kite')) install_button.setAutoDefault(False) install_button.setStyleSheet( "background-color: #3775A9;" f"font-size: {self.BUTTONS_FONT_SIZE};" f"padding: {self.BUTTONS_PADDING}" ) dismiss_button = QPushButton(_('Dismiss')) dismiss_button.setAutoDefault(False) dismiss_button.setStyleSheet( "background-color: #60798B;" f"font-size: {self.BUTTONS_FONT_SIZE};" f"padding: {self.BUTTONS_PADDING}" ) buttons_layout.addStretch() buttons_layout.addWidget(install_button) if not MAC: buttons_layout.addSpacing(10) buttons_layout.addWidget(dismiss_button) # Buttons with label vertical_layout = QVBoxLayout() if not MAC: vertical_layout.addStretch() vertical_layout.addLayout(label_layout) vertical_layout.addSpacing(20) vertical_layout.addLayout(buttons_layout) vertical_layout.addStretch() else: vertical_layout.addLayout(label_layout) vertical_layout.addLayout(buttons_layout) general_layout = QHBoxLayout() general_layout.addStretch() general_layout.addLayout(ilayout) general_layout.addSpacing(15) general_layout.addLayout(vertical_layout) general_layout.addStretch() self.setLayout(general_layout) # Signals install_button.clicked.connect(self.sig_install_button_clicked) dismiss_button.clicked.connect(self.sig_dismiss_button_clicked) if is_dark_interface(): self.setStyleSheet("background-color: #262E38") self.setContentsMargins(18, 40, 18, 40) if not MAC: self.setFixedSize(800, 350)
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) startup_group = QGroupBox(_("Startup")) startup_bg = QButtonGroup(startup_group) startup_label = QLabel( _("At startup, the current working " "directory is:")) startup_label.setWordWrap(True) lastdir_radio = self.create_radiobutton( _("The current project directory " "or user home directory " "(if no project is active)"), 'startup/use_project_or_home_directory', True, _("At startup,"), # TODO button_group=startup_bg) thisdir_radio = self.create_radiobutton( _("The following directory:"), 'startup/use_fixed_directory', False, _("At startup, the current working " "directory will be the specified path"), button_group=startup_bg) thisdir_bd = self.create_browsedir("", 'startup/fixed_directory', getcwd_or_home()) 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) startup_layout = QVBoxLayout() startup_layout.addWidget(startup_label) startup_layout.addWidget(lastdir_radio) startup_layout.addLayout(thisdir_layout) startup_group.setLayout(startup_layout) # Console Directory 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_or_home()) 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(startup_group) vlayout.addWidget(console_group) vlayout.addStretch(1) self.setLayout(vlayout)
def setup_page(self): newcb = self.create_checkbox # --- Completion --- # Completion group self.completion_box = newcb(_("Enable code completion"), 'code_completion') self.completion_hint_box = newcb(_("Show completion details"), 'completions_hint', section='editor') self.completions_hint_after_ms = self.create_spinbox( _("Show completion detail after keyboard idle (ms):"), None, 'completions_hint_after_ms', min_=0, max_=5000, step=10, tip=_("Default is 500"), section='editor') self.automatic_completion_box = newcb(_("Show completions on the fly"), 'automatic_completions', section='editor') self.completions_after_characters = self.create_spinbox( _("Show automatic completions after characters entered:"), None, 'automatic_completions_after_chars', min_=1, step=1, tip=_("Default is 3"), section='editor') self.completions_after_ms = self.create_spinbox( _("Show automatic completions after keyboard idle (ms):"), None, 'automatic_completions_after_ms', min_=0, max_=5000, step=10, tip=_("Default is 300"), section='editor') code_snippets_box = newcb(_("Enable code snippets"), 'code_snippets') completion_layout = QGridLayout() completion_layout.addWidget(self.completion_box, 0, 0) completion_layout.addWidget(self.completion_hint_box, 1, 0) completion_layout.addWidget(self.completions_hint_after_ms.plabel, 2, 0) completion_layout.addWidget(self.completions_hint_after_ms.spinbox, 2, 1) completion_layout.addWidget(self.automatic_completion_box, 3, 0) completion_layout.addWidget(self.completions_after_characters.plabel, 4, 0) completion_layout.addWidget(self.completions_after_characters.spinbox, 4, 1) completion_layout.addWidget(self.completions_after_ms.plabel, 5, 0) completion_layout.addWidget(self.completions_after_ms.spinbox, 5, 1) completion_layout.addWidget(code_snippets_box, 6, 0) completion_layout.setColumnStretch(2, 6) completion_widget = QWidget() completion_widget.setLayout(completion_layout) self.completion_box.toggled.connect(self.check_completion_options) self.automatic_completion_box.toggled.connect( self.check_completion_options) # --- Introspection --- # Introspection group introspection_group = QGroupBox(_("Basic features")) goto_definition_box = newcb( _("Enable Go to definition"), 'jedi_definition', tip=_("If enabled, left-clicking on an object name while \n" "pressing the {} key will go to that object's definition\n" "(if resolved).").format(self.CTRL)) follow_imports_box = newcb( _("Follow imports when going to a " "definition"), 'jedi_definition/follow_imports') show_signature_box = newcb(_("Show calltips"), 'jedi_signature_help') enable_hover_hints_box = newcb( _("Enable hover hints"), 'enable_hover_hints', tip=_("If enabled, hovering the mouse pointer over an object\n" "name will display that object's signature and/or\n" "docstring (if present).")) introspection_layout = QVBoxLayout() introspection_layout.addWidget(goto_definition_box) introspection_layout.addWidget(follow_imports_box) introspection_layout.addWidget(show_signature_box) introspection_layout.addWidget(enable_hover_hints_box) introspection_group.setLayout(introspection_layout) goto_definition_box.toggled.connect(follow_imports_box.setEnabled) # Advanced group advanced_group = QGroupBox(_("Advanced")) modules_textedit = self.create_textedit( _("Preload the following modules to make completion faster " "and more accurate:"), 'preload_modules') if is_dark_interface(): modules_textedit.textbox.setStyleSheet( "border: 1px solid #32414B;") advanced_layout = QVBoxLayout() advanced_layout.addWidget(modules_textedit) advanced_group.setLayout(advanced_layout) # --- Linting --- # Linting options linting_label = QLabel( _("Spyder can optionally highlight syntax " "errors and possible problems with your " "code in the editor.")) linting_label.setOpenExternalLinks(True) linting_label.setWordWrap(True) linting_check = self.create_checkbox(_("Enable basic linting"), 'pyflakes') underline_errors_box = newcb(_("Underline errors and warnings"), 'underline_errors', section='editor') linting_complexity_box = self.create_checkbox( _("Enable complexity linting with the Mccabe package"), 'mccabe') # Linting layout linting_layout = QVBoxLayout() linting_layout.addWidget(linting_label) linting_layout.addWidget(linting_check) linting_layout.addWidget(underline_errors_box) linting_layout.addWidget(linting_complexity_box) linting_widget = QWidget() linting_widget.setLayout(linting_layout) linting_check.toggled.connect(underline_errors_box.setEnabled) # --- Code style tab --- # Code style label pep_url = ( '<a href="https://www.python.org/dev/peps/pep-0008">PEP 8</a>') code_style_codes_url = _( "<a href='http://pycodestyle.pycqa.org/en/stable" "/intro.html#error-codes'>pycodestyle error codes</a>") code_style_label = QLabel( _("Spyder can use pycodestyle to analyze your code for " "conformance to the {} convention. You can also " "manually show or hide specific warnings by their " "{}.").format(pep_url, code_style_codes_url)) code_style_label.setOpenExternalLinks(True) code_style_label.setWordWrap(True) # Code style checkbox self.code_style_check = self.create_checkbox( _("Enable code style linting"), 'pycodestyle') # Code style options self.code_style_filenames_match = self.create_lineedit( _("Only check filenames matching these patterns:"), 'pycodestyle/filename', alignment=Qt.Horizontal, word_wrap=False, placeholder=_("Check Python files: *.py")) self.code_style_exclude = self.create_lineedit( _("Exclude files or directories matching these patterns:"), 'pycodestyle/exclude', alignment=Qt.Horizontal, word_wrap=False, placeholder=_("Exclude all test files: (?!test_).*\\.py")) code_style_select = self.create_lineedit( _("Show the following errors or warnings:").format( code_style_codes_url), 'pycodestyle/select', alignment=Qt.Horizontal, word_wrap=False, placeholder=_("Example codes: E113, W391")) code_style_ignore = self.create_lineedit( _("Ignore the following errors or warnings:"), 'pycodestyle/ignore', alignment=Qt.Horizontal, word_wrap=False, placeholder=_("Example codes: E201, E303")) code_style_max_line_length = self.create_spinbox( _("Maximum allowed line length:"), None, 'pycodestyle/max_line_length', min_=10, max_=500, step=1, tip=_("Default is 79")) # Code style layout code_style_g_layout = QGridLayout() code_style_g_layout.addWidget(self.code_style_filenames_match.label, 1, 0) code_style_g_layout.addWidget(self.code_style_filenames_match.textbox, 1, 1) code_style_g_layout.addWidget(self.code_style_exclude.label, 2, 0) code_style_g_layout.addWidget(self.code_style_exclude.textbox, 2, 1) code_style_g_layout.addWidget(code_style_select.label, 3, 0) code_style_g_layout.addWidget(code_style_select.textbox, 3, 1) code_style_g_layout.addWidget(code_style_ignore.label, 4, 0) code_style_g_layout.addWidget(code_style_ignore.textbox, 4, 1) code_style_g_layout.addWidget(code_style_max_line_length.plabel, 5, 0) code_style_g_layout.addWidget(code_style_max_line_length.spinbox, 5, 1) # Set Code style options enabled/disabled code_style_g_widget = QWidget() code_style_g_widget.setLayout(code_style_g_layout) code_style_g_widget.setEnabled(self.get_option('pycodestyle')) self.code_style_check.toggled.connect(code_style_g_widget.setEnabled) # Code style layout code_style_layout = QVBoxLayout() code_style_layout.addWidget(code_style_label) code_style_layout.addWidget(self.code_style_check) code_style_layout.addWidget(code_style_g_widget) code_style_widget = QWidget() code_style_widget.setLayout(code_style_layout) # --- Code formatting tab --- # Code formatting label autopep8_url = ( "<a href='https://github.com/hhatto/autopep8'>Autopep8</a>") yapf_url = ("<a href='https://github.com/google/yapf'>Yapf</a>") black_url = ( "<a href='https://black.readthedocs.io/en/stable'>Black</a>") code_fmt_label = QLabel( _("Spyder can use {0}, {1} or {2} to format your code for " "conformance to the {3} convention.").format( autopep8_url, yapf_url, black_url, pep_url)) code_fmt_label.setOpenExternalLinks(True) code_fmt_label.setWordWrap(True) # Code formatting providers code_fmt_provider = self.create_combobox( _("Choose the code formatting provider: "), (("autopep8", 'autopep8'), ("yapf", 'yapf'), ("black", 'black')), 'formatting') # Autoformat on save format_on_save_box = newcb( _("Autoformat files on save"), 'format_on_save', tip=_("If enabled, autoformatting will take place when " "saving a file")) # Code formatting layout code_fmt_layout = QVBoxLayout() code_fmt_layout.addWidget(code_fmt_label) code_fmt_layout.addWidget(code_fmt_provider) code_fmt_layout.addWidget(format_on_save_box) code_fmt_widget = QWidget() code_fmt_widget.setLayout(code_fmt_layout) # --- Docstring tab --- # Docstring style label numpy_url = ("<a href='https://numpydoc.readthedocs.io/en/" "latest/format.html'>Numpy</a>") pep257_url = ( "<a href='https://www.python.org/dev/peps/pep-0257/'>PEP 257</a>") docstring_style_codes = _( "<a href='http://www.pydocstyle.org/en/stable" "/error_codes.html'>page</a>") docstring_style_label = QLabel( _("Here you can decide if you want to perform style analysis on " "your docstrings according to the {} or {} conventions. You can " "also decide if you want to show or ignore specific errors, " "according to the codes found on this {}.").format( numpy_url, pep257_url, docstring_style_codes)) docstring_style_label.setOpenExternalLinks(True) docstring_style_label.setWordWrap(True) # Docstring style checkbox self.docstring_style_check = self.create_checkbox( _("Enable docstring style linting"), 'pydocstyle') # Docstring style options docstring_style_convention = self.create_combobox( _("Choose the convention used to lint docstrings: "), (("Numpy", 'numpy'), ("PEP 257", 'pep257'), ("Custom", 'custom')), 'pydocstyle/convention') self.docstring_style_select = self.create_lineedit( _("Show the following errors:"), 'pydocstyle/select', alignment=Qt.Horizontal, word_wrap=False, placeholder=_("Example codes: D413, D414")) self.docstring_style_ignore = self.create_lineedit( _("Ignore the following errors:"), 'pydocstyle/ignore', alignment=Qt.Horizontal, word_wrap=False, placeholder=_("Example codes: D107, D402")) self.docstring_style_match = self.create_lineedit( _("Only check filenames matching these patterns:"), 'pydocstyle/match', alignment=Qt.Horizontal, word_wrap=False, placeholder=_("Skip test files: (?!test_).*\\.py")) self.docstring_style_match_dir = self.create_lineedit( _("Only check in directories matching these patterns:"), 'pydocstyle/match_dir', alignment=Qt.Horizontal, word_wrap=False, placeholder=_("Skip dot directories: [^\\.].*")) # Custom option handling docstring_style_convention.combobox.currentTextChanged.connect( self.setup_docstring_style_convention) current_convention = docstring_style_convention.combobox.currentText() self.setup_docstring_style_convention(current_convention) # Docstring style layout docstring_style_g_layout = QGridLayout() docstring_style_g_layout.addWidget(docstring_style_convention.label, 1, 0) docstring_style_g_layout.addWidget(docstring_style_convention.combobox, 1, 1) docstring_style_g_layout.addWidget(self.docstring_style_select.label, 2, 0) docstring_style_g_layout.addWidget(self.docstring_style_select.textbox, 2, 1) docstring_style_g_layout.addWidget(self.docstring_style_ignore.label, 3, 0) docstring_style_g_layout.addWidget(self.docstring_style_ignore.textbox, 3, 1) docstring_style_g_layout.addWidget(self.docstring_style_match.label, 4, 0) docstring_style_g_layout.addWidget(self.docstring_style_match.textbox, 4, 1) docstring_style_g_layout.addWidget( self.docstring_style_match_dir.label, 5, 0) docstring_style_g_layout.addWidget( self.docstring_style_match_dir.textbox, 5, 1) # Set Docstring style options enabled/disabled docstring_style_g_widget = QWidget() docstring_style_g_widget.setLayout(docstring_style_g_layout) docstring_style_g_widget.setEnabled(self.get_option('pydocstyle')) self.docstring_style_check.toggled.connect( docstring_style_g_widget.setEnabled) # Docstring style layout docstring_style_layout = QVBoxLayout() docstring_style_layout.addWidget(docstring_style_label) docstring_style_layout.addWidget(self.docstring_style_check) docstring_style_layout.addWidget(docstring_style_g_widget) docstring_style_widget = QWidget() docstring_style_widget.setLayout(docstring_style_layout) # --- Snippets tab --- self.snippets_language = 'python' grammar_url = ( "<a href=\"{0}/specifications/specification-current#snippet_syntax\">" "{1}</a>".format(LSP_URL, _('the LSP grammar'))) snippets_info_label = QLabel( _("Spyder allows to define custom completion snippets to use " "in addition to the ones offered by the Language Server " "Protocol (LSP). Each snippet should follow {}.<br><br> " "<b>Note:</b> All changes will be effective only when applying " "the settings").format(grammar_url)) snippets_info_label.setOpenExternalLinks(True) snippets_info_label.setWordWrap(True) snippets_info_label.setAlignment(Qt.AlignJustify) self.snippets_language_cb = QComboBox(self) self.snippets_language_cb.setToolTip( _('Programming language provided by the LSP server')) self.snippets_language_cb.addItems(LSP_LANGUAGES_PY) self.snippets_language_cb.setCurrentIndex(PYTHON_POS) self.snippets_language_cb.currentTextChanged.connect( self.change_language_snippets) snippet_lang_group = QGroupBox(_('Language')) snippet_lang_layout = QVBoxLayout() snippet_lang_layout.addWidget(self.snippets_language_cb) snippet_lang_group.setLayout(snippet_lang_layout) self.snippets_proxy = SnippetModelsProxy() self.snippets_table = SnippetTable(self, self.snippets_proxy, language=self.snippets_language) self.snippets_table.setMaximumHeight(180) snippet_table_group = QGroupBox(_('Available snippets')) snippet_table_layout = QVBoxLayout() snippet_table_layout.addWidget(self.snippets_table) snippet_table_group.setLayout(snippet_table_layout) # Buttons self.reset_snippets_btn = QPushButton(_("Reset to default values")) self.new_snippet_btn = QPushButton(_("Create a new snippet")) self.delete_snippet_btn = QPushButton( _("Delete currently selected snippet")) self.delete_snippet_btn.setEnabled(False) self.export_snippets_btn = QPushButton(_("Export snippets to JSON")) self.import_snippets_btn = QPushButton(_("Import snippets from JSON")) # Slots connected to buttons self.new_snippet_btn.clicked.connect(self.create_new_snippet) self.reset_snippets_btn.clicked.connect(self.reset_default_snippets) self.delete_snippet_btn.clicked.connect(self.delete_snippet) self.export_snippets_btn.clicked.connect(self.export_snippets) self.import_snippets_btn.clicked.connect(self.import_snippets) # Buttons layout btns = [ self.new_snippet_btn, self.delete_snippet_btn, self.reset_snippets_btn, self.export_snippets_btn, self.import_snippets_btn ] sn_buttons_layout = QGridLayout() for i, btn in enumerate(btns): sn_buttons_layout.addWidget(btn, i, 1) sn_buttons_layout.setColumnStretch(0, 1) sn_buttons_layout.setColumnStretch(1, 2) sn_buttons_layout.setColumnStretch(2, 1) # Snippets layout snippets_layout = QVBoxLayout() snippets_layout.addWidget(snippets_info_label) snippets_layout.addWidget(snippet_lang_group) snippets_layout.addWidget(snippet_table_group) snippets_layout.addLayout(sn_buttons_layout) snippets_widget = QWidget() snippets_widget.setLayout(snippets_layout) # --- Advanced tab --- # Clients group clients_group = QGroupBox(_("Providers")) self.kite_enabled = newcb(_("Enable Kite " "(if the Kite engine is running)"), 'enable', section='kite') self.fallback_enabled = newcb(_("Enable fallback completions"), 'enable', section='fallback-completions') self.completions_wait_for_ms = self.create_spinbox( _("Time to wait for all providers to return (ms):"), None, 'completions_wait_for_ms', min_=0, max_=5000, step=10, tip=_("Beyond this timeout, " "the first available provider will be returned"), section='editor') clients_layout = QVBoxLayout() clients_layout.addWidget(self.kite_enabled) clients_layout.addWidget(self.fallback_enabled) clients_layout.addWidget(self.completions_wait_for_ms) clients_group.setLayout(clients_layout) kite_layout = QVBoxLayout() self.kite_cta = self.create_checkbox(_( "Notify me when Kite can provide missing completions" " (but is unavailable)"), 'call_to_action', section='kite') kite_layout.addWidget(self.kite_cta) kite_group = QGroupBox(_('Kite configuration')) kite_group.setLayout(kite_layout) # Advanced label lsp_advanced_group = QGroupBox( _('Python Language Server configuration')) advanced_label = QLabel( _("<b>Warning</b>: Only modify these values if " "you know what you're doing!")) advanced_label.setWordWrap(True) advanced_label.setAlignment(Qt.AlignJustify) # Advanced settings checkbox self.advanced_options_check = self.create_checkbox( _("Enable advanced settings"), 'advanced/enabled') # Advanced options self.advanced_module = self.create_lineedit( _("Module for the Python language server: "), 'advanced/module', alignment=Qt.Horizontal, word_wrap=False) self.advanced_host = self.create_lineedit( _("IP Address and port to bind the server to: "), 'advanced/host', alignment=Qt.Horizontal, word_wrap=False) self.advanced_port = self.create_spinbox(":", "", 'advanced/port', min_=1, max_=65535, step=1) self.external_server = self.create_checkbox( _("This is an external server"), 'advanced/external') self.use_stdio = self.create_checkbox( _("Use stdio pipes to communicate with server"), 'advanced/stdio') self.use_stdio.stateChanged.connect(self.disable_tcp) self.external_server.stateChanged.connect(self.disable_stdio) # Advanced layout advanced_g_layout = QGridLayout() advanced_g_layout.addWidget(self.advanced_module.label, 1, 0) advanced_g_layout.addWidget(self.advanced_module.textbox, 1, 1) advanced_g_layout.addWidget(self.advanced_host.label, 2, 0) advanced_host_port_g_layout = QGridLayout() advanced_host_port_g_layout.addWidget(self.advanced_host.textbox, 1, 0) advanced_host_port_g_layout.addWidget(self.advanced_port.plabel, 1, 1) advanced_host_port_g_layout.addWidget(self.advanced_port.spinbox, 1, 2) advanced_g_layout.addLayout(advanced_host_port_g_layout, 2, 1) # External server and stdio options layout advanced_server_layout = QVBoxLayout() advanced_server_layout.addWidget(self.external_server) advanced_server_layout.addWidget(self.use_stdio) advanced_options_layout = QVBoxLayout() advanced_options_layout.addLayout(advanced_g_layout) advanced_options_layout.addLayout(advanced_server_layout) # Set advanced options enabled/disabled advanced_options_widget = QWidget() advanced_options_widget.setLayout(advanced_options_layout) advanced_options_widget.setEnabled(self.get_option('advanced/enabled')) self.advanced_options_check.toggled.connect( advanced_options_widget.setEnabled) self.advanced_options_check.toggled.connect(self.show_advanced_warning) # Advanced options layout advanced_layout = QVBoxLayout() advanced_layout.addWidget(advanced_label) advanced_layout.addWidget(self.advanced_options_check) advanced_layout.addWidget(advanced_options_widget) lsp_advanced_group.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) self.table.setMaximumHeight(150) 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 --- self.tabs = QTabWidget() self.tabs.addTab(self.create_tab(completion_widget), _('Completion')) self.tabs.addTab(self.create_tab(linting_widget), _('Linting')) self.tabs.addTab(self.create_tab(introspection_group, advanced_group), _('Introspection')) self.tabs.addTab(self.create_tab(code_style_widget), _('Code style')) self.tabs.addTab(self.create_tab(docstring_style_widget), _('Docstring style')) self.tabs.addTab(self.create_tab(code_fmt_widget), _('Code formatting')) self.tabs.addTab(self.create_tab(snippets_widget), _('Snippets')) self.tabs.addTab( self.create_tab(clients_group, lsp_advanced_group, kite_group), _('Advanced')) self.tabs.addTab(self.create_tab(servers_widget), _('Other languages')) vlayout = QVBoxLayout() vlayout.addWidget(self.tabs) self.setLayout(vlayout)
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.label_warning.setMinimumHeight( 3 * self.label_warning.sizeHint().height()) 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) # Signals self.button_ok.clicked.connect(self.accept) self.button_clear.clicked.connect(self.unbind_shortcut) self.button_cancel.clicked.connect(self.reject) self.button_default.clicked.connect(self.set_sequence_to_default) # Set all widget to no focus so that we can register <Tab> key # press event. widgets = (self.label_warning, self.helper_button, self.text_new_sequence, self.button_clear, self.button_default, self.button_cancel, self.button_ok, self.btn_clear_sequence, self.button_back_sequence) for w in widgets: w.setFocusPolicy(Qt.NoFocus) w.clearFocus()
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)
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)
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)
def setup_page(self): newcb = self.create_checkbox # --- Introspection --- # Basic features group basic_features_group = QGroupBox(_("Basic features")) completion_box = newcb(_("Enable code completion"), 'code_completion') goto_definition_box = newcb( _("Enable Go to definition"), 'jedi_definition', tip=_("If this option is enabled, left-clicking on\n" "an object name while pressing the {} key will go to\n" "that object's definition (if resolved).".format(self.CTRL))) follow_imports_box = newcb(_("Follow imports when going to a " "definition"), 'jedi_definition/follow_imports') show_signature_box = newcb(_("Show calltips"), 'jedi_signature_help') basic_features_layout = QVBoxLayout() basic_features_layout.addWidget(completion_box) basic_features_layout.addWidget(goto_definition_box) basic_features_layout.addWidget(follow_imports_box) basic_features_layout.addWidget(show_signature_box) basic_features_group.setLayout(basic_features_layout) # Advanced group advanced_group = QGroupBox(_("Advanced")) modules_textedit = self.create_textedit( _("Preload the following modules to make completion faster " "and more accurate:"), 'preload_modules' ) if is_dark_interface(): modules_textedit.textbox.setStyleSheet( "border: 1px solid #32414B;" ) advanced_layout = QVBoxLayout() advanced_layout.addWidget(modules_textedit) advanced_group.setLayout(advanced_layout) # --- Linting --- # Linting options linting_label = QLabel(_("Spyder can optionally highlight syntax " "errors and possible problems with your " "code in the editor.")) linting_label.setOpenExternalLinks(True) linting_label.setWordWrap(True) linting_check = self.create_checkbox( _("Enable basic linting"), 'pyflakes') linting_complexity_box = self.create_checkbox( _("Enable complexity linting with " "the Mccabe package"), 'mccabe') # Linting layout linting_layout = QVBoxLayout() linting_layout.addWidget(linting_label) linting_layout.addWidget(linting_check) linting_layout.addWidget(linting_complexity_box) linting_widget = QWidget() linting_widget.setLayout(linting_layout) # --- Code style tab --- # Code style label pep_url = ( '<a href="https://www.python.org/dev/peps/pep-0008">PEP 8</a>') code_style_codes_url = _( "<a href='http://pycodestyle.pycqa.org/en/stable" "/intro.html#error-codes'>pycodestyle error codes</a>") code_style_label = QLabel( _("Spyder can use pycodestyle to analyze your code for " "conformance to the {} convention. You can also " "manually show or hide specific warnings by their " "{}.").format(pep_url, code_style_codes_url)) code_style_label.setOpenExternalLinks(True) code_style_label.setWordWrap(True) # Code style checkbox code_style_check = self.create_checkbox( _("Enable code style linting"), 'pycodestyle') # Code style options self.code_style_filenames_match = self.create_lineedit( _("Only check filenames matching these patterns:"), 'pycodestyle/filename', alignment=Qt.Horizontal, word_wrap=False, placeholder=_("Check Python files: *.py")) self.code_style_exclude = self.create_lineedit( _("Exclude files or directories matching these patterns:"), 'pycodestyle/exclude', alignment=Qt.Horizontal, word_wrap=False, placeholder=_("Exclude all test files: (?!test_).*\\.py")) code_style_select = self.create_lineedit( _("Show the following errors or warnings:").format( code_style_codes_url), 'pycodestyle/select', alignment=Qt.Horizontal, word_wrap=False, placeholder=_("Example codes: E113, W391")) code_style_ignore = self.create_lineedit( _("Ignore the following errors or warnings:"), 'pycodestyle/ignore', alignment=Qt.Horizontal, word_wrap=False, placeholder=_("Example codes: E201, E303")) code_style_max_line_length = self.create_spinbox( _("Maximum allowed line length:"), None, 'pycodestyle/max_line_length', min_=10, max_=500, step=1, tip=_("Default is 79")) # Code style layout code_style_g_layout = QGridLayout() code_style_g_layout.addWidget( self.code_style_filenames_match.label, 1, 0) code_style_g_layout.addWidget( self.code_style_filenames_match.textbox, 1, 1) code_style_g_layout.addWidget(self.code_style_exclude.label, 2, 0) code_style_g_layout.addWidget(self.code_style_exclude.textbox, 2, 1) code_style_g_layout.addWidget(code_style_select.label, 3, 0) code_style_g_layout.addWidget(code_style_select.textbox, 3, 1) code_style_g_layout.addWidget(code_style_ignore.label, 4, 0) code_style_g_layout.addWidget(code_style_ignore.textbox, 4, 1) code_style_g_layout.addWidget(code_style_max_line_length.plabel, 5, 0) code_style_g_layout.addWidget( code_style_max_line_length.spinbox, 5, 1) # Set Code style options enabled/disabled code_style_g_widget = QWidget() code_style_g_widget.setLayout(code_style_g_layout) code_style_g_widget.setEnabled(self.get_option('pycodestyle')) code_style_check.toggled.connect(code_style_g_widget.setEnabled) # Code style layout code_style_layout = QVBoxLayout() code_style_layout.addWidget(code_style_label) code_style_layout.addWidget(code_style_check) code_style_layout.addWidget(code_style_g_widget) code_style_widget = QWidget() code_style_widget.setLayout(code_style_layout) # --- Docstring tab --- # Docstring style label numpy_url = ( "<a href='https://numpydoc.readthedocs.io/en/" "latest/format.html'>Numpy</a>") pep257_url = ( "<a href='https://www.python.org/dev/peps/pep-0257/'>PEP 257</a>") docstring_style_codes = _( "<a href='http://www.pydocstyle.org/en/stable" "/error_codes.html'>page</a>") docstring_style_label = QLabel( _("Here you can decide if you want to perform style analysis on " "your docstrings according to the {} or {} conventions. You can " "also decide if you want to show or ignore specific errors, " "according to the codes found on this {}.").format( numpy_url, pep257_url, docstring_style_codes)) docstring_style_label.setOpenExternalLinks(True) docstring_style_label.setWordWrap(True) # Docstring style checkbox docstring_style_check = self.create_checkbox( _("Enable docstring style linting"), 'pydocstyle') # Docstring style options docstring_style_convention = self.create_combobox( _("Choose the convention used to lint docstrings: "), (("Numpy", 'numpy'), ("PEP 257", 'pep257'), ("Custom", 'custom')), 'pydocstyle/convention') self.docstring_style_select = self.create_lineedit( _("Show the following errors:"), 'pydocstyle/select', alignment=Qt.Horizontal, word_wrap=False, placeholder=_("Example codes: D413, D414")) self.docstring_style_ignore = self.create_lineedit( _("Ignore the following errors:"), 'pydocstyle/ignore', alignment=Qt.Horizontal, word_wrap=False, placeholder=_("Example codes: D107, D402")) self.docstring_style_match = self.create_lineedit( _("Only check filenames matching these patterns:"), 'pydocstyle/match', alignment=Qt.Horizontal, word_wrap=False, placeholder=_("Skip test files: (?!test_).*\\.py")) self.docstring_style_match_dir = self.create_lineedit( _("Only check in directories matching these patterns:"), 'pydocstyle/match_dir', alignment=Qt.Horizontal, word_wrap=False, placeholder=_("Skip dot directories: [^\\.].*")) # Custom option handling docstring_style_convention.combobox.currentTextChanged.connect( self.setup_docstring_style_convention) current_convention = docstring_style_convention.combobox.currentText() self.setup_docstring_style_convention(current_convention) # Docstring style layout docstring_style_g_layout = QGridLayout() docstring_style_g_layout.addWidget( docstring_style_convention.label, 1, 0) docstring_style_g_layout.addWidget( docstring_style_convention.combobox, 1, 1) docstring_style_g_layout.addWidget( self.docstring_style_select.label, 2, 0) docstring_style_g_layout.addWidget( self.docstring_style_select.textbox, 2, 1) docstring_style_g_layout.addWidget( self.docstring_style_ignore.label, 3, 0) docstring_style_g_layout.addWidget( self.docstring_style_ignore.textbox, 3, 1) docstring_style_g_layout.addWidget( self.docstring_style_match.label, 4, 0) docstring_style_g_layout.addWidget( self.docstring_style_match.textbox, 4, 1) docstring_style_g_layout.addWidget( self.docstring_style_match_dir.label, 5, 0) docstring_style_g_layout.addWidget( self.docstring_style_match_dir.textbox, 5, 1) # Set Docstring style options enabled/disabled docstring_style_g_widget = QWidget() docstring_style_g_widget.setLayout(docstring_style_g_layout) docstring_style_g_widget.setEnabled(self.get_option('pydocstyle')) docstring_style_check.toggled.connect( docstring_style_g_widget.setEnabled) # Docstring style layout docstring_style_layout = QVBoxLayout() docstring_style_layout.addWidget(docstring_style_label) docstring_style_layout.addWidget(docstring_style_check) docstring_style_layout.addWidget(docstring_style_g_widget) docstring_style_widget = QWidget() docstring_style_widget.setLayout(docstring_style_layout) # --- Advanced tab --- # Advanced label advanced_label = QLabel( _("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)
def __init__(self, parent, name=None, prefix=None, channels=(), active_channels=(), conda_url='https://conda.anaconda.org', conda_api_url='https://api.anaconda.org', setup=True, data_directory=None, extra_metadata={}): super(CondaPackagesWidget, self).__init__(parent) # Check arguments: active channels, must be witbhin channels for ch in active_channels: if ch not in channels: raise Exception("'active_channels' must be also within " "'channels'") if data_directory is None: data_directory = self.CONDA_CONF_PATH self._parent = parent self._current_action_name = '' self._hide_widgets = False self._metadata = extra_metadata # From repo.continuum self._metadata_links = {} # Bundled metadata self.api = ManagerAPI() self.busy = False self.data_directory = data_directory self.conda_url = conda_url self.conda_api_url = conda_api_url self.name = name self.package_blacklist = [] self.prefix = prefix self.root_prefix = self.api.ROOT_PREFIX self.style_sheet = None self.message = '' self.apply_actions_dialog = None self.conda_errors = [] self.message_box_error = None self.token = None if channels: self._channels = channels self._active_channels = active_channels else: self._channels = self.api.conda_get_condarc_channels() self._active_channels = self._channels[:] try: import spyderlib.utils.icon_manager as ima icon_options = ima.icon('tooloptions') except Exception: import qtawesome as qta icon_options = qta.icon('fa.cog') # Widgets self.cancel_dialog = ClosePackageManagerDialog self.bbox = QDialogButtonBox(Qt.Horizontal) self.button_cancel = QPushButton('Cancel') self.button_channels = QPushButton(_('Channels')) self.button_ok = QPushButton(_('Ok')) self.button_update = QPushButton(_('Update index...')) self.button_apply = QPushButton(_('Apply')) self.button_clear = QPushButton(_('Clear')) self.button_options = QToolButton() self.combobox_filter = DropdownPackageFilter(self) self.frame_top = FramePackageTop() self.frame_bottom = FramePackageTop() self.progress_bar = ProgressBarPackage(self) self.status_bar = LabelPackageStatus(self) self.table = TableCondaPackages(self) self.textbox_search = LineEditSearch(self) self.widgets = [self.button_update, self.button_channels, self.combobox_filter, self.textbox_search, self.table, self.button_ok, self.button_apply, self.button_clear, self.button_options] 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()
def __init__(self, parent): super(KiteInstallation, self).__init__(parent) # Left side action_layout = QVBoxLayout() progress_layout = QHBoxLayout() self._progress_widget = QWidget(self) self._progress_widget.setFixedHeight(50) self._progress_filter = HoverEventFilter() self._progress_bar = QProgressBar(self) self._progress_bar.setFixedWidth(180) self._progress_widget.installEventFilter(self._progress_filter) self.cancel_button = QPushButton() self.cancel_button.setIcon(ima.icon('DialogCloseButton')) self.cancel_button.hide() progress_layout.addWidget(self._progress_bar, alignment=Qt.AlignLeft) progress_layout.addWidget(self.cancel_button) self._progress_widget.setLayout(progress_layout) self._progress_label = QLabel(_('Downloading')) install_info = QLabel( _("Kite comes with a native app called the Copilot <br>" "which provides you with real time <br>" "documentation as you code.<br><br>" "When Kite is done installing, the Copilot will <br>" "launch automatically and guide you throught the <br>" "rest of the setup process.")) button_layout = QHBoxLayout() self.ok_button = QPushButton(_('OK')) button_layout.addStretch() button_layout.addWidget(self.ok_button) button_layout.addStretch() action_layout.addStretch() action_layout.addWidget(self._progress_label) action_layout.addWidget(self._progress_widget) action_layout.addWidget(install_info) action_layout.addSpacing(10) action_layout.addLayout(button_layout) action_layout.addStretch() # Right side copilot_image_source = get_image_path('kite_copilot') copilot_image = QPixmap(copilot_image_source) copilot_label = QLabel() screen = QApplication.primaryScreen() device_pixel_ratio = screen.devicePixelRatio() if device_pixel_ratio > 1: copilot_image.setDevicePixelRatio(device_pixel_ratio) copilot_label.setPixmap(copilot_image) else: image_height = int(copilot_image.height() * 0.4) image_width = int(copilot_image.width() * 0.4) copilot_label.setPixmap( copilot_image.scaled(image_width, image_height, Qt.KeepAspectRatio, Qt.SmoothTransformation)) # Layout general_layout = QHBoxLayout() general_layout.addLayout(action_layout) general_layout.addWidget(copilot_label) self.setLayout(general_layout) # Signals self._progress_filter.sig_hover_enter.connect( lambda: self.cancel_button.show()) self._progress_filter.sig_hover_leave.connect( lambda: self.cancel_button.hide())
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)
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)
def setup_page(self): newcb = self.create_checkbox # --- Introspection --- # Basic features group basic_features_group = QGroupBox(_("Basic features")) completion_box = newcb(_("Enable code completion"), 'code_completion') code_snippets_box = newcb(_("Enable code snippets"), 'code_snippets') enable_hover_hints_box = newcb( _("Enable hover hints"), 'enable_hover_hints', tip=_("If enabled, hovering the mouse pointer over an object\n" "name will display that object's signature and/or\n" "docstring (if present).")) goto_definition_box = newcb( _("Enable Go to definition"), 'jedi_definition', tip=_("If enabled, left-clicking on an object name while \n" "pressing the {} key will go to that object's definition\n" "(if resolved).".format(self.CTRL))) follow_imports_box = newcb(_("Follow imports when going to a " "definition"), 'jedi_definition/follow_imports') show_signature_box = newcb(_("Show calltips"), 'jedi_signature_help') basic_features_layout = QVBoxLayout() basic_features_layout.addWidget(completion_box) basic_features_layout.addWidget(code_snippets_box) basic_features_layout.addWidget(enable_hover_hints_box) basic_features_layout.addWidget(goto_definition_box) basic_features_layout.addWidget(follow_imports_box) basic_features_layout.addWidget(show_signature_box) basic_features_group.setLayout(basic_features_layout) # Advanced group advanced_group = QGroupBox(_("Advanced")) modules_textedit = self.create_textedit( _("Preload the following modules to make completion faster " "and more accurate:"), 'preload_modules' ) if is_dark_interface(): modules_textedit.textbox.setStyleSheet( "border: 1px solid #32414B;" ) advanced_layout = QVBoxLayout() advanced_layout.addWidget(modules_textedit) advanced_group.setLayout(advanced_layout) # --- Linting --- # Linting options linting_label = QLabel(_("Spyder can optionally highlight syntax " "errors and possible problems with your " "code in the editor.")) linting_label.setOpenExternalLinks(True) linting_label.setWordWrap(True) linting_check = self.create_checkbox( _("Enable basic linting"), 'pyflakes') linting_complexity_box = self.create_checkbox( _("Enable complexity linting with " "the Mccabe package"), 'mccabe') # Linting layout linting_layout = QVBoxLayout() linting_layout.addWidget(linting_label) linting_layout.addWidget(linting_check) linting_layout.addWidget(linting_complexity_box) linting_widget = QWidget() linting_widget.setLayout(linting_layout) # --- Code style tab --- # Code style label pep_url = ( '<a href="https://www.python.org/dev/peps/pep-0008">PEP 8</a>') code_style_codes_url = _( "<a href='http://pycodestyle.pycqa.org/en/stable" "/intro.html#error-codes'>pycodestyle error codes</a>") code_style_label = QLabel( _("Spyder can use pycodestyle to analyze your code for " "conformance to the {} convention. You can also " "manually show or hide specific warnings by their " "{}.").format(pep_url, code_style_codes_url)) code_style_label.setOpenExternalLinks(True) code_style_label.setWordWrap(True) # Code style checkbox self.code_style_check = self.create_checkbox( _("Enable code style linting"), 'pycodestyle') # Code style options self.code_style_filenames_match = self.create_lineedit( _("Only check filenames matching these patterns:"), 'pycodestyle/filename', alignment=Qt.Horizontal, word_wrap=False, placeholder=_("Check Python files: *.py")) self.code_style_exclude = self.create_lineedit( _("Exclude files or directories matching these patterns:"), 'pycodestyle/exclude', alignment=Qt.Horizontal, word_wrap=False, placeholder=_("Exclude all test files: (?!test_).*\\.py")) code_style_select = self.create_lineedit( _("Show the following errors or warnings:").format( code_style_codes_url), 'pycodestyle/select', alignment=Qt.Horizontal, word_wrap=False, placeholder=_("Example codes: E113, W391")) code_style_ignore = self.create_lineedit( _("Ignore the following errors or warnings:"), 'pycodestyle/ignore', alignment=Qt.Horizontal, word_wrap=False, placeholder=_("Example codes: E201, E303")) code_style_max_line_length = self.create_spinbox( _("Maximum allowed line length:"), None, 'pycodestyle/max_line_length', min_=10, max_=500, step=1, tip=_("Default is 79")) # Code style layout code_style_g_layout = QGridLayout() code_style_g_layout.addWidget( self.code_style_filenames_match.label, 1, 0) code_style_g_layout.addWidget( self.code_style_filenames_match.textbox, 1, 1) code_style_g_layout.addWidget(self.code_style_exclude.label, 2, 0) code_style_g_layout.addWidget(self.code_style_exclude.textbox, 2, 1) code_style_g_layout.addWidget(code_style_select.label, 3, 0) code_style_g_layout.addWidget(code_style_select.textbox, 3, 1) code_style_g_layout.addWidget(code_style_ignore.label, 4, 0) code_style_g_layout.addWidget(code_style_ignore.textbox, 4, 1) code_style_g_layout.addWidget(code_style_max_line_length.plabel, 5, 0) code_style_g_layout.addWidget( code_style_max_line_length.spinbox, 5, 1) # Set Code style options enabled/disabled code_style_g_widget = QWidget() code_style_g_widget.setLayout(code_style_g_layout) code_style_g_widget.setEnabled(self.get_option('pycodestyle')) self.code_style_check.toggled.connect(code_style_g_widget.setEnabled) # Code style layout code_style_layout = QVBoxLayout() code_style_layout.addWidget(code_style_label) code_style_layout.addWidget(self.code_style_check) code_style_layout.addWidget(code_style_g_widget) code_style_widget = QWidget() code_style_widget.setLayout(code_style_layout) # --- Docstring tab --- # Docstring style label numpy_url = ( "<a href='https://numpydoc.readthedocs.io/en/" "latest/format.html'>Numpy</a>") pep257_url = ( "<a href='https://www.python.org/dev/peps/pep-0257/'>PEP 257</a>") docstring_style_codes = _( "<a href='http://www.pydocstyle.org/en/stable" "/error_codes.html'>page</a>") docstring_style_label = QLabel( _("Here you can decide if you want to perform style analysis on " "your docstrings according to the {} or {} conventions. You can " "also decide if you want to show or ignore specific errors, " "according to the codes found on this {}.").format( numpy_url, pep257_url, docstring_style_codes)) docstring_style_label.setOpenExternalLinks(True) docstring_style_label.setWordWrap(True) # Docstring style checkbox self.docstring_style_check = self.create_checkbox( _("Enable docstring style linting"), 'pydocstyle') # Docstring style options docstring_style_convention = self.create_combobox( _("Choose the convention used to lint docstrings: "), (("Numpy", 'numpy'), ("PEP 257", 'pep257'), ("Custom", 'custom')), 'pydocstyle/convention') self.docstring_style_select = self.create_lineedit( _("Show the following errors:"), 'pydocstyle/select', alignment=Qt.Horizontal, word_wrap=False, placeholder=_("Example codes: D413, D414")) self.docstring_style_ignore = self.create_lineedit( _("Ignore the following errors:"), 'pydocstyle/ignore', alignment=Qt.Horizontal, word_wrap=False, placeholder=_("Example codes: D107, D402")) self.docstring_style_match = self.create_lineedit( _("Only check filenames matching these patterns:"), 'pydocstyle/match', alignment=Qt.Horizontal, word_wrap=False, placeholder=_("Skip test files: (?!test_).*\\.py")) self.docstring_style_match_dir = self.create_lineedit( _("Only check in directories matching these patterns:"), 'pydocstyle/match_dir', alignment=Qt.Horizontal, word_wrap=False, placeholder=_("Skip dot directories: [^\\.].*")) # Custom option handling docstring_style_convention.combobox.currentTextChanged.connect( self.setup_docstring_style_convention) current_convention = docstring_style_convention.combobox.currentText() self.setup_docstring_style_convention(current_convention) # Docstring style layout docstring_style_g_layout = QGridLayout() docstring_style_g_layout.addWidget( docstring_style_convention.label, 1, 0) docstring_style_g_layout.addWidget( docstring_style_convention.combobox, 1, 1) docstring_style_g_layout.addWidget( self.docstring_style_select.label, 2, 0) docstring_style_g_layout.addWidget( self.docstring_style_select.textbox, 2, 1) docstring_style_g_layout.addWidget( self.docstring_style_ignore.label, 3, 0) docstring_style_g_layout.addWidget( self.docstring_style_ignore.textbox, 3, 1) docstring_style_g_layout.addWidget( self.docstring_style_match.label, 4, 0) docstring_style_g_layout.addWidget( self.docstring_style_match.textbox, 4, 1) docstring_style_g_layout.addWidget( self.docstring_style_match_dir.label, 5, 0) docstring_style_g_layout.addWidget( self.docstring_style_match_dir.textbox, 5, 1) # Set Docstring style options enabled/disabled docstring_style_g_widget = QWidget() docstring_style_g_widget.setLayout(docstring_style_g_layout) docstring_style_g_widget.setEnabled(self.get_option('pydocstyle')) self.docstring_style_check.toggled.connect( docstring_style_g_widget.setEnabled) # Docstring style layout docstring_style_layout = QVBoxLayout() docstring_style_layout.addWidget(docstring_style_label) docstring_style_layout.addWidget(self.docstring_style_check) docstring_style_layout.addWidget(docstring_style_g_widget) docstring_style_widget = QWidget() docstring_style_widget.setLayout(docstring_style_layout) # --- Advanced tab --- # Advanced label advanced_label = QLabel( _("<b>Warning</b>: Only modify these values if " "you know what you're doing!")) advanced_label.setWordWrap(True) advanced_label.setAlignment(Qt.AlignJustify) # Advanced settings checkbox self.advanced_options_check = self.create_checkbox( _("Enable advanced settings"), 'advanced/enabled') # Advanced options self.advanced_module = self.create_lineedit( _("Module for the Python language server: "), 'advanced/module', alignment=Qt.Horizontal, word_wrap=False) self.advanced_host = self.create_lineedit( _("IP Address and port to bind the server to: "), 'advanced/host', alignment=Qt.Horizontal, word_wrap=False) self.advanced_port = self.create_spinbox( ":", "", 'advanced/port', min_=1, max_=65535, step=1) self.external_server = self.create_checkbox( _("This is an external server"), 'advanced/external') self.use_stdio = self.create_checkbox( _("Use stdio pipes to communicate with server"), 'advanced/stdio') self.use_stdio.stateChanged.connect(self.disable_tcp) self.external_server.stateChanged.connect(self.disable_stdio) # Advanced layout advanced_g_layout = QGridLayout() advanced_g_layout.addWidget(self.advanced_module.label, 1, 0) advanced_g_layout.addWidget(self.advanced_module.textbox, 1, 1) advanced_g_layout.addWidget(self.advanced_host.label, 2, 0) advanced_host_port_g_layout = QGridLayout() advanced_host_port_g_layout.addWidget(self.advanced_host.textbox, 1, 0) advanced_host_port_g_layout.addWidget(self.advanced_port.plabel, 1, 1) advanced_host_port_g_layout.addWidget(self.advanced_port.spinbox, 1, 2) advanced_g_layout.addLayout(advanced_host_port_g_layout, 2, 1) # External server and stdio options layout advanced_server_layout = QVBoxLayout() advanced_server_layout.addWidget(self.external_server) advanced_server_layout.addWidget(self.use_stdio) advanced_options_layout = QVBoxLayout() advanced_options_layout.addLayout(advanced_g_layout) advanced_options_layout.addLayout(advanced_server_layout) # Set advanced options enabled/disabled advanced_options_widget = QWidget() advanced_options_widget.setLayout(advanced_options_layout) advanced_options_widget.setEnabled(self.get_option('advanced/enabled')) self.advanced_options_check.toggled.connect( advanced_options_widget.setEnabled) self.advanced_options_check.toggled.connect( self.show_advanced_warning) # Advanced options layout advanced_layout = QVBoxLayout() advanced_layout.addWidget(advanced_label) advanced_layout.addWidget(self.advanced_options_check) advanced_layout.addWidget(advanced_options_widget) advanced_widget = QWidget() 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) self.table.setMaximumHeight(150) 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 --- self.tabs = QTabWidget() self.tabs.addTab(self.create_tab(basic_features_group, advanced_group), _('Introspection')) self.tabs.addTab(self.create_tab(linting_widget), _('Linting')) self.tabs.addTab(self.create_tab(code_style_widget), _('Code style')) self.tabs.addTab(self.create_tab(docstring_style_widget), _('Docstring style')) self.tabs.addTab(self.create_tab(advanced_widget), _('Advanced')) self.tabs.addTab(self.create_tab(servers_widget), _('Other languages')) vlayout = QVBoxLayout() vlayout.addWidget(self.tabs) self.setLayout(vlayout)
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)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) selectProjectButton = QPushButton() selectProjectButton.setCursor(Qt.PointingHandCursor) selectProjectButton.setObjectName("selectProjectButton") selectProjectButton.setText("Select project") self.selectProjectButton = selectProjectButton pathLabel = QLabel() pathLabel.setText("Path:") pathLabel.setToolTip("Project path") pathLabel.setWordWrap(False) pathLabel.setAlignment(Qt.AlignRight) pathValueLabel = QElidedLabel() pathValueLabel.setText("none") pathValueLabel.setToolTip("none") pathValueLabel.setWordWrap(False) self.pathValueLabel = pathValueLabel nameLabel = QLabel() nameLabel.setText("Name:") nameLabel.setToolTip("Project name") nameLabel.setWordWrap(False) nameLabel.setAlignment(Qt.AlignRight) nameValueLabel = QElidedLabel() nameValueLabel.setText("none") nameValueLabel.setToolTip("none") nameValueLabel.setWordWrap(False) self.nameValueLabel = nameValueLabel projectStatusGrid = QGridLayout() projectStatusGrid.setContentsMargins(2, 2, 2, 2) projectStatusGrid.setColumnStretch(0, 0) projectStatusGrid.setColumnStretch(1, 1) projectStatusGrid.addWidget(pathLabel, 0, 0) projectStatusGrid.addWidget(nameLabel, 1, 0) projectStatusGrid.addWidget(pathValueLabel, 0, 1) projectStatusGrid.addWidget(nameValueLabel, 1, 1) projectGroupBox = QGroupBox() projectGroupBox.setTitle("Current project") projectGroupBox.setLayout(projectStatusGrid) statusLayout = QVBoxLayout() statusLayout.addWidget(selectProjectButton, stretch=0) statusLayout.addSpacing(10) statusLayout.addWidget(projectGroupBox, stretch=0) statusLayout.addStretch(1) statusLayout.setContentsMargins(0, 0, 0, 0) statusLayout.setSpacing(0) statusWidget = QWidget() statusWidget.setLayout(statusLayout) statusWidget.setContentsMargins(0, 0, 0, 0) statusWidget.setFixedWidth(250) noProjectSetLabel = QLabel() noProjectSetLabel.setObjectName("noProjectSetLabel") noProjectSetLabel.setText("No project set") noProjectSetLabel.setAlignment(Qt.AlignCenter) layout = QHBoxLayout() layout.setContentsMargins(6, 6, 6, 6) layout.addWidget(statusWidget, stretch=0) layout.addSpacing(3) layout.addWidget(noProjectSetLabel, stretch=1) self.setLayout(layout)
def __init__(self, parent, project_types): """Project creation dialog.""" super(ProjectDialog, self).__init__(parent=parent) self.plugin = parent self._project_types = project_types self.project_data = {} # 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.label_information = QLabel("") 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) for (id_, name) in [(pt_id, pt.get_name()) for pt_id, pt in project_types.items()]: self.combo_project_type.addItem(name, id_) 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_grid.addWidget(self.label_information, 4, 0, 1, 3) 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)
def __init__(self, parent): super(KiteIntegrationInfo, self).__init__(parent) # Images images_layout = QHBoxLayout() icon_filename = 'kite_completions' image_path = get_image_path(icon_filename) image = QPixmap(image_path) image_label = QLabel() image_label = QLabel() image_height = int(image.height() * DialogStyle.IconScaleFactor) image_width = int(image.width() * DialogStyle.IconScaleFactor) image = image.scaled(image_width, image_height, Qt.KeepAspectRatio, Qt.SmoothTransformation) image_label.setPixmap(image) images_layout.addStretch() images_layout.addWidget(image_label) images_layout.addStretch() ilayout = QHBoxLayout() ilayout.addLayout(images_layout) # Label integration_label_title = QLabel( "Get better code completions in Spyder") integration_label_title.setStyleSheet( f"font-size: {DialogStyle.TitleFontSize}") integration_label_title.setWordWrap(True) integration_label = QLabel( _("Now Spyder can use Kite to provide better code " "completions for key packages in the scientific Python " "Ecosystem. Install Kite for a better editor experience in " "Spyder. <br><br>Kite is free to use but is not open " "source. <a href=\"{kite_url}\">Learn more about Kite </a>"). format(kite_url=KITE_SPYDER_URL)) integration_label.setStyleSheet( f"font-size: {DialogStyle.ContentFontSize}") integration_label.setOpenExternalLinks(True) integration_label.setWordWrap(True) integration_label.setFixedWidth(360) label_layout = QVBoxLayout() label_layout.addWidget(integration_label_title) label_layout.addWidget(integration_label) # Buttons install_button_color = QStylePalette.COLOR_ACCENT_2 install_button_hover = QStylePalette.COLOR_ACCENT_3 install_button_pressed = QStylePalette.COLOR_ACCENT_4 dismiss_button_color = QStylePalette.COLOR_BACKGROUND_4 dismiss_button_hover = QStylePalette.COLOR_BACKGROUND_5 dismiss_button_pressed = QStylePalette.COLOR_BACKGROUND_6 font_color = QStylePalette.COLOR_TEXT_1 buttons_layout = QHBoxLayout() install_button = QPushButton(_('Install Kite')) install_button.setAutoDefault(False) install_button.setStyleSheet( ("QPushButton {{ " "background-color: {background_color};" "border-color: {border_color};" "font-size: {font_size};" "color: {font_color};" "padding: {padding}}}" "QPushButton:hover:!pressed {{ " "background-color: {color_hover}}}" "QPushButton:pressed {{ " "background-color: {color_pressed}}}").format( background_color=install_button_color, border_color=install_button_color, font_size=DialogStyle.ButtonsFontSize, font_color=font_color, padding=DialogStyle.ButtonsPadding, color_hover=install_button_hover, color_pressed=install_button_pressed)) dismiss_button = QPushButton(_('Dismiss')) dismiss_button.setAutoDefault(False) dismiss_button.setStyleSheet( ("QPushButton {{ " "background-color: {background_color};" "border-color: {border_color};" "font-size: {font_size};" "color: {font_color};" "padding: {padding}}}" "QPushButton:hover:!pressed {{ " "background-color: {color_hover}}}" "QPushButton:pressed {{ " "background-color: {color_pressed}}}").format( background_color=dismiss_button_color, border_color=dismiss_button_color, font_size=DialogStyle.ButtonsFontSize, font_color=font_color, padding=DialogStyle.ButtonsPadding, color_hover=dismiss_button_hover, color_pressed=dismiss_button_pressed)) buttons_layout.addStretch() buttons_layout.addWidget(install_button) if not MAC: buttons_layout.addSpacing(10) buttons_layout.addWidget(dismiss_button) # Buttons with label vertical_layout = QVBoxLayout() if not MAC: vertical_layout.addStretch() vertical_layout.addLayout(label_layout) vertical_layout.addSpacing(20) vertical_layout.addLayout(buttons_layout) vertical_layout.addStretch() else: vertical_layout.addLayout(label_layout) vertical_layout.addLayout(buttons_layout) general_layout = QHBoxLayout() general_layout.addStretch() general_layout.addLayout(ilayout) general_layout.addSpacing(15) general_layout.addLayout(vertical_layout) general_layout.addStretch() self.setLayout(general_layout) # Signals install_button.clicked.connect(self.sig_install_button_clicked) dismiss_button.clicked.connect(self.sig_dismiss_button_clicked) self.setStyleSheet( f"background-color: {QStylePalette.COLOR_BACKGROUND_2}") self.setContentsMargins(18, 40, 18, 40) if not MAC: self.setFixedSize(800, 350)