def __init__(self, parent, **kwargs): QWidget.__init__(self, parent) if spyder.version_info > (5,): self.plugin = parent.get_plugin() else: self.plugin = parent # Create tool bar if "options_button" in kwargs: self.options_button = kwargs["options_button"] else: self.options_button = None self.plugin_actions = [] MxToolBarMixin.__init__( self, options_button=self.options_button, plugin_actions=self.plugin_actions ) # Create main widget self.tabwidget = QTabWidget(parent=parent) self.precedents = MxAnalyzerTab(parent=self, adjacency='precedents') self.succs = MxAnalyzerTab(parent=self, adjacency='succs') self.tabs = {'precedents': self.precedents, 'succs': self.succs} self.tabwidget.addTab(self.precedents, 'Precedents') self.tabwidget.addTab(self.succs, 'Dependents') layout = create_plugin_layout(self.tools_layout, self.tabwidget) self.setFocusPolicy(Qt.ClickFocus) self.setLayout(layout)
def __init__(self, parent, name_filters=[], show_hscrollbar=True, options_button=None, single_click_to_open=False): # TODO: Remove once Projects is Migrated self.CONF_SECTION = parent.CONF_SECTION QWidget.__init__(self, parent) self.name_filters = name_filters self.show_hscrollbar = show_hscrollbar self.treewidget = ExplorerTreeWidget(self, self.show_hscrollbar) self.treewidget.setup() self.treewidget.setup_view() self.treewidget.hide() self.treewidget.sig_open_file_requested.connect( self.sig_open_file_requested) self.emptywidget = ExplorerTreeWidget(self) if options_button: btn_layout = QHBoxLayout() btn_layout.setAlignment(Qt.AlignLeft) btn_layout.addStretch() btn_layout.addWidget(options_button, Qt.AlignRight) layout = create_plugin_layout(btn_layout) else: layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.emptywidget) layout.addWidget(self.treewidget) self.setLayout(layout)
def __init__(self, parent=None, show_fullpath=True, show_all_files=True, group_cells=True, show_comments=True, sort_files_alphabetically=False, options_button=None): QWidget.__init__(self, parent) self.treewidget = OutlineExplorerTreeWidget( self, show_fullpath=show_fullpath, show_all_files=show_all_files, group_cells=group_cells, show_comments=show_comments, sort_files_alphabetically=sort_files_alphabetically) self.visibility_action = create_action(self, _("Show/hide outline explorer"), icon='outline_explorer_vis.png', toggled=self.toggle_visibility) self.visibility_action.setChecked(True) btn_layout = QHBoxLayout() for btn in self.setup_buttons(): btn.setAutoRaise(True) btn.setIconSize(QSize(16, 16)) btn_layout.addWidget(btn) if options_button: btn_layout.addStretch() btn_layout.addWidget(options_button, Qt.AlignRight) layout = create_plugin_layout(btn_layout, self.treewidget) self.setLayout(layout)
def __init__(self, parent, name_filters=[], show_all=True, show_hscrollbar=True, options_button=None): QWidget.__init__(self, parent) self.name_filters = name_filters self.show_all = show_all self.show_hscrollbar = show_hscrollbar self.treewidget = ExplorerTreeWidget(self, self.show_hscrollbar) self.treewidget.setup(name_filters=self.name_filters, show_all=self.show_all) self.treewidget.setup_view() self.treewidget.hide() self.emptywidget = ExplorerTreeWidget(self) if options_button: btn_layout = QHBoxLayout() btn_layout.setAlignment(Qt.AlignLeft) btn_layout.addStretch() btn_layout.addWidget(options_button, Qt.AlignRight) layout = create_plugin_layout(btn_layout) else: layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.emptywidget) layout.addWidget(self.treewidget) self.setLayout(layout)
def __init__(self, parent=None, show_fullpath=True, fullpath_sorting=True, show_all_files=True, show_comments=True, options_button=None): QWidget.__init__(self, parent) self.treewidget = OutlineExplorerTreeWidget(self, show_fullpath=show_fullpath, fullpath_sorting=fullpath_sorting, show_all_files=show_all_files, show_comments=show_comments) self.visibility_action = create_action(self, _("Show/hide outline explorer"), icon='outline_explorer_vis.png', toggled=self.toggle_visibility) self.visibility_action.setChecked(True) btn_layout = QHBoxLayout() for btn in self.setup_buttons(): btn.setAutoRaise(True) btn.setIconSize(QSize(16, 16)) btn_layout.addWidget(btn) if options_button: btn_layout.addStretch() btn_layout.addWidget(options_button, Qt.AlignRight) layout = create_plugin_layout(btn_layout, self.treewidget) self.setLayout(layout)
def __init__(self, parent, name_filters=[], show_all=True, show_hscrollbar=True, options_button=None): QWidget.__init__(self, parent) self.name_filters = name_filters self.show_all = show_all self.show_hscrollbar = show_hscrollbar self.treewidget = ExplorerTreeWidget(self, self.show_hscrollbar) self.treewidget.setup(name_filters=self.name_filters, show_all=self.show_all) self.treewidget.setup_view() self.treewidget.hide() self.emptywidget = ExplorerTreeWidget(self) if options_button: btn_layout = QHBoxLayout() btn_layout.setAlignment(Qt.AlignLeft) btn_layout.addStretch() btn_layout.addWidget(options_button, Qt.AlignRight) layout = create_plugin_layout(btn_layout) else: layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.emptywidget) layout.addWidget(self.treewidget) self.setLayout(layout)
def __init__(self, parent=None, show_fullpath=True, fullpath_sorting=True, show_all_files=True, show_comments=True): QWidget.__init__(self, parent) self.treewidget = OutlineExplorerTreeWidget( self, show_fullpath=show_fullpath, fullpath_sorting=fullpath_sorting, show_all_files=show_all_files, show_comments=show_comments) self.visibility_action = create_action(self, _("Show/hide outline explorer"), icon='outline_explorer_vis.png', toggled=self.toggle_visibility) self.visibility_action.setChecked(True) btn_layout = QHBoxLayout() btn_layout.setAlignment(Qt.AlignLeft) for btn in self.setup_buttons(): btn_layout.addWidget(btn) layout = create_plugin_layout(btn_layout, self.treewidget) self.setLayout(layout)
def __init__(self, parent=None, namespace=None, commands=[], message=None, exitfunc=None, profile=False, multithreaded=False): SpyderPluginWidget.__init__(self, parent) logger.info("Initializing...") self.dialog_manager = DialogManager() # Shell self.shell = InternalShell(parent, namespace, commands, message, self.get_option('max_line_count'), self.get_plugin_font(), exitfunc, profile, multithreaded) self.shell.status.connect(lambda msg: self.show_message.emit(msg, 0)) self.shell.go_to_error.connect(self.go_to_error) self.shell.focus_changed.connect(lambda: self.focus_changed.emit()) # Redirecting some signals: self.shell.redirect_stdio.connect( lambda state: self.redirect_stdio.emit(state)) # Initialize plugin self.initialize_plugin() # Find/replace widget self.find_widget = FindReplace(self) self.find_widget.set_editor(self.shell) self.find_widget.hide() self.register_widget_shortcuts(self.find_widget) # Main layout btn_layout = QHBoxLayout() btn_layout.setAlignment(Qt.AlignLeft) btn_layout.addStretch() btn_layout.addWidget(self.options_button, Qt.AlignRight) layout = create_plugin_layout(btn_layout) layout.addWidget(self.shell) layout.addWidget(self.find_widget) self.setLayout(layout) # Parameters self.shell.toggle_wrap_mode(self.get_option('wrap')) # Accepting drops self.setAcceptDrops(True) # Traceback MessageBox self.error_dlg = None self.error_traceback = "" self.dismiss_error = False
def __init__(self, parent=None, css_path=CSS_PATH): SpyderPluginWidget.__init__(self, parent) self.shell = None self.var_info = [] # Object name layout_edit = QHBoxLayout() layout_edit.setContentsMargins(0, 0, 0, 0) pybutton = QPushButton('Select a File', self) pybutton.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding) pybutton.clicked.connect(self.selectImageFile) pybutton1 = QPushButton('Color Conversion', self) pybutton1.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding) pybutton1.clicked.connect(self.showdialog) pybutton2 = QPushButton('Thresholding', self) pybutton2.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding) pybutton2.clicked.connect(self.showdialog2) pybutton3 = QPushButton('Blob Detection', self) pybutton3.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding) pybutton3.clicked.connect(self.showdialog3) welcomeTitle = QLabel() welcomeTitle.setText("Welcome to Image Processr!") layout_edit.addWidget(pybutton) #layout_edit.addStretch() layout_edit.addWidget(pybutton1) #layout_edit.addStretch() layout_edit.addWidget(pybutton2) #layout_edit.addStretch() layout_edit.addWidget(pybutton3) # Main layout layout = create_plugin_layout(QVBoxLayout()) # we have two main widgets, but only one of them is shown at a time layout.addStretch() layout.addWidget(welcomeTitle) layout.addLayout(layout_edit) layout.addStretch() layout.addStretch() layout.addStretch() self.setLayout(layout) self._starting_up = True
def __init__(self, parent=None, namespace=None, commands=[], message=None, exitfunc=None, profile=False, multithreaded=False): SpyderPluginWidget.__init__(self, parent) logger.info("Initializing...") self.dialog_manager = DialogManager() # Shell light_background = self.get_option('light_background') self.shell = InternalShell(parent, namespace, commands, message, self.get_option('max_line_count'), self.get_plugin_font(), exitfunc, profile, multithreaded, light_background=light_background) self.shell.status.connect(lambda msg: self.show_message.emit(msg, 0)) self.shell.go_to_error.connect(self.go_to_error) self.shell.focus_changed.connect(lambda: self.focus_changed.emit()) # Redirecting some signals: self.shell.redirect_stdio.connect(lambda state: self.redirect_stdio.emit(state)) # Initialize plugin self.initialize_plugin() # Find/replace widget self.find_widget = FindReplace(self) self.find_widget.set_editor(self.shell) self.find_widget.hide() self.register_widget_shortcuts(self.find_widget) # Main layout btn_layout = QHBoxLayout() btn_layout.setAlignment(Qt.AlignLeft) btn_layout.addStretch() btn_layout.addWidget(self.options_button, Qt.AlignRight) layout = create_plugin_layout(btn_layout) layout.addWidget(self.shell) layout.addWidget(self.find_widget) self.setLayout(layout) # Parameters self.shell.toggle_wrap_mode(self.get_option('wrap')) # Accepting drops self.setAcceptDrops(True) # Traceback MessageBox self.error_dlg = None self.error_traceback = "" self.dismiss_error = False
def __init__(self, parent, **kwargs): QWidget.__init__(self, parent) self.plugin = parent.get_plugin() self.last_modelpath = None # Create and place Model Selector txt = _("Model") if sys.platform == 'darwin': expr_label = QLabel(" " + txt) else: expr_label = QLabel(txt) # expr_label.setAlignment(Qt.AlignCenter | Qt.AlignRight) self.model_selector = MxModelSelector(self) selector_layout = QHBoxLayout() selector_layout.addWidget(expr_label) selector_layout.addWidget(self.model_selector) selector_layout.insertStretch(-1, 1) selector_layout.setStretch(0, 0) selector_layout.setStretch(1, 1) # Create widget and add to dockwindow self.explorer = MxExplorer(self) # Create code list self.codelist = MxCodeListWidget(self) self.propwidget = MxPropertyWidget(self, orientation=Qt.Vertical) self.datalist = MxDataListWidget(self, orientation=Qt.Vertical) # Create splitter self.splitter = QSplitter(self) self.splitter.setContentsMargins(0, 0, 0, 0) # self.splitter.addWidget(self.widget) # self.splitter.setStretchFactor(0, 5) # self.splitter.setStretchFactor(1, 1) self.tabwidget = QTabWidget(parent=self) # self.tabwidget.setContentsMargins(0, 0, 0, 0) MxMainWidget.IdxProperties = self.tabwidget.addTab(self.propwidget, "Properties") MxMainWidget.IdxFormulas = self.tabwidget.addTab(self.codelist, "Formulas") MxMainWidget.IdxDataList = self.tabwidget.addTab(self.datalist, "Data") # Layout management self.splitter.addWidget(self.explorer) self.splitter.addWidget(self.tabwidget) layout = create_plugin_layout(selector_layout, self.splitter) self.setLayout(layout) self.setFocusPolicy(Qt.ClickFocus)
def __init__(self, parent, adjacency): QWidget.__init__(self, parent) # self.main = parent # Spyder3 # Create main widget self.model = MxAnalyzerModel(adjacency=adjacency, root=None, parent=self) # from .modeltest import ModelTest # self.modeltest = ModelTest(self.model, self) self.tree = MxAnalyzerTree(self, self.model) self.shellwidget = None # Set by parent # Layout of the top area in the plugin widget layout_top = QHBoxLayout() layout_top.setContentsMargins(0, 0, 0, 0) # Add Object textbox layout_top.addSpacing(10) txt = _("Object") if sys.platform == 'darwin': obj_label = QLabel(" " + txt) else: obj_label = QLabel(txt) layout_top.addWidget(obj_label) if spyder.version_info < (4, ): font = parent.plugin.get_plugin_font() else: font = parent.plugin.get_font() self.objbox = MxPyExprLineEdit(self, font=font) layout_top.addWidget(self.objbox) layout_top.addSpacing(10) # Add Object textbox txt = _("Args") if sys.platform == 'darwin': arg_label = QLabel(" " + txt) else: arg_label = QLabel(txt) layout_top.addWidget(arg_label) self.argbox = MxPyExprLineEdit(self, font=font) layout_top.addWidget(self.argbox) layout_top.addSpacing(10) # Main layout of this widget layout = create_plugin_layout(layout_top, self.tree) self.setLayout(layout)
def __init__(self, parent, **kwargs): QWidget.__init__(self, parent) if spyder.version_info > (5,): self.plugin = parent.get_plugin() else: self.plugin = parent self.last_modelpath = None # Create tool bar if "options_button" in kwargs: self.options_button = kwargs["options_button"] else: self.options_button = None self.plugin_actions = [] MxToolBarMixin.__init__( self, options_button=self.options_button, plugin_actions=self.plugin_actions ) # Create widget and add to dockwindow self.explorer = MxExplorer(self) # Create code list self.codelist = MxCodeListWidget(self) self.propwidget = MxPropertyWidget(self, orientation=Qt.Vertical) self.datalist = MxDataListWidget(self, orientation=Qt.Vertical) # Create splitter self.splitter = QSplitter(self) self.splitter.setContentsMargins(0, 0, 0, 0) # self.splitter.addWidget(self.widget) # self.splitter.setStretchFactor(0, 5) # self.splitter.setStretchFactor(1, 1) self.tabwidget = QTabWidget(parent=self) # self.tabwidget.setContentsMargins(0, 0, 0, 0) MxMainWidget.IdxProperties = self.tabwidget.addTab(self.propwidget, "Properties") MxMainWidget.IdxFormulas = self.tabwidget.addTab(self.codelist, "Formulas") MxMainWidget.IdxDataList = self.tabwidget.addTab(self.datalist, "Data") # Layout management self.splitter.addWidget(self.explorer) self.splitter.addWidget(self.tabwidget) layout = create_plugin_layout(self.tools_layout, self.splitter) self.setFocusPolicy(Qt.ClickFocus) self.setLayout(layout)
def __init__(self, parent=None, show_fullpath=True, show_all_files=True, group_cells=True, show_comments=True, sort_files_alphabetically=False, display_variables=False, follow_cursor=True, options_button=None): # TODO: Remove once the OutlineExplorer is migrated self.CONF_SECTION = 'outline_explorer' QWidget.__init__(self, parent) self.treewidget = OutlineExplorerTreeWidget( self, show_fullpath=show_fullpath, show_all_files=show_all_files, group_cells=group_cells, display_variables=display_variables, show_comments=show_comments, sort_files_alphabetically=sort_files_alphabetically, follow_cursor=follow_cursor, ) self.loading_widget = create_waitspinner(size=16, parent=self) self.treewidget.sig_display_spinner.connect(self.loading_widget.start) self.treewidget.sig_hide_spinner.connect(self.loading_widget.stop) self.treewidget.sig_update_configuration.connect( self.sig_update_configuration) self.visibility_action = create_action(self, _("Show/hide outline explorer"), icon='outline_explorer_vis.png', toggled=self.toggle_visibility) self.visibility_action.setChecked(True) btn_layout = QHBoxLayout() for btn in self.setup_buttons(): btn.setAutoRaise(True) btn.setIconSize(QSize(16, 16)) btn_layout.addWidget(btn) if options_button: btn_layout.addStretch() btn_layout.addWidget(self.loading_widget, Qt.AlignRight) btn_layout.addWidget(options_button, Qt.AlignRight) layout = create_plugin_layout(btn_layout, self.treewidget) self.setLayout(layout)
def setup(self, mute_inline_plotting=None, show_plot_outline=None, auto_fit_plotting=None): """Setup the figure browser with provided settings.""" assert self.shellwidget is not None self.mute_inline_plotting = mute_inline_plotting self.show_plot_outline = show_plot_outline self.auto_fit_plotting = auto_fit_plotting if self.figviewer is not None: self.mute_inline_action.setChecked(mute_inline_plotting) self.show_plot_outline_action.setChecked(show_plot_outline) self.auto_fit_action.setChecked(auto_fit_plotting) return # Setup the figure viewer. self.figviewer = FigureViewer(background_color=self.background_color) self.figviewer.figcanvas.sig_save_fig_requested.connect( self.save_figure) self.figviewer.figcanvas.sig_clear_fig_requested.connect( self.close_figure) # Setup the thumbnail scrollbar. self.thumbnails_sb = ThumbnailScrollBar( self.figviewer, background_color=self.background_color) toolbar = self.setup_toolbar() self.setup_option_actions(mute_inline_plotting, show_plot_outline, auto_fit_plotting) # Create the layout. main_widget = QSplitter() main_widget.addWidget(self.figviewer) main_widget.addWidget(self.thumbnails_sb) main_widget.setFrameStyle(QScrollArea().frameStyle()) self.tools_layout = QHBoxLayout() for widget in toolbar: self.tools_layout.addWidget(widget) self.tools_layout.addStretch() self.setup_options_button() layout = create_plugin_layout(self.tools_layout, main_widget) self.setLayout(layout)
def setup(self, mute_inline_plotting=None, show_plot_outline=None, auto_fit_plotting=None): """Setup the figure browser with provided settings.""" assert self.shellwidget is not None self.mute_inline_plotting = mute_inline_plotting self.show_plot_outline = show_plot_outline self.auto_fit_plotting = auto_fit_plotting if self.figviewer is not None: self.mute_inline_action.setChecked(mute_inline_plotting) self.show_plot_outline_action.setChecked(show_plot_outline) self.auto_fit_action.setChecked(auto_fit_plotting) return self.figviewer = FigureViewer(background_color=self.background_color) self.figviewer.setStyleSheet("FigureViewer{" "border: 1px solid lightgrey;" "border-top-width: 0px;" "border-bottom-width: 0px;" "border-left-width: 0px;" "}") self.thumbnails_sb = ThumbnailScrollBar( self.figviewer, background_color=self.background_color) # Option actions : self.setup_option_actions(mute_inline_plotting, show_plot_outline, auto_fit_plotting) # Create the layout : main_widget = QSplitter() main_widget.addWidget(self.figviewer) main_widget.addWidget(self.thumbnails_sb) main_widget.setFrameStyle(QScrollArea().frameStyle()) self.tools_layout = QHBoxLayout() toolbar = self.setup_toolbar() for widget in toolbar: self.tools_layout.addWidget(widget) self.tools_layout.addStretch() self.setup_options_button() layout = create_plugin_layout(self.tools_layout, main_widget) self.setLayout(layout)
def __init__(self, parent, name_filters=[], show_hscrollbar=True, options_button=None, single_click_to_open=False): QWidget.__init__(self, parent) self.name_filters = name_filters self.show_hscrollbar = show_hscrollbar self.treewidget = ExplorerTreeWidget(self, self.show_hscrollbar) options = { 'date_column': False, 'kind_column': True, 'size_column': False, 'name_filters': name_filters, 'show_hidden': False, 'single_click_to_open': single_click_to_open, 'file_associations': {}, } self.treewidget.setup(options) self.treewidget.setup_view() self.treewidget.hide() self.treewidget.sig_open_file_requested.connect( self.sig_open_file_requested) self.emptywidget = ExplorerTreeWidget(self) if options_button: btn_layout = QHBoxLayout() btn_layout.setAlignment(Qt.AlignLeft) btn_layout.addStretch() btn_layout.addWidget(options_button, Qt.AlignRight) layout = create_plugin_layout(btn_layout) else: layout = QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.emptywidget) layout.addWidget(self.treewidget) self.setLayout(layout)
def __init__(self, parent, **kwargs): QWidget.__init__(self, parent) self.plugin = parent # Create tool bar if "options_button" in kwargs: self.options_button = kwargs["options_button"] else: self.options_button = None self.plugin_actions = [] MxToolBarMixin.__init__(self, options_button=self.options_button, plugin_actions=self.plugin_actions) # Create main widget self.widget = MxDataWidget(self) # Main layout of this widget layout = create_plugin_layout(self.tools_layout, self.widget) self.setLayout(layout)
def setup(self, mute_inline_plotting=None, show_plot_outline=None): """Setup the figure browser with provided settings.""" assert self.shellwidget is not None self.mute_inline_plotting = mute_inline_plotting self.show_plot_outline = show_plot_outline if self.figviewer is not None: self.mute_inline_action.setChecked(mute_inline_plotting) self.show_plot_outline_action.setChecked(show_plot_outline) return self.figviewer = FigureViewer(background_color=self.background_color) self.figviewer.setStyleSheet("FigureViewer{" "border: 1px solid lightgrey;" "border-top-width: 0px;" "border-bottom-width: 0px;" "border-left-width: 0px;" "}") self.thumbnails_sb = ThumbnailScrollBar( self.figviewer, background_color=self.background_color) # Option actions : self.setup_option_actions(mute_inline_plotting, show_plot_outline) # Create the layout : main_widget = QSplitter() main_widget.addWidget(self.figviewer) main_widget.addWidget(self.thumbnails_sb) main_widget.setFrameStyle(QScrollArea().frameStyle()) self.tools_layout = QHBoxLayout() toolbar = self.setup_toolbar() for widget in toolbar: self.tools_layout.addWidget(widget) self.tools_layout.addStretch() self.setup_options_button() layout = create_plugin_layout(self.tools_layout, main_widget) self.setLayout(layout)
def __init__(self, parent=None, show_fullpath=True, fullpath_sorting=True, show_all_files=True, show_comments=True): QWidget.__init__(self, parent) self.treewidget = OutlineExplorerTreeWidget(self, show_fullpath=show_fullpath, fullpath_sorting=fullpath_sorting, show_all_files=show_all_files, show_comments=show_comments) self.visibility_action = create_action(self, _("Show/hide outline explorer"), icon='outline_explorer_vis.png', toggled=self.toggle_visibility) self.visibility_action.setChecked(True) btn_layout = QHBoxLayout() btn_layout.setAlignment(Qt.AlignLeft) for btn in self.setup_buttons(): btn_layout.addWidget(btn) layout = create_plugin_layout(btn_layout, self.treewidget) self.setLayout(layout)
def __init__(self, parent, options_button=None): QWidget.__init__(self, parent) self.setWindowTitle("Breakpoints") self.dictwidget = BreakpointTableView(self, self._load_all_breakpoints()) if options_button: btn_layout = QHBoxLayout() btn_layout.setAlignment(Qt.AlignLeft) btn_layout.addStretch() btn_layout.addWidget(options_button, Qt.AlignRight) layout = create_plugin_layout(btn_layout, self.dictwidget) else: 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 __init__(self, parent, options_button=None): QWidget.__init__(self, parent) self.setWindowTitle("Breakpoints") self.dictwidget = BreakpointTableView(self, self._load_all_breakpoints()) if options_button: btn_layout = QHBoxLayout() btn_layout.setAlignment(Qt.AlignLeft) btn_layout.addStretch() btn_layout.addWidget(options_button, Qt.AlignRight) layout = create_plugin_layout(btn_layout, self.dictwidget) else: 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 _setup_views(self): """Creates the UI widgets.""" self.central_splitter = QSplitter(self, orientation=Qt.Vertical) layout = create_plugin_layout(self.tools_layout, self.central_splitter) self.setLayout(layout) # Stretch last column? # It doesn't play nice when columns are hidden and then shown again. obj_tree_header = self.obj_tree.header() obj_tree_header.setSectionsMovable(True) obj_tree_header.setStretchLastSection(False) add_actions(self.show_cols_submenu, self.obj_tree.toggle_column_actions_group.actions()) self.central_splitter.addWidget(self.obj_tree) # Bottom pane bottom_pane_widget = QWidget() bottom_layout = QHBoxLayout() bottom_layout.setSpacing(0) bottom_layout.setContentsMargins(5, 5, 5, 5) # left top right bottom bottom_pane_widget.setLayout(bottom_layout) self.central_splitter.addWidget(bottom_pane_widget) group_box = QGroupBox(_("Details")) bottom_layout.addWidget(group_box) v_group_layout = QVBoxLayout() h_group_layout = QHBoxLayout() h_group_layout.setContentsMargins(2, 2, 2, 2) # left top right bottom group_box.setLayout(v_group_layout) v_group_layout.addLayout(h_group_layout) # Radio buttons radio_widget = QWidget() radio_layout = QVBoxLayout() radio_layout.setContentsMargins(0, 0, 0, 0) # left top right bottom radio_widget.setLayout(radio_layout) self.button_group = QButtonGroup(self) for button_id, attr_detail in enumerate(self._attr_details): radio_button = QRadioButton(attr_detail.name) radio_layout.addWidget(radio_button) self.button_group.addButton(radio_button, button_id) self.button_group.buttonClicked[int].connect( self._change_details_field) self.button_group.button(0).setChecked(True) radio_layout.addStretch(1) h_group_layout.addWidget(radio_widget) # Editor widget self.editor = SimpleCodeEditor(self) self.editor.setReadOnly(True) h_group_layout.addWidget(self.editor) # Save and close buttons btn_layout = QHBoxLayout() btn_layout.addStretch() if not self.readonly: self.btn_save_and_close = QPushButton(_('Save and Close')) self.btn_save_and_close.setDisabled(True) self.btn_save_and_close.clicked.connect(self.accept) btn_layout.addWidget(self.btn_save_and_close) self.btn_close = QPushButton(_('Close')) self.btn_close.setAutoDefault(True) self.btn_close.setDefault(True) self.btn_close.clicked.connect(self.reject) btn_layout.addWidget(self.btn_close) v_group_layout.addLayout(btn_layout) # Splitter parameters self.central_splitter.setCollapsible(0, False) self.central_splitter.setCollapsible(1, True) self.central_splitter.setSizes([500, 320]) # Connect signals # Keep a temporary reference of the selection_model to prevent # segfault in PySide. # See http://permalink.gmane.org/gmane.comp.lib.qt.pyside.devel/222 selection_model = self.obj_tree.selectionModel() selection_model.currentChanged.connect(self._update_details) # Check if the values of the model have been changed self._proxy_tree_model.sig_setting_data.connect( self.save_and_close_enable) self._proxy_tree_model.sig_update_details.connect( self._update_details_for_item)
def setup( self, check_all=None, exclude_private=None, exclude_uppercase=None, exclude_capitalized=None, exclude_unsupported=None, excluded_names=None, exclude_callables_and_modules=None, minmax=None, dataframe_format=None, show_callable_attributes=None, show_special_attributes=None, ): """ Setup the namespace browser with provided settings. Args: dataframe_format (string): default floating-point format for DataFrame editor """ assert self.shellwidget is not None self.check_all = check_all self.exclude_private = exclude_private self.exclude_uppercase = exclude_uppercase self.exclude_capitalized = exclude_capitalized self.exclude_unsupported = exclude_unsupported self.exclude_callables_and_modules = exclude_callables_and_modules self.excluded_names = excluded_names self.minmax = minmax self.dataframe_format = dataframe_format self.show_callable_attributes = show_callable_attributes self.show_special_attributes = show_special_attributes if self.editor is not None: self.editor.setup_menu(minmax) self.editor.set_dataframe_format(dataframe_format) self.exclude_private_action.setChecked(exclude_private) self.exclude_uppercase_action.setChecked(exclude_uppercase) self.exclude_capitalized_action.setChecked(exclude_capitalized) self.exclude_unsupported_action.setChecked(exclude_unsupported) self.exclude_callables_and_modules_action.setChecked( exclude_callables_and_modules) self.refresh_table() return self.editor = RemoteCollectionsEditorTableView( self, data=None, minmax=minmax, shellwidget=self.shellwidget, dataframe_format=dataframe_format, show_callable_attributes=show_callable_attributes, show_special_attributes=show_special_attributes) self.editor.sig_option_changed.connect(self.sig_option_changed.emit) self.editor.sig_files_dropped.connect(self.import_data) self.editor.sig_free_memory.connect(self.sig_free_memory.emit) self.setup_option_actions(exclude_private, exclude_uppercase, exclude_capitalized, exclude_unsupported, exclude_callables_and_modules) # Setup toolbar layout. self.tools_layout = QHBoxLayout() toolbar = self.setup_toolbar() for widget in toolbar: self.tools_layout.addWidget(widget) self.tools_layout.addStretch() self.setup_options_button() # Setup layout. layout = create_plugin_layout(self.tools_layout, self.editor) # Fuzzy search layout finder_layout = QHBoxLayout() close_button = create_toolbutton(self, triggered=self.show_finder, icon=ima.icon('DialogCloseButton')) text_finder = NamespacesBrowserFinder(self.editor, callback=self.editor.set_regex, main=self, regex_base=VALID_VARIABLE_CHARS) self.editor.finder = text_finder finder_layout.addWidget(close_button) finder_layout.addWidget(text_finder) finder_layout.setContentsMargins(0, 0, 0, 0) self.finder = QWidget(self) self.finder.text_finder = text_finder self.finder.setLayout(finder_layout) self.finder.setVisible(False) layout.addWidget(self.finder) self.setLayout(layout) # Local shortcuts self.shortcuts = self.create_shortcuts() self.sig_option_changed.connect(self.option_changed)
def setup(self, check_all=None, exclude_private=None, exclude_uppercase=None, exclude_capitalized=None, exclude_unsupported=None, excluded_names=None, minmax=None, dataframe_format=None): """ Setup the namespace browser with provided settings. Args: dataframe_format (string): default floating-point format for DataFrame editor """ assert self.shellwidget is not None self.check_all = check_all self.exclude_private = exclude_private self.exclude_uppercase = exclude_uppercase self.exclude_capitalized = exclude_capitalized self.exclude_unsupported = exclude_unsupported self.excluded_names = excluded_names self.minmax = minmax self.dataframe_format = dataframe_format if self.editor is not None: self.editor.setup_menu(minmax) self.editor.set_dataframe_format(dataframe_format) self.exclude_private_action.setChecked(exclude_private) self.exclude_uppercase_action.setChecked(exclude_uppercase) self.exclude_capitalized_action.setChecked(exclude_capitalized) self.exclude_unsupported_action.setChecked(exclude_unsupported) self.refresh_table() return self.editor = RemoteCollectionsEditorTableView( self, data=None, minmax=minmax, shellwidget=self.shellwidget, dataframe_format=dataframe_format) self.editor.sig_option_changed.connect(self.sig_option_changed.emit) self.editor.sig_files_dropped.connect(self.import_data) # Setup layout blayout = QHBoxLayout() toolbar = self.setup_toolbar(exclude_private, exclude_uppercase, exclude_capitalized, exclude_unsupported) for widget in toolbar: blayout.addWidget(widget) # Options menu options_button = create_toolbutton(self, text=_('Options'), icon=ima.icon('tooloptions')) options_button.setPopupMode(QToolButton.InstantPopup) menu = QMenu(self) editor = self.editor actions = [self.exclude_private_action, self.exclude_uppercase_action, self.exclude_capitalized_action, self.exclude_unsupported_action, None] if is_module_installed('numpy'): actions.append(editor.minmax_action) add_actions(menu, actions) options_button.setMenu(menu) blayout.addStretch() blayout.addWidget(options_button) layout = create_plugin_layout(blayout, self.editor) self.setLayout(layout) self.sig_option_changed.connect(self.option_changed)
def __init__(self, parent=None, options_button=None, handle_links=True): QWidget.__init__(self, parent) self.home_url = None self.webview = WebView(self, handle_links=handle_links) self.webview.setup() 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) def pageact2btn(prop, icon=None): return action2button(self.webview.pageAction(prop), parent=self.webview, icon=icon) refresh_button = pageact2btn(QWebEnginePage.Reload, icon=ima.icon('refresh')) stop_button = pageact2btn(QWebEnginePage.Stop, icon=ima.icon('stop')) previous_button = pageact2btn(QWebEnginePage.Back, icon=ima.icon('previous')) next_button = pageact2btn(QWebEnginePage.Forward, icon=ima.icon('next')) 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) if not WEBENGINE: 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) if options_button: hlayout.addWidget(options_button) layout = create_plugin_layout(hlayout) layout.addWidget(self.webview) layout.addWidget(self.find_widget) self.setLayout(layout)
def __init__(self, parent=None, css_path=CSS_PATH): SpyderPluginWidget.__init__(self, parent) self.internal_shell = None self.console = None self.css_path = css_path # Initialize plugin self.initialize_plugin() self.no_doc_string = _("No documentation available") self._last_console_cb = None self._last_editor_cb = None self.plain_text = PlainText(self) self.rich_text = RichText(self) color_scheme = self.get_color_scheme() self.set_plain_text_font(self.get_plugin_font(), color_scheme) self.plain_text.editor.toggle_wrap_mode(self.get_option('wrap')) # Add entries to read-only editor context-menu self.wrap_action = create_action(self, _("Wrap lines"), toggled=self.toggle_wrap_mode) self.wrap_action.setChecked(self.get_option('wrap')) self.plain_text.editor.readonly_menu.addSeparator() add_actions(self.plain_text.editor.readonly_menu, (self.wrap_action,)) self.set_rich_text_font(self.get_plugin_font('rich_text')) self.shell = None # locked = disable link with Console self.locked = False self._last_texts = [None, None] self._last_editor_doc = None # Object name layout_edit = QHBoxLayout() layout_edit.setContentsMargins(0, 0, 0, 0) txt = _("Source") if sys.platform == 'darwin': source_label = QLabel(" " + txt) else: source_label = QLabel(txt) layout_edit.addWidget(source_label) self.source_combo = QComboBox(self) self.source_combo.addItems([_("Console"), _("Editor")]) self.source_combo.currentIndexChanged.connect(self.source_changed) if (not programs.is_module_installed('rope') and not programs.is_module_installed('jedi', '>=0.11.0')): self.source_combo.hide() source_label.hide() layout_edit.addWidget(self.source_combo) layout_edit.addSpacing(10) layout_edit.addWidget(QLabel(_("Object"))) self.combo = ObjectComboBox(self) layout_edit.addWidget(self.combo) self.object_edit = QLineEdit(self) self.object_edit.setReadOnly(True) layout_edit.addWidget(self.object_edit) self.combo.setMaxCount(self.get_option('max_history_entries')) self.combo.addItems( self.load_history() ) self.combo.setItemText(0, '') self.combo.valid.connect(lambda valid: self.force_refresh()) # Plain text docstring option self.docstring = True self.rich_help = self.get_option('rich_mode', True) self.plain_text_action = create_action(self, _("Plain Text"), toggled=self.toggle_plain_text) # Source code option self.show_source_action = create_action(self, _("Show Source"), toggled=self.toggle_show_source) # Rich text option self.rich_text_action = create_action(self, _("Rich Text"), toggled=self.toggle_rich_text) # Add the help actions to an exclusive QActionGroup help_actions = QActionGroup(self) help_actions.setExclusive(True) help_actions.addAction(self.plain_text_action) help_actions.addAction(self.rich_text_action) # Automatic import option self.auto_import_action = create_action(self, _("Automatic import"), toggled=self.toggle_auto_import) auto_import_state = self.get_option('automatic_import') self.auto_import_action.setChecked(auto_import_state) # Lock checkbox self.locked_button = create_toolbutton(self, triggered=self.toggle_locked) layout_edit.addWidget(self.locked_button) self._update_lock_icon() # Option menu self.menu = QMenu(self) add_actions(self.menu, [self.rich_text_action, self.plain_text_action, self.show_source_action, MENU_SEPARATOR, self.auto_import_action, MENU_SEPARATOR, self.undock_action]) self.options_button.setMenu(self.menu) layout_edit.addWidget(self.options_button) if self.rich_help: self.switch_to_rich_text() else: self.switch_to_plain_text() self.plain_text_action.setChecked(not self.rich_help) self.rich_text_action.setChecked(self.rich_help) self.source_changed() # Main layout layout = create_plugin_layout(layout_edit) # we have two main widgets, but only one of them is shown at a time layout.addWidget(self.plain_text) layout.addWidget(self.rich_text) self.setLayout(layout) # Add worker thread for handling rich text rendering self._sphinx_thread = SphinxThread( html_text_no_doc=warning(self.no_doc_string, css_path=self.css_path), css_path=self.css_path) self._sphinx_thread.html_ready.connect( self._on_sphinx_thread_html_ready) self._sphinx_thread.error_msg.connect(self._on_sphinx_thread_error_msg) # Handle internal and external links view = self.rich_text.webview if not WEBENGINE: view.page().setLinkDelegationPolicy(QWebEnginePage.DelegateAllLinks) view.linkClicked.connect(self.handle_link_clicks) self._starting_up = True
def __init__(self, parent, adjacency): QSplitter.__init__(self, parent, orientation=Qt.Vertical) self.plugin = parent.plugin self.adjacency = adjacency treepane = QWidget(parent=self) # Create main widget self.model = MxAnalyzerModel( adjacency=adjacency, root=None, parent=self # parent must be self, # because self.model access self.tab ) # from .modeltest import ModelTest # self.modeltest = ModelTest(self.model, self) self.tree = MxAnalyzerTree(treepane, self.model) self.shellwidget = None # Set by parent button_group = QButtonGroup(parent=self) self.object_radio = object_radio = QRadioButton("Object") self.expr_radio = expr_radio = QRadioButton("Expression") button_group.addButton(object_radio) button_group.addButton(expr_radio) object_radio.setChecked(True) object_radio.toggled.connect(self.toggleObject) # Layout of the top area in the plugin widget expr_layout = QHBoxLayout() expr_layout.setContentsMargins(0, 0, 0, 0) # Add Object textbox expr_layout.addSpacing(10) txt = _("Object") if sys.platform == 'darwin': obj_label = QLabel(" " + txt) else: obj_label = QLabel(txt) expr_layout.addWidget(obj_label) if spyder.version_info < (4,): font = parent.plugin.get_plugin_font() else: font = parent.plugin.get_font() self.objbox = QLabel(parent=self) self.argbox = MxPyExprLineEdit(self, font=font) self.attrdict = None objbox_layout = QHBoxLayout() objbox_layout.addWidget(self.objbox) objbox_layout.addWidget(self.argbox) objbox_layout.setStretch(0, 3) # 3:1 objbox_layout.setStretch(1, 1) self.exprobjbox = MxPyExprLineEdit(treepane, font=font) expr_layout.addWidget(self.exprobjbox) expr_layout.addSpacing(10) # Add Object textbox txt = _("Args") if sys.platform == 'darwin': arg_label = QLabel(" " + txt) else: arg_label = QLabel(txt) expr_layout.addWidget(arg_label) self.exprargbox = MxPyExprLineEdit(treepane, font=font) expr_layout.addWidget(self.exprargbox) # expr_layout.addSpacing(5) top_layout = QGridLayout() top_layout.addWidget(object_radio, 0, 0) top_layout.addWidget(expr_radio, 1, 0) top_layout.addLayout(objbox_layout, 0, 1) objbox_layout.setContentsMargins(0, 0, 0, 5) top_layout.addLayout(expr_layout, 1, 1) top_layout.setContentsMargins(5, 5, 5, 5) # Main layout of this widget layout = create_plugin_layout(top_layout, self.tree) treepane.setLayout(layout) self.status = QLabel() layout.addWidget(self.status) self.codepane = AnalyzerCodePane(parent=self)
def setup(self, check_all=None, exclude_private=None, exclude_uppercase=None, exclude_capitalized=None, exclude_unsupported=None, excluded_names=None, minmax=None, dataframe_format=None): """ Setup the namespace browser with provided settings. Args: dataframe_format (string): default floating-point format for DataFrame editor """ assert self.shellwidget is not None self.check_all = check_all self.exclude_private = exclude_private self.exclude_uppercase = exclude_uppercase self.exclude_capitalized = exclude_capitalized self.exclude_unsupported = exclude_unsupported self.excluded_names = excluded_names self.minmax = minmax self.dataframe_format = dataframe_format if self.editor is not None: self.editor.setup_menu(minmax) self.editor.set_dataframe_format(dataframe_format) self.exclude_private_action.setChecked(exclude_private) self.exclude_uppercase_action.setChecked(exclude_uppercase) self.exclude_capitalized_action.setChecked(exclude_capitalized) self.exclude_unsupported_action.setChecked(exclude_unsupported) self.refresh_table() return self.editor = RemoteCollectionsEditorTableView( self, data=None, minmax=minmax, shellwidget=self.shellwidget, dataframe_format=dataframe_format) self.editor.sig_option_changed.connect(self.sig_option_changed.emit) self.editor.sig_files_dropped.connect(self.import_data) # Setup layout blayout = QHBoxLayout() toolbar = self.setup_toolbar(exclude_private, exclude_uppercase, exclude_capitalized, exclude_unsupported) for widget in toolbar: blayout.addWidget(widget) # Options menu options_button = create_toolbutton(self, text=_('Options'), icon=ima.icon('tooloptions')) options_button.setPopupMode(QToolButton.InstantPopup) menu = QMenu(self) editor = self.editor actions = [ self.exclude_private_action, self.exclude_uppercase_action, self.exclude_capitalized_action, self.exclude_unsupported_action, None ] if is_module_installed('numpy'): actions.append(editor.minmax_action) add_actions(menu, actions) options_button.setMenu(menu) blayout.addStretch() blayout.addWidget(options_button) layout = create_plugin_layout(blayout, self.editor) self.setLayout(layout) self.sig_option_changed.connect(self.option_changed)
def __init__(self, parent, **kwargs): QWidget.__init__(self, parent) if spyder.version_info > (5, ): self.plugin = parent.get_plugin() else: self.plugin = parent # Create tool bar if "options_button" in kwargs: self.options_button = kwargs["options_button"] else: self.options_button = None self.plugin_actions = [] MxToolBarMixin.__init__(self, options_button=self.options_button, plugin_actions=self.plugin_actions) # # outer_layout # +----------------------------------------------|-----------+ # | inner_layout | | # | +---------|-----------------------------+ | | # upper | | | +----------------------+ | | | # layout | |obj_radio| |objbox_layout | | | | # | | | +----------------------+ | | update | # | ----------------------------------------- | button | # | | expr | | | | # | | radio | exprbox | | | # | +---------|-----------------------------+ | | # | | | # -----------------------------------------------|------------ # | | # | msgbox | # | | # +----------------------------------------------------------+ # button_group = QButtonGroup(parent=self) self.object_radio = object_radio = QRadioButton("Object") self.expr_radio = expr_radio = QRadioButton("Expression") button_group.addButton(object_radio) button_group.addButton(expr_radio) object_radio.toggled.connect(self.activateObject) expr_radio.toggled.connect(self.activateExpression) update_button = QPushButton(text="Update", parent=self) update_button.clicked.connect(self.update_data) # txt = _("Expression") # if sys.platform == 'darwin': # expr_label = QLabel(" " + txt) # else: # expr_label = QLabel(txt) if spyder.version_info < (4, ): font = self.plugin.get_plugin_font() else: font = self.plugin.get_font() self.exprbox = MxPyExprLineEdit(self, font=font) self.objbox = QLabel(parent=self) self.argbox = MxPyExprLineEdit(self, font=font) self.msgbox = QLabel(parent=self) self.msgbox.setText("") self.msgbox.setWordWrap(True) outer_layout = QVBoxLayout() upper_layout = QHBoxLayout() outer_layout.addLayout(upper_layout) outer_layout.addWidget(self.msgbox) inner_layout = QGridLayout() inner_layout.addWidget(object_radio, 0, 0) inner_layout.addWidget(expr_radio, 1, 0) inner_layout.addWidget(self.exprbox, 1, 1) objbox_layout = QHBoxLayout() objbox_layout.addWidget(self.objbox) objbox_layout.addWidget(self.argbox) objbox_layout.setStretch(0, 3) # 3:1 objbox_layout.setStretch(1, 1) inner_layout.addLayout(objbox_layout, 0, 1) upper_layout.addLayout(inner_layout) upper_layout.addWidget(update_button) # widget = QWidget(parent=self) # widget.setLayout(outer_layout) # Create main widget self.widget = QWidget(parent=self) # MxDataFrameViewer(self) self.main_layout = main_layout = QVBoxLayout() main_layout.addLayout(outer_layout) main_layout.addWidget(self.widget) main_layout.setStretch(1, 1) # Main layout of this widget layout = create_plugin_layout(self.tools_layout) layout.addLayout(main_layout) margins = (5, 5, 5, 5) for lo in [outer_layout, upper_layout, inner_layout, self.msgbox]: lo.setContentsMargins(*margins) objbox_layout.setContentsMargins(5, 5, 0, 5) self.setLayout(layout) self.attrdict = None object_radio.setChecked(True)
def __init__(self, parent=None, css_path=CSS_PATH): SpyderPluginWidget.__init__(self, parent) self.internal_shell = None self.console = None self.css_path = css_path self.no_doc_string = _("No documentation available") self._last_console_cb = None self._last_editor_cb = None self.plain_text = PlainText(self) self.rich_text = RichText(self) color_scheme = self.get_color_scheme() self.set_plain_text_font(self.get_font(), color_scheme) self.plain_text.editor.toggle_wrap_mode(self.get_option('wrap')) # Add entries to read-only editor context-menu self.wrap_action = create_action(self, _("Wrap lines"), toggled=self.toggle_wrap_mode) self.wrap_action.setChecked(self.get_option('wrap')) self.plain_text.editor.readonly_menu.addSeparator() add_actions(self.plain_text.editor.readonly_menu, (self.wrap_action,)) self.set_rich_text_font(self.get_font(rich_text=True)) self.shell = None # locked = disable link with Console self.locked = False self._last_texts = [None, None] self._last_editor_doc = None # Object name layout_edit = QHBoxLayout() layout_edit.setContentsMargins(0, 0, 0, 0) txt = _("Source") if sys.platform == 'darwin': source_label = QLabel(" " + txt) else: source_label = QLabel(txt) layout_edit.addWidget(source_label) self.source_combo = QComboBox(self) self.source_combo.addItems([_("Console"), _("Editor")]) self.source_combo.currentIndexChanged.connect(self.source_changed) if (not programs.is_module_installed('rope') and not programs.is_module_installed('jedi', '>=0.11.0')): self.source_combo.hide() source_label.hide() layout_edit.addWidget(self.source_combo) layout_edit.addSpacing(10) layout_edit.addWidget(QLabel(_("Object"))) self.combo = ObjectComboBox(self) layout_edit.addWidget(self.combo) self.object_edit = QLineEdit(self) self.object_edit.setReadOnly(True) layout_edit.addWidget(self.object_edit) self.combo.setMaxCount(self.get_option('max_history_entries')) self.combo.addItems( self.load_history() ) self.combo.setItemText(0, '') self.combo.valid.connect(self.force_refresh) # Plain text docstring option self.docstring = True self.rich_help = self.get_option('rich_mode', True) self.plain_text_action = create_action(self, _("Plain Text"), toggled=self.toggle_plain_text) # Source code option self.show_source_action = create_action(self, _("Show Source"), toggled=self.toggle_show_source) # Rich text option self.rich_text_action = create_action(self, _("Rich Text"), toggled=self.toggle_rich_text) # Add the help actions to an exclusive QActionGroup help_actions = QActionGroup(self) help_actions.setExclusive(True) help_actions.addAction(self.plain_text_action) help_actions.addAction(self.rich_text_action) # Automatic import option self.auto_import_action = create_action(self, _("Automatic import"), toggled=self.toggle_auto_import) auto_import_state = self.get_option('automatic_import') self.auto_import_action.setChecked(auto_import_state) # Lock checkbox self.locked_button = create_toolbutton(self, triggered=self.toggle_locked) layout_edit.addWidget(self.locked_button) self._update_lock_icon() # Option menu layout_edit.addWidget(self.options_button) if self.rich_help: self.switch_to_rich_text() else: self.switch_to_plain_text() self.plain_text_action.setChecked(not self.rich_help) self.rich_text_action.setChecked(self.rich_help) self.source_changed() # Main layout layout = create_plugin_layout(layout_edit) # we have two main widgets, but only one of them is shown at a time layout.addWidget(self.plain_text) layout.addWidget(self.rich_text) self.setLayout(layout) # Add worker thread for handling rich text rendering self._sphinx_thread = SphinxThread( html_text_no_doc=warning(self.no_doc_string, css_path=self.css_path), css_path=self.css_path) self._sphinx_thread.html_ready.connect( self._on_sphinx_thread_html_ready) self._sphinx_thread.error_msg.connect(self._on_sphinx_thread_error_msg) # Handle internal and external links view = self.rich_text.webview if not WEBENGINE: view.page().setLinkDelegationPolicy(QWebEnginePage.DelegateAllLinks) view.linkClicked.connect(self.handle_link_clicks) self._starting_up = True
def setup(self, check_all=None, exclude_private=None, exclude_uppercase=None, exclude_capitalized=None, exclude_unsupported=None, excluded_names=None, minmax=None, dataframe_format=None, show_callable_attributes=None, show_special_attributes=None): """ Setup the namespace browser with provided settings. Args: dataframe_format (string): default floating-point format for DataFrame editor """ assert self.shellwidget is not None self.check_all = check_all self.exclude_private = exclude_private self.exclude_uppercase = exclude_uppercase self.exclude_capitalized = exclude_capitalized self.exclude_unsupported = exclude_unsupported self.excluded_names = excluded_names self.minmax = minmax self.dataframe_format = dataframe_format self.show_callable_attributes = show_callable_attributes self.show_special_attributes = show_special_attributes if self.editor is not None: self.editor.setup_menu(minmax) self.editor.set_dataframe_format(dataframe_format) self.exclude_private_action.setChecked(exclude_private) self.exclude_uppercase_action.setChecked(exclude_uppercase) self.exclude_capitalized_action.setChecked(exclude_capitalized) self.exclude_unsupported_action.setChecked(exclude_unsupported) self.refresh_table() return self.editor = RemoteCollectionsEditorTableView( self, data=None, minmax=minmax, shellwidget=self.shellwidget, dataframe_format=dataframe_format, show_callable_attributes=show_callable_attributes, show_special_attributes=show_special_attributes ) self.editor.sig_option_changed.connect(self.sig_option_changed.emit) self.editor.sig_files_dropped.connect(self.import_data) self.editor.sig_free_memory.connect(self.sig_free_memory.emit) self.setup_option_actions(exclude_private, exclude_uppercase, exclude_capitalized, exclude_unsupported) # Setup toolbar layout. self.tools_layout = QHBoxLayout() toolbar = self.setup_toolbar() for widget in toolbar: self.tools_layout.addWidget(widget) self.tools_layout.addStretch() self.setup_options_button() # Setup layout. layout = create_plugin_layout(self.tools_layout, self.editor) self.setLayout(layout) self.sig_option_changed.connect(self.option_changed)
def _setup_views(self): """Creates the UI widgets.""" self.central_splitter = QSplitter(self, orientation=Qt.Vertical) layout = create_plugin_layout(self.tools_layout, self.central_splitter) self.setLayout(layout) # Tree widget self.obj_tree = ToggleColumnTreeView() self.obj_tree.setAlternatingRowColors(True) self.obj_tree.setModel(self._proxy_tree_model) self.obj_tree.setSelectionBehavior(QAbstractItemView.SelectRows) self.obj_tree.setUniformRowHeights(True) self.obj_tree.setAnimated(True) self.obj_tree.add_header_context_menu() # Stretch last column? # It doesn't play nice when columns are hidden and then shown again. obj_tree_header = self.obj_tree.header() obj_tree_header.setSectionsMovable(True) obj_tree_header.setStretchLastSection(False) add_actions(self.show_cols_submenu, self.obj_tree.toggle_column_actions_group.actions()) self.central_splitter.addWidget(self.obj_tree) # Bottom pane bottom_pane_widget = QWidget() bottom_layout = QHBoxLayout() bottom_layout.setSpacing(0) bottom_layout.setContentsMargins(5, 5, 5, 5) # left top right bottom bottom_pane_widget.setLayout(bottom_layout) self.central_splitter.addWidget(bottom_pane_widget) group_box = QGroupBox(_("Details")) bottom_layout.addWidget(group_box) v_group_layout = QVBoxLayout() h_group_layout = QHBoxLayout() h_group_layout.setContentsMargins(2, 2, 2, 2) # left top right bottom group_box.setLayout(v_group_layout) v_group_layout.addLayout(h_group_layout) # Radio buttons radio_widget = QWidget() radio_layout = QVBoxLayout() radio_layout.setContentsMargins(0, 0, 0, 0) # left top right bottom radio_widget.setLayout(radio_layout) self.button_group = QButtonGroup(self) for button_id, attr_detail in enumerate(self._attr_details): radio_button = QRadioButton(attr_detail.name) radio_layout.addWidget(radio_button) self.button_group.addButton(radio_button, button_id) self.button_group.buttonClicked[int].connect( self._change_details_field) self.button_group.button(0).setChecked(True) radio_layout.addStretch(1) h_group_layout.addWidget(radio_widget) # Editor widget self.editor = CodeEditor(self) self.editor.setReadOnly(True) h_group_layout.addWidget(self.editor) # Warining label about repr repr_label = QLabel( _("(*) Some objects have very large repr's, " "which can freeze Spyder. Please use this " "with care.")) v_group_layout.addWidget(repr_label) # Splitter parameters self.central_splitter.setCollapsible(0, False) self.central_splitter.setCollapsible(1, True) self.central_splitter.setSizes([500, 320]) self.central_splitter.setStretchFactor(0, 10) self.central_splitter.setStretchFactor(1, 0) # Connect signals # Keep a temporary reference of the selection_model to prevent # segfault in PySide. # See http://permalink.gmane.org/gmane.comp.lib.qt.pyside.devel/222 selection_model = self.obj_tree.selectionModel() selection_model.currentChanged.connect(self._update_details)
def __init__(self, parent=None, options_button=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(QWebEnginePage.Reload) stop_button = pageact2btn(QWebEnginePage.Stop) previous_button = pageact2btn(QWebEnginePage.Back) next_button = pageact2btn(QWebEnginePage.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) if not WEBENGINE: 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) if options_button: hlayout.addWidget(options_button) layout = create_plugin_layout(hlayout) layout.addWidget(self.webview) layout.addWidget(self.find_widget) self.setLayout(layout)
def setup(self, check_all=None, exclude_private=None, exclude_uppercase=None, exclude_capitalized=None, exclude_unsupported=None, excluded_names=None, minmax=None, dataframe_format=None): """ Setup the namespace browser with provided settings. Args: dataframe_format (string): default floating-point format for DataFrame editor """ assert self.shellwidget is not None self.check_all = check_all self.exclude_private = exclude_private self.exclude_uppercase = exclude_uppercase self.exclude_capitalized = exclude_capitalized self.exclude_unsupported = exclude_unsupported self.excluded_names = excluded_names self.minmax = minmax self.dataframe_format = dataframe_format if self.editor is not None: self.editor.setup_menu(minmax) self.editor.set_dataframe_format(dataframe_format) self.exclude_private_action.setChecked(exclude_private) self.exclude_uppercase_action.setChecked(exclude_uppercase) self.exclude_capitalized_action.setChecked(exclude_capitalized) self.exclude_unsupported_action.setChecked(exclude_unsupported) self.refresh_table() return self.editor = RemoteCollectionsEditorTableView( self, data=None, minmax=minmax, shellwidget=self.shellwidget, dataframe_format=dataframe_format) self.editor.sig_option_changed.connect(self.sig_option_changed.emit) self.editor.sig_files_dropped.connect(self.import_data) self.editor.sig_free_memory.connect(self.sig_free_memory.emit) self.setup_option_actions(exclude_private, exclude_uppercase, exclude_capitalized, exclude_unsupported) # Setup toolbar layout. self.tools_layout = QHBoxLayout() toolbar = self.setup_toolbar() for widget in toolbar: self.tools_layout.addWidget(widget) self.tools_layout.addStretch() self.setup_options_button() # Setup layout. layout = create_plugin_layout(self.tools_layout, self.editor) self.setLayout(layout) self.sig_option_changed.connect(self.option_changed)