def _show_code_nav(self): self.btnPrevious.setIcon(ui_tools.get_icon("code-left")) self.btnNext.setIcon(ui_tools.get_icon("code-right")) self.bookmarksAction.setChecked(False) self.breakpointsAction.setChecked(False) self.codeAction.setChecked(True) self.operation = 0
def __init__(self): super(CodeNavigator, self).__init__() self.setContextMenuPolicy(Qt.DefaultContextMenu) self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred) # self.setContentsMargins(0, 0, 0, 0) hbox = QHBoxLayout(self) hbox.setContentsMargins(0, 0, 0, 0) if settings.IS_MAC_OS: hbox.setSpacing(10) else: hbox.setSpacing(0) self.btnPrevious = QPushButton() self.btnPrevious.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Minimum) self.btnPrevious.setObjectName('navigation_button') self.btnPrevious.clicked.connect(self._on_previous_pressed) self.btnPrevious.setIcon(ui_tools.get_icon('code-left')) self.btnPrevious.setToolTip(translations.TR_TOOLTIP_NAV_BUTTONS) self.btnNext = QPushButton() self.btnNext.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Minimum) self.btnNext.setObjectName('navigation_button') self.btnNext.clicked.connect(self._on_next_pressed) self.btnNext.setIcon(ui_tools.get_icon('code-right')) self.btnNext.setToolTip(translations.TR_TOOLTIP_NAV_BUTTONS) hbox.addWidget(self.btnPrevious) hbox.addWidget(self.btnNext) self.menuNavigate = QMenu(self.tr("Navigate")) self.codeAction = self.menuNavigate.addAction( translations.TR_NAV_CODE_JUMP) self.codeAction.setCheckable(True) self.codeAction.setChecked(True) self.bookmarksAction = self.menuNavigate.addAction( translations.TR_NAV_BOOKMARKS) self.bookmarksAction.setCheckable(True) self.breakpointsAction = self.menuNavigate.addAction( translations.TR_NAV_BREAKPOINTS) self.breakpointsAction.setCheckable(True) # 0 = Code Jumps # 1 = Bookmarks # 2 = Breakpoints self.operation = 0 self.codeAction.triggered.connect(self._show_code_nav) self.breakpointsAction.triggered.connect(self._show_breakpoints) self.bookmarksAction.triggered.connect(self._show_bookmarks)
def __init__(self, parent): super().__init__() self._preferences = parent box = QVBoxLayout(self) group_python_path = QGroupBox(translations.TR_WORKSPACE_PROJECTS) grid = QVBoxLayout(group_python_path) # Python Path python_path_bgroup = QButtonGroup(group_python_path) box_path = QVBoxLayout() # Line python path self._txt_python_path = QLineEdit() act = self._txt_python_path.addAction( ui_tools.get_icon('open-project'), QLineEdit.TrailingPosition) act.triggered.connect(self._load_python_path) import sys self._txt_python_path.setText(sys.executable) self._txt_python_path.textChanged.connect(self._python_exec_changed) box_path.addWidget(QLabel("Select the Python interpreter")) # Default default_interpreter_radio = QRadioButton("Default") default_interpreter_radio.toggled.connect( self._txt_python_path.setDisabled) python_path_bgroup.addButton(default_interpreter_radio) # Custom self._custom_interpreter_radio = QRadioButton( "Use this Python interpreter:") self._custom_interpreter_radio.toggled.connect( self._txt_python_path.setEnabled) python_path_bgroup.addButton(self._custom_interpreter_radio) box_path.addWidget(default_interpreter_radio) box_path.addWidget(self._custom_interpreter_radio) box_path.addWidget(self._txt_python_path) """ completer = QCompleter(self) dirs = QDirModel(self) dirs.setFilter(QDir.AllEntries | QDir.NoDotAndDotDot) completer.setModel(dirs) self._txt_python_path.setCompleter(completer) box_path.addWidget(default_interpreter_radio) box_path.addWidget(custom_interpreter_radio) """ # self._btn_python_path = QPushButton('o') # box_path.addWidget(self._btn_python_path) grid.addLayout(box_path) box.addWidget(group_python_path) box.addItem( QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding)) # Connections # self._txt_python_path.buttonClicked.connect(self._load_python_path) self._preferences.savePreferences.connect(self.save)
def _load_ui(self): ninjaide = IDE.get_service("ide") shortcut_number = 1 for index, (obj, name) in _ToolsDock.__WIDGETS.items(): button = ToolButton(name, index + 1) button.setCheckable(True) button.clicked.connect(self.on_button_triggered) self.__buttons.append(button) self.buttons_widget.layout().addWidget(button) self.add_widget(name, obj) self.__buttons_visibility[button] = True # Shortcut action ksequence = self._get_shortcut(shortcut_number) short = QShortcut(ksequence, ninjaide) button.setToolTip( ui_tools.tooltip_with_shortcut(button._text, ksequence)) short.activated.connect(self._shortcut_triggered) shortcut_number += 1 self.buttons_widget.layout().addItem( QSpacerItem(0, 0, QSizePolicy.Expanding)) # Python Selector btn_selector = ui_tools.FancyButton("Loading...") btn_selector.setIcon(ui_tools.get_icon("python")) btn_selector.setCheckable(True) btn_selector.setEnabled(False) self.buttons_widget.layout().addWidget(btn_selector) # QML Interface self._python_selector = python_selector.PythonSelector(btn_selector) interpreter_srv = IDE.get_service("interpreter") interpreter_srv.foundInterpreters.connect( self._python_selector.add_model) btn_selector.toggled[bool].connect( lambda v: self._python_selector.setVisible(v)) # Popup for show/hide tools widget button_toggle_widgets = ToggleButton() self.buttons_widget.layout().addWidget(button_toggle_widgets) button_toggle_widgets.clicked.connect(self._show_menu)
def __init__(self, filename, lineno): super().__init__(filename, lineno) self.set_icon(ui_tools.get_icon("bookmark", "#8080ff")) self._linetext = ""
def update_symbols_tree(self, symbols, filename='', parent=None): """Method to Update the symbols on the Tree""" TIP = "{} {}" if not parent: if filename == self.actualSymbols[0] and \ self.actualSymbols[1] and not symbols: return if symbols == self.actualSymbols[1]: # Nothing new then return return # we have new symbols refresh it self.tree.clear() self.actualSymbols = (filename, symbols) self.docstrings = symbols.get('docstrings', {}) parent = self.tree if 'attributes' in symbols: globalAttribute = ItemTree(parent, [translations.TR_ATTRIBUTES]) globalAttribute.isClickable = False globalAttribute.isAttribute = True globalAttribute.setExpanded(self._get_expand(globalAttribute)) globalAttribute.setToolTip( 0, TIP.format(len(symbols['attributes']), translations.TR_ATTRIBUTES)) for glob in sorted(symbols['attributes']): globItem = ItemTree(globalAttribute, [glob], lineno=symbols['attributes'][glob]) globItem.isAttribute = True # globItem.setIcon( # 0, ui_tools.colored_icon(":img/attr", "#5dade2")) globItem.setIcon(0, QIcon(":img/attr")) globItem.setExpanded(self._get_expand(globItem)) if 'functions' in symbols and symbols['functions']: functionsItem = ItemTree(parent, [translations.TR_FUNCTIONS]) functionsItem.isClickable = False functionsItem.isMethod = True functionsItem.setExpanded(self._get_expand(functionsItem)) functionsItem.setToolTip( 0, TIP.format(len(symbols['functions']), translations.TR_FUNCTIONS)) for func in sorted(symbols['functions']): item = ItemTree(functionsItem, [func], lineno=symbols['functions'][func]['lineno']) tooltip = self.create_tooltip( func, symbols['functions'][func]['lineno']) item.isMethod = True item.setIcon(0, QIcon(":img/function")) # item.setIcon( # 0, ui_tools.colored_icon(":img/function", "#9FA8DA")) item.setToolTip(0, tooltip) item.setExpanded(self._get_expand(item)) self.update_symbols_tree( symbols['functions'][func]['functions'], parent=item) if 'classes' in symbols and symbols['classes']: classItem = ItemTree(parent, [translations.TR_CLASSES]) classItem.isClickable = False classItem.isClass = True classItem.setExpanded(self._get_expand(classItem)) classItem.setToolTip( 0, TIP.format(len(symbols['classes']), translations.TR_CLASSES)) for claz in sorted(symbols['classes']): line_number = symbols['classes'][claz]['lineno'] item = ItemTree(classItem, [claz], lineno=line_number) item.isClass = True tooltip = self.create_tooltip(claz, line_number) item.setToolTip(0, tooltip) # item.setIcon(0, ui_tools.colored_icon(":img/class", "#FFCC80")) # item.setIcon(0, ui_tools.get_icon('class', '#FFCC80')) item.setIcon(0, ui_tools.get_icon('class')) item.setExpanded(self._get_expand(item)) self.update_symbols_tree(symbols['classes'][claz]['members'], parent=item)