def __init__(self, parent): QWidget.__init__(self, parent) self.setWindowTitle("Breakpoints") self.dictwidget = BreakpointTableView(self, self._load_all_breakpoints()) layout = QVBoxLayout() layout.addWidget(self.dictwidget) self.setLayout(layout) self.connect( self.dictwidget, SIGNAL("clear_all_breakpoints()"), lambda: self.emit(SIGNAL("clear_all_breakpoints()")) ) self.connect( self.dictwidget, SIGNAL("clear_breakpoint(QString,int)"), lambda s1, lino: self.emit(SIGNAL("clear_breakpoint(QString,int)"), s1, lino), ) self.connect( self.dictwidget, SIGNAL("edit_goto(QString,int,QString)"), lambda s1, lino, s2: self.emit(SIGNAL("edit_goto(QString,int,QString)"), s1, lino, s2), ) self.connect( self.dictwidget, SIGNAL("set_or_edit_conditional_breakpoint()"), lambda: self.emit(SIGNAL("set_or_edit_conditional_breakpoint()")), )
def create_scedit(self, text, option, default=NoDefault, tip=None, without_layout=False): label = QLabel(text) clayout = ColorLayout(QColor(Qt.black), self) clayout.lineedit.setMaximumWidth(80) if tip is not None: clayout.setToolTip(tip) cb_bold = QCheckBox() cb_bold.setIcon(ima.icon('bold')) cb_bold.setToolTip(_("Bold")) cb_italic = QCheckBox() cb_italic.setIcon(ima.icon('italic')) cb_italic.setToolTip(_("Italic")) self.scedits[(clayout, cb_bold, cb_italic)] = (option, default) if without_layout: return label, clayout, cb_bold, cb_italic layout = QHBoxLayout() layout.addWidget(label) layout.addLayout(clayout) layout.addSpacing(10) layout.addWidget(cb_bold) layout.addWidget(cb_italic) layout.addStretch(1) layout.setContentsMargins(0, 0, 0, 0) widget = QWidget(self) widget.setLayout(layout) return widget
def __init__(self, parent): QWidget.__init__(self, parent) self.shellwidget = None self.is_internal_shell = None self.ipyclient = None self.is_ipykernel = None self.is_visible = True # Do not modify: light mode won't work! self.setup_in_progress = None # Remote dict editor settings self.check_all = None self.exclude_private = None self.exclude_uppercase = None self.exclude_capitalized = None self.exclude_unsupported = None self.excluded_names = None self.truncate = None self.minmax = None self.remote_editing = None self.autorefresh = None self.editor = None self.exclude_private_action = None self.exclude_uppercase_action = None self.exclude_capitalized_action = None self.exclude_unsupported_action = None self.filename = None
def create_spinbox(self, prefix, suffix, option, default=NoDefault, min_=None, max_=None, step=None, tip=None): if prefix: plabel = QLabel(prefix) else: plabel = None if suffix: slabel = QLabel(suffix) else: slabel = None spinbox = QSpinBox() if min_ is not None: spinbox.setMinimum(min_) if max_ is not None: spinbox.setMaximum(max_) if step is not None: spinbox.setSingleStep(step) if tip is not None: spinbox.setToolTip(tip) self.spinboxes[spinbox] = (option, default) layout = QHBoxLayout() for subwidget in (plabel, spinbox, slabel): if subwidget is not None: layout.addWidget(subwidget) layout.addStretch(1) layout.setContentsMargins(0, 0, 0, 0) widget = QWidget(self) widget.setLayout(layout) return widget
def __init__(self, parent): QWidget.__init__(self, parent) vert_layout = QVBoxLayout() # Type frame type_layout = QHBoxLayout() type_label = QLabel(_("Import as")) type_layout.addWidget(type_label) self.array_btn = array_btn = QRadioButton(_("array")) array_btn.setEnabled(ndarray is not FakeObject) array_btn.setChecked(ndarray is not FakeObject) type_layout.addWidget(array_btn) list_btn = QRadioButton(_("list")) list_btn.setChecked(not array_btn.isChecked()) type_layout.addWidget(list_btn) if pd: self.df_btn = df_btn = QRadioButton(_("DataFrame")) df_btn.setChecked(False) type_layout.addWidget(df_btn) h_spacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) type_layout.addItem(h_spacer) type_frame = QFrame() type_frame.setLayout(type_layout) self._table_view = PreviewTable(self) vert_layout.addWidget(type_frame) vert_layout.addWidget(self._table_view) self.setLayout(vert_layout)
def __init__(self): QWidget.__init__(self) vlayout = QVBoxLayout() self.setLayout(vlayout) self.explorer = ExplorerWidget(self, show_cd_only=None) vlayout.addWidget(self.explorer) hlayout1 = QHBoxLayout() vlayout.addLayout(hlayout1) label = QLabel("<b>Open file:</b>") label.setAlignment(Qt.AlignRight) hlayout1.addWidget(label) self.label1 = QLabel() hlayout1.addWidget(self.label1) self.explorer.sig_open_file.connect(self.label1.setText) hlayout2 = QHBoxLayout() vlayout.addLayout(hlayout2) label = QLabel("<b>Open dir:</b>") label.setAlignment(Qt.AlignRight) hlayout2.addWidget(label) self.label2 = QLabel() hlayout2.addWidget(self.label2) self.explorer.open_dir.connect(self.label2.setText) hlayout3 = QHBoxLayout() vlayout.addLayout(hlayout3) label = QLabel("<b>Option changed:</b>") label.setAlignment(Qt.AlignRight) hlayout3.addWidget(label) self.label3 = QLabel() hlayout3.addWidget(self.label3) self.explorer.sig_option_changed.connect(lambda x, y: self.label3.setText("option_changed: %r, %r" % (x, y))) self.explorer.open_dir.connect(lambda: self.explorer.treewidget.refresh(".."))
def __init__(self, parent=None, show_fullpath=True, fullpath_sorting=True, show_all_files=True, show_comments=True): QWidget.__init__(self, parent) self.treewidget = OutlineExplorerTreeWidget(self, show_fullpath=show_fullpath, fullpath_sorting=fullpath_sorting, show_all_files=show_all_files, show_comments=show_comments) self.visibility_action = create_action(self, _("Show/hide outline explorer"), icon='outline_explorer_vis.png', toggled=self.toggle_visibility) self.visibility_action.setChecked(True) btn_layout = QHBoxLayout() btn_layout.setAlignment(Qt.AlignRight) for btn in self.setup_buttons(): btn_layout.addWidget(btn) layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.treewidget) layout.addLayout(btn_layout) self.setLayout(layout)
def __init__(self, parent=None, name_filters=['*.py', '*.pyw'], valid_types=('.py', '.pyw'), show_all=False, show_cd_only=None, show_toolbar=True, show_icontext=True): QWidget.__init__(self, parent) self.treewidget = ExplorerTreeWidget(self, show_cd_only=show_cd_only) self.treewidget.setup(name_filters=name_filters, valid_types=valid_types, show_all=show_all) self.treewidget.chdir(os.getcwdu()) toolbar_action = create_action(self, _("Show toolbar"), toggled=self.toggle_toolbar) icontext_action = create_action(self, _("Show icons and text"), toggled=self.toggle_icontext) self.treewidget.common_actions += [None, toolbar_action, icontext_action] # Setup toolbar self.toolbar = QToolBar(self) self.toolbar.setIconSize(QSize(16, 16)) self.previous_action = create_action(self, text=_("Previous"), icon=get_icon('previous.png'), triggered=self.treewidget.go_to_previous_directory) self.toolbar.addAction(self.previous_action) self.previous_action.setEnabled(False) self.connect(self.treewidget, SIGNAL("set_previous_enabled(bool)"), self.previous_action.setEnabled) self.next_action = create_action(self, text=_("Next"), icon=get_icon('next.png'), triggered=self.treewidget.go_to_next_directory) self.toolbar.addAction(self.next_action) self.next_action.setEnabled(False) self.connect(self.treewidget, SIGNAL("set_next_enabled(bool)"), self.next_action.setEnabled) parent_action = create_action(self, text=_("Parent"), icon=get_icon('up.png'), triggered=self.treewidget.go_to_parent_directory) self.toolbar.addAction(parent_action) options_action = create_action(self, text=_("Options"), icon=get_icon('tooloptions.png')) self.toolbar.addAction(options_action) widget = self.toolbar.widgetForAction(options_action) widget.setPopupMode(QToolButton.InstantPopup) menu = QMenu(self) add_actions(menu, self.treewidget.common_actions) options_action.setMenu(menu) toolbar_action.setChecked(show_toolbar) self.toggle_toolbar(show_toolbar) icontext_action.setChecked(show_icontext) self.toggle_icontext(show_icontext) vlayout = QVBoxLayout() vlayout.addWidget(self.toolbar) vlayout.addWidget(self.treewidget) self.setLayout(vlayout)
def __init__(self, parent=None): QWidget.__init__(self, parent) self.runconf = RunConfiguration() common_group = QGroupBox(_("General settings")) common_layout = QGridLayout() common_group.setLayout(common_layout) self.clo_cb = QCheckBox(_("Command line options:")) common_layout.addWidget(self.clo_cb, 0, 0) self.clo_edit = QLineEdit() self.connect(self.clo_cb, SIGNAL("toggled(bool)"), self.clo_edit.setEnabled) self.clo_edit.setEnabled(False) common_layout.addWidget(self.clo_edit, 0, 1) self.wd_cb = QCheckBox(_("Working directory:")) common_layout.addWidget(self.wd_cb, 1, 0) wd_layout = QHBoxLayout() self.wd_edit = QLineEdit() self.connect(self.wd_cb, SIGNAL("toggled(bool)"), self.wd_edit.setEnabled) self.wd_edit.setEnabled(False) wd_layout.addWidget(self.wd_edit) browse_btn = QPushButton(get_std_icon("DirOpenIcon"), "", self) browse_btn.setToolTip(_("Select directory")) self.connect(browse_btn, SIGNAL("clicked()"), self.select_directory) wd_layout.addWidget(browse_btn) common_layout.addLayout(wd_layout, 1, 1) radio_group = QGroupBox(_("Interpreter")) radio_layout = QVBoxLayout() radio_group.setLayout(radio_layout) self.current_radio = QRadioButton(_("Execute in current Python " "or IPython interpreter")) radio_layout.addWidget(self.current_radio) self.new_radio = QRadioButton(_("Execute in a new dedicated " "Python interpreter")) radio_layout.addWidget(self.new_radio) self.systerm_radio = QRadioButton(_("Execute in an external " "system terminal")) radio_layout.addWidget(self.systerm_radio) new_group = QGroupBox(_("Dedicated Python interpreter")) self.connect(self.current_radio, SIGNAL("toggled(bool)"), new_group.setDisabled) new_layout = QGridLayout() new_group.setLayout(new_layout) self.interact_cb = QCheckBox(_("Interact with the Python " "interpreter after execution")) new_layout.addWidget(self.interact_cb, 1, 0, 1, -1) self.pclo_cb = QCheckBox(_("Command line options:")) new_layout.addWidget(self.pclo_cb, 2, 0) self.pclo_edit = QLineEdit() self.connect(self.pclo_cb, SIGNAL("toggled(bool)"), self.pclo_edit.setEnabled) self.pclo_edit.setEnabled(False) new_layout.addWidget(self.pclo_edit, 2, 1) pclo_label = QLabel(_("The <b>-u</b> option is " "added to these commands")) pclo_label.setWordWrap(True) new_layout.addWidget(pclo_label, 3, 1) # TODO: Add option for "Post-mortem debugging" layout = QVBoxLayout() layout.addWidget(common_group) layout.addWidget(radio_group) layout.addWidget(new_group) self.setLayout(layout)
def __init__(self, parent=None): QWidget.__init__(self, parent=parent) SpyderPluginMixin.__init__(self, parent) layout = QVBoxLayout() self.setLayout(layout) # Initialize plugin self.initialize_plugin()
def __init__(self, parent=None): QWidget.__init__(self, parent) vlayout = QVBoxLayout() self.setLayout(vlayout) self.treewidget = FilteredDirView(self) self.treewidget.setup_view() self.treewidget.set_root_path(r'D:\Python') self.treewidget.set_folder_names(['spyder', 'spyder-2.0']) vlayout.addWidget(self.treewidget)
def __init__(self, parent=None): QWidget.__init__(self, parent) vlayout = QVBoxLayout() self.setLayout(vlayout) self.treewidget = FilteredDirView(self) self.treewidget.setup_view() self.treewidget.set_root_path(osp.dirname(osp.abspath(__file__))) self.treewidget.set_folder_names(["variableexplorer", "sourcecode"]) vlayout.addWidget(self.treewidget)
def create_tab(self, *widgets): """Create simple tab widget page: widgets added in a vertical layout""" widget = QWidget() layout = QVBoxLayout() for widg in widgets: layout.addWidget(widg) layout.addStretch(1) widget.setLayout(layout) return widget
def hide(self): """Overrides Qt Method""" for widget in self.replace_widgets: widget.hide() QWidget.hide(self) self.visibility_changed.emit(False) if self.editor is not None: self.editor.setFocus() self.clear_matches()
def __init__(self, parent, search_text = r"# ?TODO|# ?FIXME|# ?XXX", search_text_regexp=True, search_path=None, include=[".", ".py"], include_idx=None, include_regexp=True, exclude=r"\.pyc$|\.orig$|\.hg|\.svn", exclude_idx=None, exclude_regexp=True, supported_encodings=("utf-8", "iso-8859-1", "cp1252"), in_python_path=False, more_options=False): QWidget.__init__(self, parent) self.setWindowTitle(_('Find in files')) self.search_thread = None self.get_pythonpath_callback = None self.find_options = FindOptions(self, search_text, search_text_regexp, search_path, include, include_idx, include_regexp, exclude, exclude_idx, exclude_regexp, supported_encodings, in_python_path, more_options) self.connect(self.find_options, SIGNAL('find()'), self.find) self.connect(self.find_options, SIGNAL('stop()'), self.stop_and_reset_thread) self.result_browser = ResultsBrowser(self) collapse_btn = create_toolbutton(self) collapse_btn.setDefaultAction(self.result_browser.collapse_all_action) expand_btn = create_toolbutton(self) expand_btn.setDefaultAction(self.result_browser.expand_all_action) restore_btn = create_toolbutton(self) restore_btn.setDefaultAction(self.result_browser.restore_action) # collapse_sel_btn = create_toolbutton(self) # collapse_sel_btn.setDefaultAction( # self.result_browser.collapse_selection_action) # expand_sel_btn = create_toolbutton(self) # expand_sel_btn.setDefaultAction( # self.result_browser.expand_selection_action) btn_layout = QVBoxLayout() btn_layout.setAlignment(Qt.AlignTop) for widget in [collapse_btn, expand_btn, restore_btn]: # collapse_sel_btn, expand_sel_btn]: btn_layout.addWidget(widget) hlayout = QHBoxLayout() hlayout.addWidget(self.result_browser) hlayout.addLayout(btn_layout) layout = QVBoxLayout() left, _x, right, bottom = layout.getContentsMargins() layout.setContentsMargins(left, 0, right, bottom) layout.addWidget(self.find_options) layout.addLayout(hlayout) self.setLayout(layout)
def __init__(self, parent): QWidget.__init__(self, parent) self.parent = parent # Variables to adjust self.duration_canvas = [666, 666] self.duration_tips = [333, 333] self.opacity_canvas = [0.0, 0.7] self.opacity_tips = [0.0, 1.0] self.color = Qt.black self.easing_curve = [QEasingCurve.Linear] self.current_step = 0 self.step_current = 0 self.steps = 0 self.canvas = None self.tips = None self.frames = None self.spy_window = None self.widgets = None self.dockwidgets = None self.decoration = None self.run = None self.is_tour_set = False # Widgets self.canvas = FadingCanvas(self.parent, self.opacity_canvas, self.duration_canvas, self.easing_curve, self.color) self.tips = FadingTipBox(self.parent, self.opacity_tips, self.duration_tips, self.easing_curve) # Widgets setup # Needed to fix issue #2204 self.setAttribute(Qt.WA_TransparentForMouseEvents) # Signals and slots self.tips.button_next.clicked.connect(self.next_step) self.tips.button_previous.clicked.connect(self.previous_step) self.tips.button_close.clicked.connect(self.close_tour) self.tips.button_run.clicked.connect(self.run_code) self.tips.button_home.clicked.connect(self.first_step) self.tips.button_end.clicked.connect(self.last_step) self.tips.button_run.clicked.connect( lambda: self.tips.button_run.setDisabled(True)) self.tips.combo_title.currentIndexChanged.connect(self.go_to_step) # Main window move or resize self.parent.sig_resized.connect(self._resized) self.parent.sig_moved.connect(self._moved) # To capture the arrow keys that allow moving the tour self.tips.sig_key_pressed.connect(self._key_pressed)
def get_std_icon(name, size=None): """Get standard platform icon Call 'show_std_icons()' for details""" if not name.startswith('SP_'): name = 'SP_' + name icon = QWidget().style().standardIcon(getattr(QStyle, name)) if size is None: return icon else: return QIcon(icon.pixmap(size, size))
def keyPressEvent(self, event): """Reimplemented to handle key events""" ctrl = event.modifiers() & Qt.ControlModifier shift = event.modifiers() & Qt.ShiftModifier if event.key() in (Qt.Key_Enter, Qt.Key_Return): self.find.emit() elif event.key() == Qt.Key_F and ctrl and shift: # Toggle find widgets self.parent().toggle_visibility.emit(not self.isVisible()) else: QWidget.keyPressEvent(self, event)
def __init__(self, parent, statusbar): QWidget.__init__(self, parent) self.label_font = font = get_font('editor') font.setPointSize(self.font().pointSize()) font.setBold(True) layout = QHBoxLayout() layout.setContentsMargins(0, 0, 0, 0) self.setLayout(layout) statusbar.addPermanentWidget(self)
def __init__(self, parent=None, name_filters=['*.py', '*.pyw'], show_all=False, show_cd_only=None, show_icontext=True): QWidget.__init__(self, parent) self.treewidget = ExplorerTreeWidget(self, show_cd_only=show_cd_only) self.treewidget.setup(name_filters=name_filters, show_all=show_all) self.treewidget.chdir(getcwd()) icontext_action = create_action(self, _("Show icons and text"), toggled=self.toggle_icontext) self.treewidget.common_actions += [None, icontext_action] # Setup toolbar self.toolbar = QToolBar(self) self.toolbar.setIconSize(QSize(16, 16)) self.previous_action = create_action(self, text=_("Previous"), icon=ima.icon('ArrowBack'), triggered=self.treewidget.go_to_previous_directory) self.toolbar.addAction(self.previous_action) self.previous_action.setEnabled(False) self.treewidget.set_previous_enabled.connect( self.previous_action.setEnabled) self.next_action = create_action(self, text=_("Next"), icon=ima.icon('ArrowForward'), triggered=self.treewidget.go_to_next_directory) self.toolbar.addAction(self.next_action) self.next_action.setEnabled(False) self.treewidget.set_next_enabled.connect(self.next_action.setEnabled) parent_action = create_action(self, text=_("Parent"), icon=ima.icon('ArrowUp'), triggered=self.treewidget.go_to_parent_directory) self.toolbar.addAction(parent_action) self.toolbar.addSeparator() options_action = create_action(self, text='', tip=_('Options'), icon=ima.icon('tooloptions')) self.toolbar.addAction(options_action) widget = self.toolbar.widgetForAction(options_action) widget.setPopupMode(QToolButton.InstantPopup) menu = QMenu(self) add_actions(menu, self.treewidget.common_actions) options_action.setMenu(menu) icontext_action.setChecked(show_icontext) self.toggle_icontext(show_icontext) vlayout = QVBoxLayout() vlayout.addWidget(self.toolbar) vlayout.addWidget(self.treewidget) self.setLayout(vlayout)
def __init__(self, parent): self.tabwidget = None self.menu_actions = None self.dockviewer = None self.wrap_action = None self.editors = [] self.filenames = [] self.icons = [] if PYQT5: SpyderPluginWidget.__init__(self, parent, main = parent) else: SpyderPluginWidget.__init__(self, parent) # Initialize plugin self.initialize_plugin() self.set_default_color_scheme() layout = QVBoxLayout() self.tabwidget = Tabs(self, self.menu_actions) self.tabwidget.currentChanged.connect(self.refresh_plugin) self.tabwidget.move_data.connect(self.move_tab) if sys.platform == 'darwin': tab_container = QWidget() tab_container.setObjectName('tab-container') tab_layout = QHBoxLayout(tab_container) tab_layout.setContentsMargins(0, 0, 0, 0) tab_layout.addWidget(self.tabwidget) layout.addWidget(tab_container) else: layout.addWidget(self.tabwidget) self.tabwidget.setStyleSheet("QTabWidget::pane {border: 0;}") # Menu as corner widget options_button = create_toolbutton(self, text=_('Options'), icon=ima.icon('tooloptions')) options_button.setPopupMode(QToolButton.InstantPopup) menu = QMenu(self) add_actions(menu, self.menu_actions) options_button.setMenu(menu) self.tabwidget.setCornerWidget(options_button) # Find/replace widget self.find_widget = FindReplace(self) self.find_widget.hide() self.register_widget_shortcuts("Editor", self.find_widget) layout.addWidget(self.find_widget) self.setLayout(layout)
def show(self): """Overrides Qt Method""" QWidget.show(self) self.visibility_changed.emit(True) if self.editor is not None: text = self.editor.get_selected_text() if len(text) > 0: self.search_text.setEditText(text) self.search_text.lineEdit().selectAll() self.refresh() else: self.search_text.lineEdit().selectAll() self.search_text.setFocus()
def __init__(self, parent): QWidget.__init__(self, parent) self.webview = FrameWebView(self) self.find_widget = FindReplace(self) self.find_widget.set_editor(self.webview) self.find_widget.hide() layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.webview) layout.addWidget(self.find_widget) self.setLayout(layout)
def __init__(self, parent): QWidget.__init__(self, parent) self.setWindowTitle("Breakpoints") self.dictwidget = BreakpointTableView(self, self._load_all_breakpoints()) layout = QVBoxLayout() layout.addWidget(self.dictwidget) self.setLayout(layout) self.dictwidget.clear_all_breakpoints.connect(lambda: self.clear_all_breakpoints.emit()) self.dictwidget.clear_breakpoint.connect(lambda s1, lino: self.clear_breakpoint.emit(s1, lino)) self.dictwidget.edit_goto.connect(lambda s1, lino, s2: self.edit_goto.emit(s1, lino, s2)) self.dictwidget.set_or_edit_conditional_breakpoint.connect( lambda: self.set_or_edit_conditional_breakpoint.emit() )
def create_lineedit(self, text, option, default=NoDefault, tip=None, alignment=Qt.Vertical): label = QLabel(text) label.setWordWrap(True) edit = QLineEdit() layout = QVBoxLayout() if alignment == Qt.Vertical else QHBoxLayout() layout.addWidget(label) layout.addWidget(edit) layout.setContentsMargins(0, 0, 0, 0) if tip: edit.setToolTip(tip) self.lineedits[edit] = (option, default) widget = QWidget(self) widget.setLayout(layout) return widget
def __init__(self, datalist, comment="", parent=None): QWidget.__init__(self, parent) layout = QVBoxLayout() self.tabwidget = QTabWidget() layout.addWidget(self.tabwidget) self.setLayout(layout) self.widgetlist = [] for data, title, comment in datalist: if len(data[0])==3: widget = FormComboWidget(data, comment=comment, parent=self) else: widget = FormWidget(data, comment=comment, parent=self) index = self.tabwidget.addTab(widget, title) self.tabwidget.setTabToolTip(index, comment) self.widgetlist.append(widget)
def __init__(self, data, comment="", parent=None): QWidget.__init__(self, parent) from copy import deepcopy self.data = deepcopy(data) self.widgets = [] self.formlayout = QFormLayout(self) if comment: self.formlayout.addRow(QLabel(comment)) self.formlayout.addRow(QLabel(" ")) if DEBUG_FORMLAYOUT: print("\n"+("*"*80)) print("DATA:", self.data) print("*"*80) print("COMMENT:", comment) print("*"*80)
def __init__(self, parent): QWidget.__init__(self, parent) SpyderPluginMixin.__init__(self, parent) # Widgets self.stack = QStackedWidget(self) self.shellwidgets = {} # Layout layout = QVBoxLayout() layout.addWidget(self.stack) self.setLayout(layout) # Initialize plugin self.initialize_plugin()
def __init__(self, parent): QWidget.__init__(self, parent=parent) self.setWindowTitle("Example") # Widgets self.button = QPushButton('Current editor') self.table = QTableWidget(self) # Widget setup self.button.setIcon(ima.icon('spyder')) # Layouts layout = QVBoxLayout() layout.addWidget(self.button) layout.addWidget(self.table) self.setLayout(layout)
def set_corner_widgets(self, corner_widgets): """ Set tabs corner widgets corner_widgets: dictionary of (corner, widgets) corner: Qt.TopLeftCorner or Qt.TopRightCorner widgets: list of widgets (may contains integers to add spacings) """ assert isinstance(corner_widgets, dict) assert all(key in (Qt.TopLeftCorner, Qt.TopRightCorner) for key in corner_widgets) self.corner_widgets.update(corner_widgets) for corner, widgets in list(self.corner_widgets.items()): cwidget = QWidget() cwidget.hide() prev_widget = self.cornerWidget(corner) if prev_widget: prev_widget.close() self.setCornerWidget(cwidget, corner) clayout = QHBoxLayout() clayout.setContentsMargins(0, 0, 0, 0) for widget in widgets: if isinstance(widget, int): clayout.addSpacing(widget) else: clayout.addWidget(widget) cwidget.setLayout(clayout) cwidget.show()
def __init__(self, parent, search_text, search_text_regexp, search_path, include, include_idx, include_regexp, exclude, exclude_idx, exclude_regexp, supported_encodings, in_python_path, more_options): QWidget.__init__(self, parent) if search_path is None: search_path = getcwd() if not isinstance(search_text, (list, tuple)): search_text = [search_text] if not isinstance(search_path, (list, tuple)): search_path = [search_path] if not isinstance(include, (list, tuple)): include = [include] if not isinstance(exclude, (list, tuple)): exclude = [exclude] self.supported_encodings = supported_encodings # Layout 1 hlayout1 = QHBoxLayout() self.search_text = PatternComboBox(self, search_text, _("Search pattern")) self.edit_regexp = create_toolbutton(self, icon=get_icon("advanced.png"), tip=_("Regular expression")) self.edit_regexp.setCheckable(True) self.edit_regexp.setChecked(search_text_regexp) self.more_widgets = () self.more_options = create_toolbutton(self, toggled=self.toggle_more_options) self.more_options.setCheckable(True) self.more_options.setChecked(more_options) self.ok_button = create_toolbutton( self, text=_("Search"), icon=get_std_icon("DialogApplyButton"), triggered=lambda: self.emit(SIGNAL('find()')), tip=_("Start search"), text_beside_icon=True) self.connect(self.ok_button, SIGNAL('clicked()'), self.update_combos) self.stop_button = create_toolbutton( self, text=_("Stop"), icon=get_icon("stop.png"), triggered=lambda: self.emit(SIGNAL('stop()')), tip=_("Stop search"), text_beside_icon=True) self.stop_button.setEnabled(False) for widget in [ self.search_text, self.edit_regexp, self.ok_button, self.stop_button, self.more_options ]: hlayout1.addWidget(widget) # Layout 2 hlayout2 = QHBoxLayout() self.include_pattern = PatternComboBox(self, include, _("Included filenames pattern")) if include_idx is not None and include_idx >= 0 \ and include_idx < self.include_pattern.count(): self.include_pattern.setCurrentIndex(include_idx) self.include_regexp = create_toolbutton(self, icon=get_icon("advanced.png"), tip=_("Regular expression")) self.include_regexp.setCheckable(True) self.include_regexp.setChecked(include_regexp) include_label = QLabel(_("Include:")) include_label.setBuddy(self.include_pattern) self.exclude_pattern = PatternComboBox(self, exclude, _("Excluded filenames pattern")) if exclude_idx is not None and exclude_idx >= 0 \ and exclude_idx < self.exclude_pattern.count(): self.exclude_pattern.setCurrentIndex(exclude_idx) self.exclude_regexp = create_toolbutton(self, icon=get_icon("advanced.png"), tip=_("Regular expression")) self.exclude_regexp.setCheckable(True) self.exclude_regexp.setChecked(exclude_regexp) exclude_label = QLabel(_("Exclude:")) exclude_label.setBuddy(self.exclude_pattern) for widget in [ include_label, self.include_pattern, self.include_regexp, exclude_label, self.exclude_pattern, self.exclude_regexp ]: hlayout2.addWidget(widget) # Layout 3 hlayout3 = QHBoxLayout() self.python_path = QRadioButton(_("PYTHONPATH"), self) self.python_path.setChecked(in_python_path) self.python_path.setToolTip( _("Search in all directories listed in sys.path which" " are outside the Python installation directory")) self.hg_manifest = QRadioButton(_("Hg repository"), self) self.detect_hg_repository() self.hg_manifest.setToolTip( _("Search in current directory hg repository")) self.custom_dir = QRadioButton(_("Here:"), self) self.custom_dir.setChecked(not in_python_path) self.dir_combo = PathComboBox(self) self.dir_combo.addItems(search_path) self.dir_combo.setToolTip(_("Search recursively in this directory")) self.connect(self.dir_combo, SIGNAL("open_dir(QString)"), self.set_directory) self.connect(self.python_path, SIGNAL('toggled(bool)'), self.dir_combo.setDisabled) self.connect(self.hg_manifest, SIGNAL('toggled(bool)'), self.dir_combo.setDisabled) browse = create_toolbutton(self, icon=get_std_icon('DirOpenIcon'), tip=_('Browse a search directory'), triggered=self.select_directory) for widget in [ self.python_path, self.hg_manifest, self.custom_dir, self.dir_combo, browse ]: hlayout3.addWidget(widget) self.connect(self.search_text, SIGNAL("valid(bool)"), lambda valid: self.emit(SIGNAL('find()'))) self.connect(self.include_pattern, SIGNAL("valid(bool)"), lambda valid: self.emit(SIGNAL('find()'))) self.connect(self.exclude_pattern, SIGNAL("valid(bool)"), lambda valid: self.emit(SIGNAL('find()'))) self.connect(self.dir_combo, SIGNAL("valid(bool)"), lambda valid: self.emit(SIGNAL('find()'))) vlayout = QVBoxLayout() vlayout.setContentsMargins(0, 0, 0, 0) vlayout.addLayout(hlayout1) vlayout.addLayout(hlayout2) vlayout.addLayout(hlayout3) self.more_widgets = (hlayout2, hlayout3) self.toggle_more_options(more_options) self.setLayout(vlayout) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
def __init__(self, parent, enable_replace=False): QWidget.__init__(self, parent) self.enable_replace = enable_replace self.editor = None self.is_code_editor = None glayout = QGridLayout() glayout.setContentsMargins(0, 0, 0, 0) self.setLayout(glayout) self.close_button = create_toolbutton( self, triggered=self.hide, icon=ima.icon('DialogCloseButton')) glayout.addWidget(self.close_button, 0, 0) # Find layout self.search_text = PatternComboBox(self, tip=_("Search string"), adjust_to_minimum=False) self.search_text.valid.connect(lambda state: self.find( changed=False, forward=True, rehighlight=False)) self.search_text.lineEdit().textEdited.connect( self.text_has_been_edited) self.previous_button = create_toolbutton(self, triggered=self.find_previous, icon=ima.icon('ArrowUp')) self.next_button = create_toolbutton(self, triggered=self.find_next, icon=ima.icon('ArrowDown')) self.next_button.clicked.connect(self.update_search_combo) self.previous_button.clicked.connect(self.update_search_combo) self.re_button = create_toolbutton(self, icon=ima.icon('advanced'), tip=_("Regular expression")) self.re_button.setCheckable(True) self.re_button.toggled.connect(lambda state: self.find()) self.case_button = create_toolbutton(self, icon=get_icon("upper_lower.png"), tip=_("Case Sensitive")) self.case_button.setCheckable(True) self.case_button.toggled.connect(lambda state: self.find()) self.words_button = create_toolbutton(self, icon=get_icon("whole_words.png"), tip=_("Whole words")) self.words_button.setCheckable(True) self.words_button.toggled.connect(lambda state: self.find()) self.highlight_button = create_toolbutton( self, icon=get_icon("highlight.png"), tip=_("Highlight matches")) self.highlight_button.setCheckable(True) self.highlight_button.toggled.connect(self.toggle_highlighting) hlayout = QHBoxLayout() self.widgets = [ self.close_button, self.search_text, self.previous_button, self.next_button, self.re_button, self.case_button, self.words_button, self.highlight_button ] for widget in self.widgets[1:]: hlayout.addWidget(widget) glayout.addLayout(hlayout, 0, 1) # Replace layout replace_with = QLabel(_("Replace with:")) self.replace_text = PatternComboBox(self, adjust_to_minimum=False, tip=_('Replace string')) self.replace_button = create_toolbutton( self, text=_('Replace/find'), icon=ima.icon('DialogApplyButton'), triggered=self.replace_find, text_beside_icon=True) self.replace_button.clicked.connect(self.update_replace_combo) self.replace_button.clicked.connect(self.update_search_combo) self.all_check = QCheckBox(_("Replace all")) self.replace_layout = QHBoxLayout() widgets = [ replace_with, self.replace_text, self.replace_button, self.all_check ] for widget in widgets: self.replace_layout.addWidget(widget) glayout.addLayout(self.replace_layout, 1, 1) self.widgets.extend(widgets) self.replace_widgets = widgets self.hide_replace() self.search_text.setTabOrder(self.search_text, self.replace_text) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) self.shortcuts = self.create_shortcuts(parent) self.highlight_timer = QTimer(self) self.highlight_timer.setSingleShot(True) self.highlight_timer.setInterval(1000) self.highlight_timer.timeout.connect(self.highlight_matches)
def __init__(self, parent): QWidget.__init__(self, parent) self.setWindowTitle("Line profiler") self.output = None self.error_output = None self.use_colors = True self._last_wdir = None self._last_args = None self._last_pythonpath = None self.filecombo = PythonModulesComboBox(self) self.start_button = create_toolbutton(self, icon=get_icon('run.png'), text=_("Profile by line"), tip=_("Run line profiler"), triggered=self.start, text_beside_icon=True) self.stop_button = create_toolbutton(self, icon=get_icon('terminate.png'), text=_("Stop"), tip=_("Stop current profiling"), text_beside_icon=True) self.connect(self.filecombo, SIGNAL('valid(bool)'), self.start_button.setEnabled) #self.connect(self.filecombo, SIGNAL('valid(bool)'), self.show_data) # FIXME: The combobox emits this signal on almost any event # triggering show_data() too early, too often. browse_button = create_toolbutton(self, icon=get_icon('fileopen.png'), tip=_('Select Python script'), triggered=self.select_file) self.datelabel = QLabel() self.log_button = create_toolbutton(self, icon=get_icon('log.png'), text=_("Output"), text_beside_icon=True, tip=_("Show program's output"), triggered=self.show_log) self.datatree = LineProfilerDataTree(self) self.collapse_button = create_toolbutton( self, icon=get_icon('collapse.png'), triggered=lambda dD=-1: self.datatree.collapseAll(), tip=_('Collapse all')) self.expand_button = create_toolbutton( self, icon=get_icon('expand.png'), triggered=lambda dD=1: self.datatree.expandAll(), tip=_('Expand all')) hlayout1 = QHBoxLayout() hlayout1.addWidget(self.filecombo) hlayout1.addWidget(browse_button) hlayout1.addWidget(self.start_button) hlayout1.addWidget(self.stop_button) hlayout2 = QHBoxLayout() hlayout2.addWidget(self.collapse_button) hlayout2.addWidget(self.expand_button) hlayout2.addStretch() hlayout2.addWidget(self.datelabel) hlayout2.addStretch() hlayout2.addWidget(self.log_button) layout = QVBoxLayout() layout.addLayout(hlayout1) layout.addLayout(hlayout2) layout.addWidget(self.datatree) self.setLayout(layout) self.process = None self.set_running_state(False) self.start_button.setEnabled(False) if not is_lineprofiler_installed(): for widget in (self.datatree, self.filecombo, self.log_button, self.start_button, self.stop_button, browse_button, self.collapse_button, self.expand_button): widget.setDisabled(True) text = _( '<b>Please install the <a href="%s">line_profiler module</a></b>' ) % WEBSITE_URL self.datelabel.setText(text) self.datelabel.setOpenExternalLinks(True) else: pass # self.show_data()
def __init__(self, parent=None): QWidget.__init__(self, parent) self.home_url = None self.webview = WebView(self) self.webview.loadFinished.connect(self.load_finished) self.webview.titleChanged.connect(self.setWindowTitle) self.webview.urlChanged.connect(self.url_changed) home_button = create_toolbutton(self, icon=ima.icon('home'), tip=_("Home"), triggered=self.go_home) zoom_out_button = action2button(self.webview.zoom_out_action) zoom_in_button = action2button(self.webview.zoom_in_action) pageact2btn = lambda prop: action2button(self.webview.pageAction(prop), parent=self.webview) refresh_button = pageact2btn(QWebPage.Reload) stop_button = pageact2btn(QWebPage.Stop) previous_button = pageact2btn(QWebPage.Back) next_button = pageact2btn(QWebPage.Forward) stop_button.setEnabled(False) self.webview.loadStarted.connect(lambda: stop_button.setEnabled(True)) self.webview.loadFinished.connect( lambda: stop_button.setEnabled(False)) progressbar = QProgressBar(self) progressbar.setTextVisible(False) progressbar.hide() self.webview.loadStarted.connect(progressbar.show) self.webview.loadProgress.connect(progressbar.setValue) self.webview.loadFinished.connect(lambda _state: progressbar.hide()) label = QLabel(self.get_label()) self.url_combo = UrlComboBox(self) self.url_combo.valid.connect(self.url_combo_activated) self.webview.iconChanged.connect(self.icon_changed) self.find_widget = FindReplace(self) self.find_widget.set_editor(self.webview) self.find_widget.hide() find_button = create_toolbutton(self, icon=ima.icon('find'), tip=_("Find text"), toggled=self.toggle_find_widget) self.find_widget.visibility_changed.connect(find_button.setChecked) hlayout = QHBoxLayout() for widget in (previous_button, next_button, home_button, find_button, label, self.url_combo, zoom_out_button, zoom_in_button, refresh_button, progressbar, stop_button): hlayout.addWidget(widget) layout = QVBoxLayout() layout.addLayout(hlayout) layout.addWidget(self.webview) layout.addWidget(self.find_widget) self.setLayout(layout)
def __init__(self, parent, text): QWidget.__init__(self, parent) self.text_editor = QTextEdit(self) self.text_editor.setText(text) self.text_editor.setReadOnly(True) # Type frame type_layout = QHBoxLayout() type_label = QLabel(_("Import as")) type_layout.addWidget(type_label) data_btn = QRadioButton(_("data")) data_btn.setChecked(True) self._as_data = True type_layout.addWidget(data_btn) code_btn = QRadioButton(_("code")) self._as_code = False type_layout.addWidget(code_btn) txt_btn = QRadioButton(_("text")) type_layout.addWidget(txt_btn) h_spacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) type_layout.addItem(h_spacer) type_frame = QFrame() type_frame.setLayout(type_layout) # Opts frame grid_layout = QGridLayout() grid_layout.setSpacing(0) col_label = QLabel(_("Column separator:")) grid_layout.addWidget(col_label, 0, 0) col_w = QWidget() col_btn_layout = QHBoxLayout() self.tab_btn = QRadioButton(_("Tab")) self.tab_btn.setChecked(False) col_btn_layout.addWidget(self.tab_btn) other_btn_col = QRadioButton(_("other")) other_btn_col.setChecked(True) col_btn_layout.addWidget(other_btn_col) col_w.setLayout(col_btn_layout) grid_layout.addWidget(col_w, 0, 1) self.line_edt = QLineEdit(",") self.line_edt.setMaximumWidth(30) self.line_edt.setEnabled(True) other_btn_col.toggled.connect(self.line_edt.setEnabled) grid_layout.addWidget(self.line_edt, 0, 2) row_label = QLabel(_("Row separator:")) grid_layout.addWidget(row_label, 1, 0) row_w = QWidget() row_btn_layout = QHBoxLayout() self.eol_btn = QRadioButton(_("EOL")) self.eol_btn.setChecked(True) row_btn_layout.addWidget(self.eol_btn) other_btn_row = QRadioButton(_("other")) row_btn_layout.addWidget(other_btn_row) row_w.setLayout(row_btn_layout) grid_layout.addWidget(row_w, 1, 1) self.line_edt_row = QLineEdit(";") self.line_edt_row.setMaximumWidth(30) self.line_edt_row.setEnabled(False) other_btn_row.toggled.connect(self.line_edt_row.setEnabled) grid_layout.addWidget(self.line_edt_row, 1, 2) grid_layout.setRowMinimumHeight(2, 15) other_group = QGroupBox(_("Additional options")) other_layout = QGridLayout() other_group.setLayout(other_layout) skiprows_label = QLabel(_("Skip rows:")) other_layout.addWidget(skiprows_label, 0, 0) self.skiprows_edt = QLineEdit('0') self.skiprows_edt.setMaximumWidth(30) intvalid = QIntValidator(0, len(to_text_string(text).splitlines()), self.skiprows_edt) self.skiprows_edt.setValidator(intvalid) other_layout.addWidget(self.skiprows_edt, 0, 1) other_layout.setColumnMinimumWidth(2, 5) comments_label = QLabel(_("Comments:")) other_layout.addWidget(comments_label, 0, 3) self.comments_edt = QLineEdit('#') self.comments_edt.setMaximumWidth(30) other_layout.addWidget(self.comments_edt, 0, 4) self.trnsp_box = QCheckBox(_("Transpose")) #self.trnsp_box.setEnabled(False) other_layout.addWidget(self.trnsp_box, 1, 0, 2, 0) grid_layout.addWidget(other_group, 3, 0, 2, 0) opts_frame = QFrame() opts_frame.setLayout(grid_layout) data_btn.toggled.connect(opts_frame.setEnabled) data_btn.toggled.connect(self.set_as_data) code_btn.toggled.connect(self.set_as_code) # self.connect(txt_btn, SIGNAL("toggled(bool)"), # self, SLOT("is_text(bool)")) # Final layout layout = QVBoxLayout() layout.addWidget(type_frame) layout.addWidget(self.text_editor) layout.addWidget(opts_frame) self.setLayout(layout)
def __init__(self, parent=None): QWidget.__init__(self, parent) self.current_radio = None self.dedicated_radio = None self.systerm_radio = None self.runconf = RunConfiguration() firstrun_o = CONF.get('run', ALWAYS_OPEN_FIRST_RUN_OPTION, False) # --- General settings ---- common_group = QGroupBox(_("General settings")) common_layout = QGridLayout() common_group.setLayout(common_layout) self.clo_cb = QCheckBox(_("Command line options:")) common_layout.addWidget(self.clo_cb, 0, 0) self.clo_edit = QLineEdit() self.clo_cb.toggled.connect(self.clo_edit.setEnabled) self.clo_edit.setEnabled(False) common_layout.addWidget(self.clo_edit, 0, 1) self.wd_cb = QCheckBox(_("Working directory:")) common_layout.addWidget(self.wd_cb, 1, 0) wd_layout = QHBoxLayout() self.wd_edit = QLineEdit() self.wd_cb.toggled.connect(self.wd_edit.setEnabled) self.wd_edit.setEnabled(False) wd_layout.addWidget(self.wd_edit) browse_btn = QPushButton(ima.icon('DirOpenIcon'), '', self) browse_btn.setToolTip(_("Select directory")) browse_btn.clicked.connect(self.select_directory) wd_layout.addWidget(browse_btn) common_layout.addLayout(wd_layout, 1, 1) self.post_mortem_cb = QCheckBox( _("Enter debugging mode when " "errors appear during execution")) common_layout.addWidget(self.post_mortem_cb) # --- Interpreter --- interpreter_group = QGroupBox(_("Console")) interpreter_layout = QVBoxLayout() interpreter_group.setLayout(interpreter_layout) self.current_radio = QRadioButton(CURRENT_INTERPRETER) interpreter_layout.addWidget(self.current_radio) self.dedicated_radio = QRadioButton(DEDICATED_INTERPRETER) interpreter_layout.addWidget(self.dedicated_radio) self.systerm_radio = QRadioButton(SYSTERM_INTERPRETER) interpreter_layout.addWidget(self.systerm_radio) # --- Dedicated interpreter --- new_group = QGroupBox(_("Dedicated Python console")) self.current_radio.toggled.connect(new_group.setDisabled) new_layout = QGridLayout() new_group.setLayout(new_layout) self.interact_cb = QCheckBox( _("Interact with the Python " "console after execution")) new_layout.addWidget(self.interact_cb, 1, 0, 1, -1) self.show_kill_warning_cb = QCheckBox( _("Show warning when killing" " running process")) new_layout.addWidget(self.show_kill_warning_cb, 2, 0, 1, -1) self.pclo_cb = QCheckBox(_("Command line options:")) new_layout.addWidget(self.pclo_cb, 3, 0) self.pclo_edit = QLineEdit() self.pclo_cb.toggled.connect(self.pclo_edit.setEnabled) self.pclo_edit.setEnabled(False) self.pclo_edit.setToolTip( _("<b>-u</b> is added to the " "other options you set here")) new_layout.addWidget(self.pclo_edit, 3, 1) # Checkbox to preserve the old behavior, i.e. always open the dialog # on first run hline = QFrame() hline.setFrameShape(QFrame.HLine) hline.setFrameShadow(QFrame.Sunken) self.firstrun_cb = QCheckBox(ALWAYS_OPEN_FIRST_RUN % _("this dialog")) self.firstrun_cb.clicked.connect(self.set_firstrun_o) self.firstrun_cb.setChecked(firstrun_o) layout = QVBoxLayout() layout.addWidget(interpreter_group) layout.addWidget(common_group) layout.addWidget(new_group) layout.addWidget(hline) layout.addWidget(self.firstrun_cb) self.setLayout(layout)
def __init__(self, parent, max_entries=100): "Initialize Various list objects before assignment" displaylist = [] displaynamelist = [] infixmod = [] infixlist = [] desclist = [] parameternamelist = [] parameterdesclist = [] parameterstringlist = [] paramcountlist = [] buttonlist = [] xmldoc = minidom.parse('C:\\Users\\Jayit\\.spyder2\\ratelaw2_0_3.xml') #xmldoc = minidom.parse('%\\Downloads\\ratelaw2_0_3.xml') lawlistxml = xmldoc.getElementsByTagName('law') o = 0 for s in lawlistxml: o = o + 1 parameternamelistlist = [0 for x in range(o)] parameterdesclistlist = [0 for x in range(o)] """i is the number of laws currently in the xml file""" i = 0 """ Parsing xml: Acquiring rate law name, description, and list of parameter information """ for s in lawlistxml: #RATE_LAW_MESSAGE += s.getAttribute('displayName') + "\n" """Gets Latec Expression""" displaylist.append(s.getAttribute('display')) """Gets Rate-Law Name""" displaynamelist.append(s.getAttribute('displayName')) """"Gets Raw Rate-Law expression""" infixlist.append(s.getAttribute('infixExpression')) """Gets description statement""" desclist.append(s.getAttribute('description')) """Gets listOfParameters Object""" parameterlist = s.getElementsByTagName('listOfParameters')[0] """Gets a list of parameters within ListOfParameters object""" parameters = parameterlist.getElementsByTagName('parameter') for param in parameters: parameternamelist.append(param.attributes['name'].value) #print(param.attributes['name'].value) parameterdesclist.append(param.attributes['description'].value) parameternamelistlist[i] = parameternamelist #print("break") parameterdesclistlist[i] = parameterdesclist parameternamelist = [] parameterdesclist = [] i = i + 1 SLElistlist = [0 for x in range(i)] PLElistlist = [0 for x in range(i)] ILElistlist = [0 for x in range(i)] paramLElistlist = [0 for x in range(i)] numlistlist = [0 for x in range(i)] QWidget.__init__(self, parent) self.setWindowTitle("Rate Law Library") self.output = None self.error_output = None self._last_wdir = None self._last_args = None self._last_pythonpath = None #self.textlabel = QLabel(RATE_LAW_MESSAGE) self.lawlist = QListWidget() self.lawpage = QStackedWidget() index = 0 for j in range(i): item = QListWidgetItem(displaynamelist[j]) self.lawlist.addItem(item) self.lawdetailpage = QWidget() setup_group = QGroupBox(displaynamelist[j]) infixmod.append(infixlist[j].replace("___", " ")) setup_label = QLabel(infixmod[j]) setup_label.setWordWrap(True) desc_group = QGroupBox("Description") desc_label = QLabel(desclist[j]) desc_label.setWordWrap(True) param_label = QGridLayout() nm = QLabel("Name:") des = QLabel("Description:") repl = QLabel("Replace with:") param_label.addWidget(nm, 0, 0) param_label.addWidget(des, 0, 1) param_label.addWidget(repl, 0, 2) """g is the total number of alterable values""" g = 0 """t is the total number of alterable non-parameters""" t = 1 snum = 0 pnum = 0 inum = 0 """range of N is the max number of possible substrates OR products""" N = 5 for n in range(N): nl = n + 1 if (infixmod[j].find('S%s' % nl) > -1): z = QLabel('S%s is present' % nl) param_label.addWidget(z, t, 0) snum = snum + 1 t = t + 1 for n in range(N): nl = n + 1 if (infixmod[j].find('P%s' % nl) > -1): z = QLabel('P%s is present' % nl) param_label.addWidget(z, t, 0) pnum = pnum + 1 t = t + 1 for n in range(N): nl = n + 1 if (infixmod[j].find('I%s' % nl) > -1): z = QLabel('I%s is present' % nl) param_label.addWidget(z, t, 0) inum = inum + 1 t = t + 1 """Initialize lists of list of parameter lineedit""" length = len(parameternamelistlist[j]) for b in range(length): p = QLabel("%s :" % parameternamelistlist[j][b]) param_label.addWidget(p, b + t, 0) d = QLabel("'%s'" % parameterdesclistlist[j][b]) param_label.addWidget(d, b + t, 1) g = t + length Slineeditlist = [0 for x in range(snum)] Plineeditlist = [0 for x in range(pnum)] Ilineeditlist = [0 for x in range(inum)] paramlineeditlist = [0 for x in range(length)] editcount = 1 """Place lineedit widgets for parameters""" for s in range(snum): Slineeditlist[s] = QLineEdit() param_label.addWidget(Slineeditlist[s], editcount, 2) editcount = editcount + 1 SLElistlist[j] = Slineeditlist for s in range(pnum): Plineeditlist[s] = QLineEdit() param_label.addWidget(Plineeditlist[s], editcount, 2) editcount = editcount + 1 PLElistlist[j] = Plineeditlist for s in range(inum): Ilineeditlist[s] = QLineEdit() param_label.addWidget(Ilineeditlist[s], editcount, 2) editcount = editcount + 1 ILElistlist[j] = Ilineeditlist for s in range(length): paramlineeditlist[s] = QLineEdit() param_label.addWidget(paramlineeditlist[s], editcount, 2) editcount = editcount + 1 paramLElistlist[j] = paramlineeditlist """Necessary lists for editable parameters. Housekeeping essentially.""" stuff = paramlineeditlist[0].text() numlistlist[j] = [snum, pnum, inum, length] charlist = ["S", "P", "I"] buttonlist.append(QPushButton(self)) buttonlist[j].setText("Insert Rate Law: %s" % displaynamelist[j]) # Warning: do not try to regroup the following QLabel contents with # widgets above -- this string was isolated here in a single QLabel # on purpose: to fix Issue 863 """Page formatting""" setup_layout = QVBoxLayout() setup_layout.addWidget(setup_label) setup_group.setLayout(setup_layout) desc_group.setLayout(param_label) vlayout = QVBoxLayout() vlayout.addWidget(setup_group) vlayout.addWidget(desc_group) vlayout.addWidget(buttonlist[j]) vlayout.addStretch(1) self.lawdetailpage.setLayout(vlayout) self.lawpage.addWidget(self.lawdetailpage) """Set up button functionality""" for k in range(47): buttonlist[k].clicked.connect( pressbutton(self, infixmod[k], SLElistlist[k], PLElistlist[k], ILElistlist[k], paramLElistlist[k], parameternamelistlist[k], numlistlist[k], charlist, k)) self.lawlist.currentRowChanged.connect(self.lawpage.setCurrentIndex) self.lawlist.setCurrentRow(0) """Set up high-level widget formatting.""" hsplitter = QSplitter() hsplitter.addWidget(self.lawlist) hsplitter.addWidget(self.lawpage) layout = QVBoxLayout() layout.addWidget(hsplitter) self.setLayout(layout)
def __init__(self, parent): QWidget.__init__(self, parent) SpyderPluginMixin.__init__(self, parent)
def __init__(self, parent, max_entries=100): QWidget.__init__(self, parent) self.setWindowTitle("Profiler") self.output = None self.error_output = None self._last_wdir = None self._last_args = None self._last_pythonpath = None self.filecombo = PythonModulesComboBox(self) self.start_button = create_toolbutton(self, icon=get_icon('run.png'), text=_("Profile"), tip=_("Run profiler"), triggered=lambda: self.start(), text_beside_icon=True) self.stop_button = create_toolbutton(self, icon=get_icon('stop.png'), text=_("Stop"), tip=_("Stop current profiling"), text_beside_icon=True) self.filecombo.valid.connect(self.start_button.setEnabled) #self.connect(self.filecombo, SIGNAL('valid(bool)'), self.show_data) # FIXME: The combobox emits this signal on almost any event # triggering show_data() too early, too often. browse_button = create_toolbutton(self, icon=get_icon('fileopen.png'), tip=_('Select Python script'), triggered=self.select_file) self.datelabel = QLabel() self.log_button = create_toolbutton(self, icon=get_icon('log.png'), text=_("Output"), text_beside_icon=True, tip=_("Show program's output"), triggered=self.show_log) self.datatree = ProfilerDataTree(self) self.collapse_button = create_toolbutton( self, icon=get_icon('collapse.png'), triggered=lambda dD=-1: self.datatree.change_view(dD), tip=_('Collapse one level up')) self.expand_button = create_toolbutton( self, icon=get_icon('expand.png'), triggered=lambda dD=1: self.datatree.change_view(dD), tip=_('Expand one level down')) self.save_button = create_toolbutton(self, text_beside_icon=True, text=_("Save data"), icon=get_icon('filesave.png'), triggered=self.save_data, tip=_('Save profiling data')) self.load_button = create_toolbutton( self, text_beside_icon=True, text=_("Load data"), icon=get_icon('fileimport.png'), triggered=self.compare, tip=_('Load profiling data for comparison')) self.clear_button = create_toolbutton(self, text_beside_icon=True, text=_("Clear comparison"), icon=get_icon('eraser.png'), triggered=self.clear) hlayout1 = QHBoxLayout() hlayout1.addWidget(self.filecombo) hlayout1.addWidget(browse_button) hlayout1.addWidget(self.start_button) hlayout1.addWidget(self.stop_button) hlayout2 = QHBoxLayout() hlayout2.addWidget(self.collapse_button) hlayout2.addWidget(self.expand_button) hlayout2.addStretch() hlayout2.addWidget(self.datelabel) hlayout2.addStretch() hlayout2.addWidget(self.log_button) hlayout2.addWidget(self.save_button) hlayout2.addWidget(self.load_button) hlayout2.addWidget(self.clear_button) layout = QVBoxLayout() layout.addLayout(hlayout1) layout.addLayout(hlayout2) layout.addWidget(self.datatree) self.setLayout(layout) self.process = None self.set_running_state(False) self.start_button.setEnabled(False) self.clear_button.setEnabled(False) if not is_profiler_installed(): # This should happen only on certain GNU/Linux distributions # or when this a home-made Python build because the Python # profilers are included in the Python standard library for widget in (self.datatree, self.filecombo, self.start_button, self.stop_button): widget.setDisabled(True) url = 'http://docs.python.org/library/profile.html' text = '%s <a href=%s>%s</a>' % (_('Please install'), url, _("the Python profiler modules")) self.datelabel.setText(text) else: pass # self.show_data()
def __init__(self, parent, apply_callback=None): QWidget.__init__(self, parent) self.apply_callback = apply_callback self.is_modified = False
def __init__(self, parent=None, name_filters=['*.py', '*.pyw'], show_all=False, show_cd_only=None, show_icontext=True): QWidget.__init__(self, parent) # Widgets self.treewidget = ExplorerTreeWidget(self, show_cd_only=show_cd_only) button_previous = QToolButton(self) button_next = QToolButton(self) button_parent = QToolButton(self) self.button_menu = QToolButton(self) menu = QMenu(self) self.action_widgets = [ button_previous, button_next, button_parent, self.button_menu ] # Actions icontext_action = create_action(self, _("Show icons and text"), toggled=self.toggle_icontext) previous_action = create_action( self, text=_("Previous"), icon=ima.icon('ArrowBack'), triggered=self.treewidget.go_to_previous_directory) next_action = create_action( self, text=_("Next"), icon=ima.icon('ArrowForward'), triggered=self.treewidget.go_to_next_directory) parent_action = create_action( self, text=_("Parent"), icon=ima.icon('ArrowUp'), triggered=self.treewidget.go_to_parent_directory) options_action = create_action(self, text='', tip=_('Options')) # Setup widgets self.treewidget.setup(name_filters=name_filters, show_all=show_all) self.treewidget.chdir(getcwd()) self.treewidget.common_actions += [None, icontext_action] button_previous.setDefaultAction(previous_action) previous_action.setEnabled(False) button_next.setDefaultAction(next_action) next_action.setEnabled(False) button_parent.setDefaultAction(parent_action) self.button_menu.setIcon(ima.icon('tooloptions')) self.button_menu.setPopupMode(QToolButton.InstantPopup) self.button_menu.setMenu(menu) add_actions(menu, self.treewidget.common_actions) options_action.setMenu(menu) self.toggle_icontext(show_icontext) icontext_action.setChecked(show_icontext) for widget in self.action_widgets: widget.setAutoRaise(True) widget.setIconSize(QSize(16, 16)) # Layouts blayout = QHBoxLayout() blayout.addWidget(button_previous) blayout.addWidget(button_next) blayout.addWidget(button_parent) blayout.addStretch() blayout.addWidget(self.button_menu) layout = QVBoxLayout() layout.addLayout(blayout) layout.addWidget(self.treewidget) self.setLayout(layout) # Signals and slots self.treewidget.set_previous_enabled.connect( previous_action.setEnabled) self.treewidget.set_next_enabled.connect(next_action.setEnabled)
def __init__(self, parent=None, fname=None, wdir=None, history_filename=None, show_icontext=True, light_background=True, menu_actions=None, show_buttons_inside=True, show_elapsed_time=True): QWidget.__init__(self, parent) self.menu_actions = menu_actions self.run_button = None self.kill_button = None self.options_button = None self.icontext_action = None self.show_elapsed_time = show_elapsed_time self.fname = fname if wdir is None: wdir = osp.dirname(osp.abspath(fname)) self.wdir = wdir if osp.isdir(wdir) else None self.arguments = "" self.shell = self.SHELL_CLASS(parent, get_conf_path(history_filename)) self.shell.set_light_background(light_background) self.shell.execute.connect(self.send_to_process) self.shell.sig_keyboard_interrupt.connect(self.keyboard_interrupt) # Redirecting some SIGNALs: self.shell.redirect_stdio.connect( lambda state: self.redirect_stdio.emit(state)) self.state_label = None self.time_label = None vlayout = QVBoxLayout() toolbar_buttons = self.get_toolbar_buttons() if show_buttons_inside: self.state_label = QLabel() hlayout = QHBoxLayout() hlayout.addWidget(self.state_label) hlayout.addStretch(0) hlayout.addWidget(self.create_time_label()) hlayout.addStretch(0) for button in toolbar_buttons: hlayout.addWidget(button) vlayout.addLayout(hlayout) else: vlayout.setContentsMargins(0, 0, 0, 0) vlayout.addWidget(self.get_shell_widget()) self.setLayout(vlayout) self.resize(640, 480) if parent is None: self.setWindowIcon(self.get_icon()) self.setWindowTitle(_("Console")) self.t0 = None self.timer = QTimer(self) self.process = None self.is_closing = False if show_buttons_inside: self.update_time_label_visibility()
def __init__(self, parent, max_entries=100): QWidget.__init__(self, parent) self.setWindowTitle("Pylint") self.output = None self.error_output = None self.max_entries = max_entries self.rdata = [] if osp.isfile(self.DATAPATH): try: data = pickle.loads(open(self.DATAPATH, 'rb').read()) if data[0] == self.VERSION: self.rdata = data[1:] except (EOFError, ImportError): pass self.filecombo = PythonModulesComboBox(self) if self.rdata: self.remove_obsolete_items() self.filecombo.addItems(self.get_filenames()) self.start_button = create_toolbutton(self, icon=ima.icon('run'), text=_("Analyze"), tip=_("Run analysis"), triggered=self.start, text_beside_icon=True) self.stop_button = create_toolbutton(self, icon=ima.icon('stop'), text=_("Stop"), tip=_("Stop current analysis"), text_beside_icon=True) self.filecombo.valid.connect(self.start_button.setEnabled) self.filecombo.valid.connect(self.show_data) browse_button = create_toolbutton(self, icon=ima.icon('fileopen'), tip=_('Select Python file'), triggered=self.select_file) self.ratelabel = QLabel() self.datelabel = QLabel() self.log_button = create_toolbutton(self, icon=ima.icon('log'), text=_("Output"), text_beside_icon=True, tip=_("Complete output"), triggered=self.show_log) self.treewidget = ResultsTree(self) hlayout1 = QHBoxLayout() hlayout1.addWidget(self.filecombo) hlayout1.addWidget(browse_button) hlayout1.addWidget(self.start_button) hlayout1.addWidget(self.stop_button) hlayout2 = QHBoxLayout() hlayout2.addWidget(self.ratelabel) hlayout2.addStretch() hlayout2.addWidget(self.datelabel) hlayout2.addStretch() hlayout2.addWidget(self.log_button) layout = QVBoxLayout() layout.addLayout(hlayout1) layout.addLayout(hlayout2) layout.addWidget(self.treewidget) self.setLayout(layout) self.process = None self.set_running_state(False) if PYLINT_PATH is None: for widget in (self.treewidget, self.filecombo, self.start_button, self.stop_button): widget.setDisabled(True) if os.name == 'nt' \ and programs.is_module_installed("pylint"): # Pylint is installed but pylint script is not in PATH # (AFAIK, could happen only on Windows) text = _('Pylint script was not found. Please add "%s" to PATH.') text = to_text_string(text) % osp.join(sys.prefix, "Scripts") else: text = _('Please install <b>pylint</b>:') url = 'http://www.logilab.fr' text += ' <a href=%s>%s</a>' % (url, url) self.ratelabel.setText(text) else: self.show_data()
def __init__(self, parent, max_entries=100): """ Creates a very basic window with some text """ """ RATE_LAW_MESSAGE = \ "The Plugins for Spyder consists out of three main classes: \n\n" \ "1. HelloWorld\n\n" \ "\tThe HelloWorld class inherits all its methods from\n" \ "\tSpyderPluginMixin and the HelloWorldWidget and performs all\n" \ "\tthe processing required by the GU. \n\n" \ "2. HelloWorldConfigPage\n\n" \ "\tThe HelloWorldConfig class inherits all its methods from\n" \ "\tPluginConfigPage to create a configuration page that can be\n" \ "\tfound under Tools -> Preferences\n\n" \ "3. HelloWorldWidget\n\n" \ "\tThe HelloWorldWidget class inherits all its methods from\n" \ "\tQWidget to create the actual plugin GUI interface that \n" \ "\tdisplays this message on screen\n\n" """ #Testing access editor on plugin initialization RATE_LAW_MESSAGE = "" displaynamelist = [] #displaylist = [] infixlist = [] desclist = [] parameterstringlist = [] xmldoc = minidom.parse('\\.spyder2\\ratelaw2_0_3.xml') #xmldoc = minidom.parse('%\\Downloads\\ratelaw2_0_3.xml') lawlistxml = xmldoc.getElementsByTagName('law') #i is the number of laws currently in the xml file i = 0 for s in lawlistxml: #RATE_LAW_MESSAGE += s.getAttribute('displayName') + "\n" RATE_LAW_MESSAGE += s.getAttribute('display') + "\n" #displaynamelist[i] = s.getAttribute('displayName') #displaylist[i] = s.getAttribute('display') displaynamelist.append(s.getAttribute('displayName')) #displaylist.append(s.getAttribute('display')) infixlist.append(s.getAttribute('infixExpression')) desclist.append(s.getAttribute('description')) parameterlist = s.getElementsByTagName('listOfParameters')[0] #for p in parameterlist parameters = parameterlist.getElementsByTagName('parameter') parameterstring = "" for param in parameters: parametername = param.attributes['name'].value parameterdesc = param.attributes['description'].value parameterstring = parameterstring + '\t' + parametername + ":" + '\t' + " " + parameterdesc + "\n" #print('\t' + parametername + ":" + '\t' + parameterdesc) parameterstringlist.append(parameterstring) i = i + 1 QWidget.__init__(self, parent) self.setWindowTitle("Rate Law Library") self.output = None self.error_output = None self._last_wdir = None self._last_args = None self._last_pythonpath = None self.textlabel = QLabel(RATE_LAW_MESSAGE) self.lawlist = QListWidget() self.lawpage = QStackedWidget() #Adding displayName items to lawlist for j in range(i): item = QListWidgetItem(displaynamelist[j]) self.lawlist.addItem(item) self.lawdetailpage = QWidget() # Page layout will become its own function setup_group = QGroupBox(displaynamelist[j]) infixmod = infixlist[j].replace("___", " ") setup_label = QLabel(infixmod) setup_label.setWordWrap(True) desc_group = QGroupBox("Description") desc_label = QLabel(desclist[j]) desc_label.setWordWrap(True) param_label = QLabel(parameterstringlist[j]) param_label.setWordWrap(True) # Warning: do not try to regroup the following QLabel contents with # widgets above -- this string was isolated here in a single QLabel # on purpose: to fix Issue 863 setup_layout = QVBoxLayout() setup_layout.addWidget(setup_label) setup_group.setLayout(setup_layout) desc_layout = QVBoxLayout() desc_layout.addWidget(desc_label) desc_layout.addWidget(param_label) desc_group.setLayout(desc_layout) vlayout = QVBoxLayout() vlayout.addWidget(setup_group) vlayout.addWidget(desc_group) vlayout.addStretch(1) self.lawdetailpage.setLayout(vlayout) self.lawpage.addWidget(self.lawdetailpage) #self.connect(self.lawlist, SIGNAL(self.lawlist.currentRowChanged(int)),self.lawpage,SLOT(self.lawpage.setCurrentIndex(int))) self.lawlist.currentRowChanged.connect(self.lawpage.setCurrentIndex) ''' self.lawpage = QWidget() ''' self.lawlist.setCurrentRow(0) hsplitter = QSplitter() hsplitter.addWidget(self.lawlist) hlayout1 = QHBoxLayout() hlayout1.addWidget(self.textlabel) hlayout1.addStretch() self.lawpage.setLayout(hlayout1) hsplitter.addWidget(self.lawpage) layout = QVBoxLayout() layout.addWidget(hsplitter) self.setLayout(layout)
class TestWindow(QMainWindow): """ """ sig_resized = Signal("QResizeEvent") sig_moved = Signal("QMoveEvent") def __init__(self): super(TestWindow, self).__init__() self.setGeometry(300, 100, 400, 600) self.setWindowTitle('Exploring QMainWindow') self.exit = QAction('Exit', self) self.exit.setStatusTip('Exit program') # create the menu bar menubar = self.menuBar() file_ = menubar.addMenu('&File') file_.addAction(self.exit) # create the status bar self.statusBar() # QWidget or its instance needed for box layout self.widget = QWidget(self) self.button = QPushButton('test') self.button1 = QPushButton('1') self.button2 = QPushButton('2') effect = QGraphicsOpacityEffect(self.button2) self.button2.setGraphicsEffect(effect) self.anim = QPropertyAnimation(effect, "opacity") self.anim.setStartValue(0.01) self.anim.setEndValue(1.0) self.anim.setDuration(500) lay = QVBoxLayout() lay.addWidget(self.button) lay.addStretch() lay.addWidget(self.button1) lay.addWidget(self.button2) self.widget.setLayout(lay) self.setCentralWidget(self.widget) self.button.clicked.connect(self.action1) self.button1.clicked.connect(self.action2) self.tour = AnimatedTour(self) def action1(self): """ """ frames = get_tour('test') index = 0 dic = {'last': 0, 'tour': frames} self.tour.set_tour(index, dic, self) self.tour.start_tour() def action2(self): """ """ self.anim.start() def resizeEvent(self, event): """Reimplement Qt method""" QMainWindow.resizeEvent(self, event) self.sig_resized.emit(event) def moveEvent(self, event): """Reimplement Qt method""" QMainWindow.moveEvent(self, event) self.sig_moved.emit(event)
def event(self, event): if event.type() == QEvent.KeyPress and event.key() == Qt.Key_Tab: return False return QWidget.event(self, event)
def __init__(self, parent, search_text=r"# ?TODO|# ?FIXME|# ?XXX", search_text_regexp=True, search_path=None, include=[".", ".py"], include_idx=None, include_regexp=True, exclude=r"\.pyc$|\.orig$|\.hg|\.svn", exclude_idx=None, exclude_regexp=True, supported_encodings=("utf-8", "iso-8859-1", "cp1252"), in_python_path=False, more_options=False): QWidget.__init__(self, parent) self.setWindowTitle(_('Find in files')) self.search_thread = None self.get_pythonpath_callback = None self.find_options = FindOptions(self, search_text, search_text_regexp, search_path, include, include_idx, include_regexp, exclude, exclude_idx, exclude_regexp, supported_encodings, in_python_path, more_options) self.connect(self.find_options, SIGNAL('find()'), self.find) self.connect(self.find_options, SIGNAL('stop()'), self.stop_and_reset_thread) self.result_browser = ResultsBrowser(self) collapse_btn = create_toolbutton(self) collapse_btn.setDefaultAction(self.result_browser.collapse_all_action) expand_btn = create_toolbutton(self) expand_btn.setDefaultAction(self.result_browser.expand_all_action) restore_btn = create_toolbutton(self) restore_btn.setDefaultAction(self.result_browser.restore_action) # collapse_sel_btn = create_toolbutton(self) # collapse_sel_btn.setDefaultAction( # self.result_browser.collapse_selection_action) # expand_sel_btn = create_toolbutton(self) # expand_sel_btn.setDefaultAction( # self.result_browser.expand_selection_action) btn_layout = QVBoxLayout() btn_layout.setAlignment(Qt.AlignTop) for widget in [collapse_btn, expand_btn, restore_btn]: # collapse_sel_btn, expand_sel_btn]: btn_layout.addWidget(widget) hlayout = QHBoxLayout() hlayout.addWidget(self.result_browser) hlayout.addLayout(btn_layout) layout = QVBoxLayout() left, _x, right, bottom = layout.getContentsMargins() layout.setContentsMargins(left, 0, right, bottom) layout.addWidget(self.find_options) layout.addLayout(hlayout) self.setLayout(layout)