def __init__(self, parent): QtGui.QWidget.__init__(self, parent) # Create text field, checkbox, and button self._text = QtGui.QLineEdit(self) self._printBut = QtGui.QPushButton("Print", self) # Create options button self._options = QtGui.QToolButton(self) self._options.setIcon(pyzo.icons.wrench) self._options.setIconSize(QtCore.QSize(16, 16)) self._options.setPopupMode(self._options.InstantPopup) self._options.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon) # Create options menu self._options._menu = QtGui.QMenu() self._options.setMenu(self._options._menu) # Create browser self._browser = QtGui.QTextBrowser(self) self._browser_text = initText # Create two sizers self._sizer1 = QtGui.QVBoxLayout(self) self._sizer2 = QtGui.QHBoxLayout() # Put the elements together self._sizer2.addWidget(self._text, 4) self._sizer2.addWidget(self._printBut, 0) self._sizer2.addWidget(self._options, 2) # self._sizer1.addLayout(self._sizer2, 0) self._sizer1.addWidget(self._browser, 1) # self._sizer1.setSpacing(2) self._sizer1.setContentsMargins(4, 4, 4, 4) self.setLayout(self._sizer1) # Set config toolId = self.__class__.__name__.lower() self._config = config = pyzo.config.tools[toolId] # if not hasattr(config, 'smartNewlines'): config.smartNewlines = True if not hasattr(config, 'fontSize'): if sys.platform == 'darwin': config.fontSize = 12 else: config.fontSize = 10 # Create callbacks self._text.returnPressed.connect(self.queryDoc) self._printBut.clicked.connect(self.printDoc) # self._options.pressed.connect(self.onOptionsPress) self._options._menu.triggered.connect(self.onOptionMenuTiggered) # Start self.setText() # Set default text self.onOptionsPress() # Fill menu
def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.setWindowTitle('Install a conda env?') self.setModal(True) text = 'Pyzo is only an editor. To execute code, you need a Python environment.\n\n' text += 'Do you want Pyzo to install a Python environment (miniconda)?\n' text += 'If not, you must arrange for a Python interpreter yourself' if not sys.platform.startswith('win'): text += ' or use the system Python' text += '.' text += '\n(You can always launch the installer from the shell menu.)' self._label = QtGui.QLabel(text, self) self._no = QtGui.QPushButton("No thanks (dont ask again)") self._yes = QtGui.QPushButton("Yes, please install Python!") self._no.clicked.connect(self.reject) self._yes.clicked.connect(self.accept) vbox = QtGui.QVBoxLayout(self) hbox = QtGui.QHBoxLayout() self.setLayout(vbox) vbox.addWidget(self._label, 1) vbox.addLayout(hbox, 0) hbox.addWidget(self._no, 2) hbox.addWidget(self._yes, 2) self._yes.setDefault(1)
def __init__(self, parent): QtGui.QWidget.__init__(self, parent) # Make sure there is a configuration entry for this tool # The pyzo tool manager makes sure that there is an entry in # config.tools before the tool is instantiated. toolId = self.__class__.__name__.lower() self._config = pyzo.config.tools[toolId] if not hasattr(self._config, 'hideTypes'): self._config.hideTypes = [] # Create tool button self._up = QtGui.QToolButton(self) style = QtGui.qApp.style() self._up.setIcon(style.standardIcon(style.SP_ArrowLeft)) self._up.setIconSize(QtCore.QSize(16, 16)) # Create "path" line edit self._line = QtGui.QLineEdit(self) self._line.setReadOnly(True) self._line.setStyleSheet("QLineEdit { background:#ddd; }") self._line.setFocusPolicy(QtCore.Qt.NoFocus) # Create options menu self._options = QtGui.QToolButton(self) self._options.setIcon(pyzo.icons.filter) self._options.setIconSize(QtCore.QSize(16, 16)) self._options.setPopupMode(self._options.InstantPopup) self._options.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon) # self._options._menu = QtGui.QMenu() self._options.setMenu(self._options._menu) self.onOptionsPress() # create menu now # Create tree self._tree = WorkspaceTree(self) # Set layout layout = QtGui.QHBoxLayout() layout.addWidget(self._up, 0) layout.addWidget(self._line, 1) layout.addWidget(self._options, 0) # mainLayout = QtGui.QVBoxLayout(self) mainLayout.addLayout(layout, 0) mainLayout.addWidget(self._tree, 1) mainLayout.setSpacing(2) mainLayout.setContentsMargins(4, 4, 4, 4) self.setLayout(mainLayout) # Bind events self._up.pressed.connect(self._tree._proxy.goUp) self._options.pressed.connect(self.onOptionsPress) self._options._menu.triggered.connect(self.onOptionMenuTiggered)
def __init__(self, parent): QtGui.QScrollArea.__init__(self, parent) # Init the scroll area self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) self.setWidgetResizable(True) self.setFrameShape(QtGui.QFrame.NoFrame) # Create widget and a layout self._content = QtGui.QWidget(parent) self._formLayout = QtGui.QFormLayout(self._content) # Collect classes of widgets to instantiate classes = [] for t in self.INFO_KEYS: className = 'ShellInfo_' + t.key cls = globals()[className] classes.append((t, cls)) # Instantiate all classes self._shellInfoWidgets = {} for t, cls in classes: # Instantiate and store instance = cls(self._content) self._shellInfoWidgets[t.key] = instance # Create label label = QtGui.QLabel(t, self._content) label.setToolTip(t.tt) # Add to layout self._formLayout.addRow(label, instance) # Add delete button t = translate('shell', 'Delete ::: Delete this shell configuration') label = QtGui.QLabel('', self._content) instance = QtGui.QPushButton(pyzo.icons.cancel, t, self._content) instance.setToolTip(t.tt) instance.setAutoDefault(False) instance.clicked.connect(self.parent().parent().onTabClose) deleteLayout = QtGui.QHBoxLayout() deleteLayout.addWidget(instance, 0) deleteLayout.addStretch(1) # Add to layout self._formLayout.addRow(label, deleteLayout) # Apply layout self._formLayout.setSpacing(15) self._content.setLayout(self._formLayout) self.setWidget(self._content)
def __init__(self, parent, i): BasePyzoWizardPage.__init__(self, parent, i) # Create label and checkbox t1 = translate('wizard', "This wizard can be opened using 'Help > Pyzo wizard'") t2 = translate('wizard', "Show this wizard on startup") self._label_info = QtGui.QLabel(t1, self) #self._check_show = QtGui.QCheckBox(t2, self) #self._check_show.stateChanged.connect(self._setNewUser) # Create language switcher self._langLabel = QtGui.QLabel(translate('wizard', "Select language"), self) # self._langBox = QtGui.QComboBox(self) self._langBox.setEditable(False) # Fill index, theIndex = -1, -1 cur = pyzo.config.settings.language for lang in sorted(LANGUAGES): index += 1 self._langBox.addItem(lang) if lang == LANGUAGE_SYNONYMS.get(cur, cur): theIndex = index # Set current index if theIndex >= 0: self._langBox.setCurrentIndex(theIndex) # Bind signal self._langBox.activated.connect(self.onLanguageChange) # Init check state #if pyzo.config.state.newUser: # self._check_show.setCheckState(QtCore.Qt.Checked) # Create sublayout layout = QtGui.QHBoxLayout() layout.addWidget(self._langLabel, 0) layout.addWidget(self._langBox, 0) layout.addStretch(2) self.layout().addLayout(layout) # Add to layout self.layout().addSpacing(10) self.layout().addWidget(self._label_info)
def __init__(self, parent): QtGui.QFrame.__init__(self, parent) # Init config toolId = self.__class__.__name__.lower() self._config = iep.config.tools[toolId] # Create web view if imported_qtwebkit: self._view = QtWebKit.QWebView() page = self._view.page() page.setLinkDelegationPolicy(QtWebKit.QWebPage.DelegateAllLinks) page.linkClicked.connect(self.onLinkClicked) cssurl = filedir + os.sep + "github.css" self._cssurl = QtCore.QUrl.fromLocalFile(cssurl) else: self._view = WebView(self) self._view.setOpenExternalLinks(True) self._cssurl = None # self._view.settings().setUserStyleSheetUrl(self._cssurl) # print(self._view.settings().userStyleSheetUrl()) # Bind to events self._view.setContextMenuPolicy(QtCore.Qt.NoContextMenu) iep.editors.currentChanged.connect(self.onEditorsCurrentChanged) iep.editors.parserDone.connect(self.getEditorContent) # Get the Markdown parser self._md = markdownparser.getparser() # Layout self._sizer1 = QtGui.QVBoxLayout(self) self._sizer2 = QtGui.QHBoxLayout() # self._sizer1.addLayout(self._sizer2, 0) self._sizer1.addWidget(self._view, 1) # self._sizer1.setSpacing(2) self.setLayout(self._sizer1) # Start self.getEditorContent() self._view.show()
def __init__(self, engine): super().__init__() self._engine = engine layout = QtGui.QVBoxLayout(self) add_button = QtGui.QPushButton("Add") del_button = QtGui.QPushButton("Delete") self._view = QtGui.QListView() layout.addWidget(self._view) layout2 = QtGui.QHBoxLayout() layout2.addWidget(add_button) layout2.addWidget(del_button) layout.addLayout(layout2) self._model = QtGui.QStringListModel() self._view.setModel(self._model) self._model.setStringList(self._engine.registeredDocumentations()) add_button.clicked.connect(self.add_doc) del_button.clicked.connect(self.del_doc)
def __init__(self, parent): QtGui.QDialog.__init__(self, parent) self.setWindowTitle(pyzo.translate("menu dialog", "About Pyzo")) self.resize(600, 500) # Layout layout = QtGui.QVBoxLayout(self) self.setLayout(layout) # Create image and title im = QtGui.QPixmap( os.path.join(pyzo.pyzoDir, 'resources', 'appicons', 'pyzologo64.png')) imlabel = QtGui.QLabel(self) imlabel.setPixmap(im) textlabel = QtGui.QLabel(self) textlabel.setText('<h3>Pyzo: the Interactive Editor for Python</h3>') # titleLayout = QtGui.QHBoxLayout() titleLayout.addWidget(imlabel, 0) titleLayout.addWidget(textlabel, 1) # layout.addLayout(titleLayout, 0) # Create tab bar self._tabs = QtGui.QTabWidget(self) self._tabs.setDocumentMode(True) layout.addWidget(self._tabs, 1) # Create button box self._butBox = QtGui.QDialogButtonBox(self) self._butBox.setOrientation(QtCore.Qt.Horizontal) self._butBox.setStandardButtons(self._butBox.Close) layout.addWidget(self._butBox, 0) # Signals self._butBox.rejected.connect(self.close) # Create tabs self.createGeneralTab() self.createContributorsTab() self.createLicenseTab()
def __init__(self, parent, **kwargs): QtGui.QWidget.__init__(self, parent) self._left = LogoWidget(self) self._right = LabelWidget(self, **kwargs) # Layout layout = QtGui.QHBoxLayout(self) self.setLayout(layout) #layout.setContentsMargins(0,0,0,0) layout.setSpacing(25) layout.addStretch(1) layout.addWidget(self._left, 0) layout.addWidget(self._right, 0) layout.addStretch(1) # Change background of main window to create a splash-screen-efefct iconImage = 'pyzologo256.png' iconImage = os.path.join(pyzo.pyzoDir, 'resources','appicons', iconImage) iconImage = iconImage.replace(os.path.sep, '/') # Fix for Windows self.setStyleSheet(STYLESHEET % iconImage)
def __init__(self, *args): QtGui.QDialog.__init__(self, *args) self.setModal(True) # Set title self.setWindowTitle(pyzo.translate('shell', 'Shell configurations')) # Create tab widget self._tabs = QtGui.QTabWidget(self) #self._tabs = CompactTabWidget(self, padding=(4,4,5,5)) #self._tabs.setDocumentMode(False) self._tabs.setMovable(True) # Get known interpreters (sorted them by version) # Do this here so we only need to do it once ... from pyzo.util.interpreters import get_interpreters self.interpreters = list(reversed(get_interpreters('2.4'))) # Introduce an entry if there's none if not pyzo.config.shellConfigs2: w = ShellInfoTab(self._tabs) self._tabs.addTab(w, '---') w.setInfo() # Fill tabs for item in pyzo.config.shellConfigs2: w = ShellInfoTab(self._tabs) self._tabs.addTab(w, '---') w.setInfo(item) # Enable making new tabs and closing tabs self._add = QtGui.QToolButton(self) self._tabs.setCornerWidget(self._add) self._add.clicked.connect(self.onAdd) self._add.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon) self._add.setIcon(pyzo.icons.add) self._add.setText(translate('shell', 'Add config')) # #self._tabs.setTabsClosable(True) self._tabs.tabCloseRequested.connect(self.onTabClose) # Create buttons cancelBut = QtGui.QPushButton("Cancel", self) okBut = QtGui.QPushButton("Done", self) cancelBut.clicked.connect(self.close) okBut.clicked.connect(self.applyAndClose) # Layout for buttons buttonLayout = QtGui.QHBoxLayout() buttonLayout.addStretch(1) buttonLayout.addWidget(cancelBut) buttonLayout.addSpacing(10) buttonLayout.addWidget(okBut) # Layout the widgets mainLayout = QtGui.QVBoxLayout(self) mainLayout.addSpacing(8) mainLayout.addWidget(self._tabs, 0) mainLayout.addLayout(buttonLayout, 0) self.setLayout(mainLayout) # Prevent resizing self.show() self.setMinimumSize(500, 400) self.resize(640, 500)
def __init__(self, parent): QtGui.QWidget.__init__(self, parent) # Make sure there is a configuration entry for this tool # The pyzo tool manager makes sure that there is an entry in # config.tools before the tool is instantiated. toolId = self.__class__.__name__.lower() self._config = pyzo.config.tools[toolId] if not hasattr(self._config, 'showTypes'): self._config.showTypes = ['class', 'def', 'cell', 'todo'] if not hasattr(self._config, 'level'): self._config.level = 2 # Create icon for slider self._sliderIcon = QtGui.QToolButton(self) self._sliderIcon.setIcon(pyzo.icons.text_align_right) self._sliderIcon.setIconSize(QtCore.QSize(16, 16)) self._sliderIcon.setStyleSheet( "QToolButton { border: none; padding: 0px; }") # Create slider self._slider = QtGui.QSlider(QtCore.Qt.Horizontal, self) self._slider.setTickPosition(QtGui.QSlider.TicksBelow) self._slider.setSingleStep(1) self._slider.setPageStep(1) self._slider.setRange(1, 9) self._slider.setValue(self._config.level) self._slider.valueChanged.connect(self.updateStructure) # Create options button #self._options = QtGui.QPushButton(self) #self._options.setText('Options')) #self._options.setToolTip("What elements to show.") self._options = QtGui.QToolButton(self) self._options.setIcon(pyzo.icons.filter) self._options.setIconSize(QtCore.QSize(16, 16)) self._options.setPopupMode(self._options.InstantPopup) self._options.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon) # Create options menu self._options._menu = QtGui.QMenu() self._options.setMenu(self._options._menu) # Create tree widget self._tree = QtGui.QTreeWidget(self) self._tree.setHeaderHidden(True) self._tree.itemCollapsed.connect(self.updateStructure) # keep expanded self._tree.itemClicked.connect(self.onItemClick) # Create two sizers self._sizer1 = QtGui.QVBoxLayout(self) self._sizer2 = QtGui.QHBoxLayout() self._sizer1.setSpacing(2) self._sizer1.setContentsMargins(4, 4, 4, 4) # Set layout self._sizer1.addLayout(self._sizer2, 0) self._sizer1.addWidget(self._tree, 1) self._sizer2.addWidget(self._sliderIcon, 0) self._sizer2.addWidget(self._slider, 4) self._sizer2.addStretch(1) self._sizer2.addWidget(self._options, 2) # self.setLayout(self._sizer1) # Init current-file name self._currentEditorId = 0 # Bind to events pyzo.editors.currentChanged.connect(self.onEditorsCurrentChanged) pyzo.editors.parserDone.connect(self.updateStructure) self._options.pressed.connect(self.onOptionsPress) self._options._menu.triggered.connect(self.onOptionMenuTiggered) # Start # When the tool is loaded, the editorStack is already done loading # all previous files and selected the appropriate file. self.onOptionsPress() # Create menu now self.onEditorsCurrentChanged()
def __init__(self, parent): QtGui.QFrame.__init__(self, parent) # Init config toolId = self.__class__.__name__.lower() self._config = pyzo.config.tools[toolId] if not hasattr(self._config, 'zoomFactor'): self._config.zoomFactor = 1.0 if not hasattr(self._config, 'bookMarks'): self._config.bookMarks = [] for item in default_bookmarks: if item not in self._config.bookMarks: self._config.bookMarks.append(item) # Get style object (for icons) style = QtGui.QApplication.style() # Create some buttons self._back = QtGui.QToolButton(self) self._back.setIcon(style.standardIcon(style.SP_ArrowBack)) self._back.setIconSize(QtCore.QSize(16, 16)) # self._forward = QtGui.QToolButton(self) self._forward.setIcon(style.standardIcon(style.SP_ArrowForward)) self._forward.setIconSize(QtCore.QSize(16, 16)) # Create address bar #self._address = QtGui.QLineEdit(self) self._address = QtGui.QComboBox(self) self._address.setEditable(True) self._address.setInsertPolicy(self._address.NoInsert) # for a in self._config.bookMarks: self._address.addItem(a) self._address.setEditText('') # Create web view if imported_qtwebkit: self._view = QtWebKit.QWebView(self) else: self._view = WebView(self) # # self._view.setZoomFactor(self._config.zoomFactor) # settings = self._view.settings() # settings.setAttribute(settings.JavascriptEnabled, True) # settings.setAttribute(settings.PluginsEnabled, True) # Layout self._sizer1 = QtGui.QVBoxLayout(self) self._sizer2 = QtGui.QHBoxLayout() # self._sizer2.addWidget(self._back, 0) self._sizer2.addWidget(self._forward, 0) self._sizer2.addWidget(self._address, 1) # self._sizer1.addLayout(self._sizer2, 0) self._sizer1.addWidget(self._view, 1) # self._sizer1.setSpacing(2) self.setLayout(self._sizer1) # Bind signals self._back.clicked.connect(self.onBack) self._forward.clicked.connect(self.onForward) self._address.lineEdit().returnPressed.connect(self.go) self._address.activated.connect(self.go) self._view.loadFinished.connect(self.onLoadEnd) self._view.loadStarted.connect(self.onLoadStart) # Start self._view.show() self.go('http://docs.python.org')
def __init__(self, parent=None, collection_filename=None): """ Initializes an assistance instance. When collection_file is none, it is determined from the appDataDir. """ from pyzolib.qt import QtHelp super().__init__(parent) self.setWindowTitle('Help') pyzoDir, appDataDir = getResourceDirs() if collection_filename is None: # Collection file is stored in pyzo data dir: collection_filename = os.path.join(appDataDir, 'tools', 'docs.qhc') self._engine = QtHelp.QHelpEngine(collection_filename) # Important, call setup data to load the files: self._engine.setupData() # If no files are loaded, register at least the pyzo docs: if len(self._engine.registeredDocumentations()) == 0: doc_file = os.path.join(pyzoDir, 'resources', 'pyzo.qch') ok = self._engine.registerDocumentation(doc_file) # The main players: self._content = self._engine.contentWidget() self._index = self._engine.indexWidget() self._indexTab = QtGui.QWidget() il = QtGui.QVBoxLayout(self._indexTab) filter_text = QtGui.QLineEdit() il.addWidget(filter_text) il.addWidget(self._index) self._helpBrowser = HelpBrowser(self._engine) self._searchEngine = self._engine.searchEngine() self._settings = Settings(self._engine) self._progress = QtGui.QWidget() pl = QtGui.QHBoxLayout(self._progress) bar = QtGui.QProgressBar() bar.setMaximum(0) pl.addWidget(QtGui.QLabel('Indexing')) pl.addWidget(bar) self._searchResultWidget = self._searchEngine.resultWidget() self._searchQueryWidget = self._searchEngine.queryWidget() self._searchTab = QtGui.QWidget() search_layout = QtGui.QVBoxLayout(self._searchTab) search_layout.addWidget(self._searchQueryWidget) search_layout.addWidget(self._searchResultWidget) tab = QtGui.QTabWidget() tab.addTab(self._content, "Contents") tab.addTab(self._indexTab, "Index") tab.addTab(self._searchTab, "Search") tab.addTab(self._settings, "Settings") splitter = QtGui.QSplitter(self) splitter.addWidget(tab) splitter.addWidget(self._helpBrowser) layout = QtGui.QVBoxLayout(self) layout.addWidget(splitter) layout.addWidget(self._progress) # Connect clicks: self._content.linkActivated.connect(self._helpBrowser.setSource) self._index.linkActivated.connect(self._helpBrowser.setSource) self._searchEngine.searchingFinished.connect(self.onSearchFinish) self._searchEngine.indexingStarted.connect(self.onIndexingStarted) self._searchEngine.indexingFinished.connect(self.onIndexingFinished) filter_text.textChanged.connect(self._index.filterIndices) self._searchResultWidget.requestShowLink.connect( self._helpBrowser.setSource) self._searchQueryWidget.search.connect(self.goSearch) # Always re-index on startup: self._searchEngine.reindexDocumentation() self._search_term = None # Show initial page: # self.showHelpForTerm('welcome to pyzo') self._helpBrowser.setHtml(help_help)