def _createWidgets(self): # Create list object and label self.lblProjects = QtGui.QLabel('Projects (drag to change the order):', self) self.lstProjects = DraggableList(self) # Create add and remove buttons self.btnAdd = QtGui.QPushButton('New project', self) self.btnAdd.setIcon(iep.icons.add) self.btnRemove = QtGui.QPushButton('Remove selected', self) self.btnRemove.setIcon(iep.icons.delete) # Create fields for description and path self.lblDescription = QtGui.QLabel('Description:', self) self.txtDescription = QtGui.QLineEdit(self) self.lblPath = QtGui.QLabel('Path:', self) self.txtPath = QtGui.QLineEdit(self) self.txtPath.setReadOnly(True) self.chkAddToPath = QtGui.QCheckBox('Add path to Python path', self) # Done button self.btnDone = QtGui.QPushButton("Done", self) self.btnDone.setDefault(True) # Layout L2 = QtGui.QHBoxLayout() L2.addWidget(self.btnAdd) L2.addStretch(1.0) L2.addWidget(self.btnRemove) # L1 = QtGui.QVBoxLayout() L1.addWidget(self.lblProjects) L1.addWidget(self.lstProjects) L1.addLayout(L2) # L4 = QtGui.QHBoxLayout() L4.addStretch(1.0) L4.addWidget(self.btnDone) # L3 = QtGui.QVBoxLayout() L3.addWidget(self.lblDescription) L3.addWidget(self.txtDescription) L3.addWidget(self.lblPath) L3.addWidget(self.txtPath) L3.addWidget(self.chkAddToPath) L3.addStretch(1.0) L3.addLayout(L4) # theLayout = QtGui.QHBoxLayout(self) theLayout.addLayout(L1) theLayout.addLayout(L3) self.setLayout(theLayout)
def __init__(self, parent): QtGui.QWidget.__init__(self, parent) # 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 tree self._tree = WorkspaceTree(self) # Set layout layout = QtGui.QHBoxLayout() layout.addWidget(self._up, 0) layout.addWidget(self._line, 1) # mainLayout = QtGui.QVBoxLayout(self) mainLayout.addLayout(layout, 0) mainLayout.addWidget(self._tree, 1) mainLayout.setSpacing(2) self.setLayout(mainLayout) # Bind up event self._up.pressed.connect(self._tree._proxy.goUp)
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(iep.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.addStretch(1) self._sizer2.addWidget(self._options, 2) # self._sizer1.addLayout(self._sizer2, 0) self._sizer1.addWidget(self._browser, 1) # self._sizer1.setSpacing(2) self.setLayout(self._sizer1) # Set config toolId = self.__class__.__name__.lower() self._config = config = iep.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, i): BaseIEPWizardPage.__init__(self, parent, i) # Create label and checkbox t1 = translate('wizard', "This wizard can be opened using 'Help > IEP 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 = iep.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 iep.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) self.layout().addWidget(self._check_show)
def __init__(self, parent): QtGui.QWidget.__init__(self, parent) # Create layout self._formLayout = QtGui.QFormLayout(self) # 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) self._shellInfoWidgets[t.key] = instance # Create label label = QtGui.QLabel(t, self) 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) instance = QtGui.QPushButton(iep.icons.cancel, t, self) 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.setLayout(self._formLayout)
def __init__(self, parent): QtGui.QWidget.__init__(self, parent) self._left = LogoWidget(self) self._right = LabelWidget(self) # 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' if iep.pyzo_mode else 'ieplogo256.png' iconImage = os.path.join(iep.iepDir, 'resources', 'appicons', iconImage) iconImage = iconImage.replace(os.path.sep, '/') # Fix for Windows self.setStyleSheet(STYLESHEET % iconImage)
def __init__(self, parent): QtGui.QWidget.__init__(self, parent) # Make sure there is a configuration entry for this tool # The IEP tool manager makes sure that there is an entry in # config.tools before the tool is instantiated. toolId = self.__class__.__name__.lower() self._config = iep.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(iep.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(iep.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() # 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._sizer1.setSpacing(2) self.setLayout(self._sizer1) # Init current-file name self._currentEditorId = 0 # Bind to events iep.editors.currentChanged.connect(self.onEditorsCurrentChanged) iep.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.QWidget.__init__(self, parent) # Init config toolId = self.__class__.__name__.lower() self.config = iep.config.tools[toolId] if not hasattr(self.config, 'projects'): self.config.projects = [] if not hasattr(self.config, 'activeproject'): self.config.activeproject = -1 if not hasattr(self.config, 'filter'): self.config.filter = '!*.pyc' if not hasattr(self.config, 'listdisclosed'): self.config.listdisclosed = True # Create example? if not self.config.projects: exampleProject = Project('Example', os.path.expanduser('~')) self.config.projects.append(exampleProject) self.config.activeproject = 0 #Init projects model self.projectsModel = ProjectsModel(self.config) #Init dir model and filtered dir model self.dirModel = QtGui.QFileSystemModel() #TODO: using the default IconProvider bugs on mac, restoring window state fails self.dirModel.setIconProvider(IconProviderWindows()) #TODO: self.dirModel.setSorting(QtCore.QDir.DirsFirst) # todo: huh? QFileSystemModel.setSorting Does not exist self.filteredDirModel = DirSortAndFilter() self.filteredDirModel.setSourceModel(self.dirModel) #Init widgets and layout self.buttonLayout = QtGui.QVBoxLayout() self.configButton = QtGui.QPushButton(self) self.configButton.setIcon(iep.icons.wrench) self.configButton.setIconSize(QtCore.QSize(16, 16)) self.buttonLayout.addWidget(self.configButton, 0) self.buttonLayout.addStretch(1) self.projectsCombo = QtGui.QComboBox() self.projectsCombo.setModel(self.projectsModel) self.hLayout = QtGui.QHBoxLayout() self.hLayout.addWidget(self.projectsCombo, 1) self.hLayout.addLayout(self.buttonLayout, 0) self.dirList = QtGui.QTreeView() self.dirList.setHeaderHidden(True) # The lessThan function in DirSortAndFilter ensures dirs are before files self.dirList.sortByColumn(0, QtCore.Qt.AscendingOrder) self.filterCombo = QtGui.QComboBox() self.layout = QtGui.QVBoxLayout() self.layout.addWidget(DeprLabel(self)) self.layout.addLayout(self.hLayout) self.layout.addWidget(self.dirList, 10) self.layout.addWidget(self.filterCombo) self.setLayout(self.layout) #Load projects in the list self.projectsCombo.show() #Load default filters self.filterCombo.setEditable(True) self.filterCombo.setCompleter(None) self.filterCombo.setInsertPolicy(self.filterCombo.NoInsert) for pattern in [ '*', '!*.pyc', '*.py *.pyw *.pyx *.pxd', '*.h *.c *.cpp' ]: self.filterCombo.addItem(pattern) self.filterCombo.editTextChanged.connect(self.filterChanged) # Set file pattern line edit (in combobox) self.filterPattern = self.filterCombo.lineEdit() self.filterPattern.setText(self.config.filter) self.filterPattern.setToolTip('File filter pattern') #Connect signals self.projectsCombo.currentIndexChanged.connect(self.comboChangedEvent) self.dirList.doubleClicked.connect(self.itemDoubleClicked) self.configButton.clicked.connect(self.showConfigDialog) #Apply previous selected project self.activeProject = None self.projectChanged(self.config.activeproject) #Attach the context menu self.dirList.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.dirList.customContextMenuRequested.connect( self.contextMenuTriggered)
def __init__(self, *args): QtGui.QDialog.__init__(self, *args) self.setModal(True) # Set title self.setWindowTitle(iep.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 pyzolib.interpreters import get_interpreters self.interpreters = list(reversed(get_interpreters('2.4'))) # Introduce an entry if there's none if not iep.config.shellConfigs2: w = ShellInfoTab(self._tabs) self._tabs.addTab(w, '---') w.setInfo() # Fill tabs for item in iep.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(iep.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() size = self.size() self.setMinimumSize(size) self.setMaximumHeight(size.height())
def __init__(self, parent): QtGui.QFrame.__init__(self, parent) # Init config toolId = self.__class__.__name__.lower() self._config = iep.config.tools[toolId] if not hasattr(self._config, 'zoomFactor'): self._config.zoomFactor = 1.0 if not hasattr(self._config, 'bookMarks'): self._config.bookMarks = default_bookmarks # 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 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, *args): QtGui.QFrame.__init__(self, *args) self.setFocusPolicy(QtCore.Qt.ClickFocus) # init layout layout = QtGui.QHBoxLayout(self) layout.setSpacing(0) self.setLayout(layout) # Create some widgets first to realize a correct tab order self._hidebut = QtGui.QToolButton(self) self._findText = QtGui.QLineEdit(self) self._replaceText = QtGui.QLineEdit(self) if True: # Create sub layouts vsubLayout = QtGui.QVBoxLayout() vsubLayout.setSpacing(0) layout.addLayout(vsubLayout, 0) # Add button self._hidebut.setFont( QtGui.QFont('helvetica',7) ) self._hidebut.setToolTip(translate('search', 'Hide search widget (Escape)')) self._hidebut.setIcon( iep.icons.cancel ) self._hidebut.setIconSize(QtCore.QSize(16,16)) vsubLayout.addWidget(self._hidebut, 0) vsubLayout.addStretch(1) layout.addSpacing(10) if True: # Create sub layouts vsubLayout = QtGui.QVBoxLayout() hsubLayout = QtGui.QHBoxLayout() vsubLayout.setSpacing(0) hsubLayout.setSpacing(0) layout.addLayout(vsubLayout, 0) # Add find text self._findText.setToolTip(translate('search', 'Find pattern')) vsubLayout.addWidget(self._findText, 0) vsubLayout.addLayout(hsubLayout) # Add previous button self._findPrev = QtGui.QToolButton(self) t = translate('search', 'Previous ::: Find previous occurance of the pattern.') self._findPrev.setText(t); self._findPrev.setToolTip(t.tt) hsubLayout.addWidget(self._findPrev, 0) hsubLayout.addStretch(1) # Add next button self._findNext = QtGui.QToolButton(self) t = translate('search', 'Next ::: Find next occurance of the pattern.') self._findNext.setText(t); self._findNext.setToolTip(t.tt) #self._findNext.setDefault(True) # Not possible with tool buttons hsubLayout.addWidget(self._findNext, 0) layout.addSpacing(10) if True: # Create sub layouts vsubLayout = QtGui.QVBoxLayout() hsubLayout = QtGui.QHBoxLayout() vsubLayout.setSpacing(0) hsubLayout.setSpacing(0) layout.addLayout(vsubLayout, 0) # Add replace text self._replaceText.setToolTip(translate('search', 'Replace pattern')) vsubLayout.addWidget(self._replaceText, 0) vsubLayout.addLayout(hsubLayout) # Add replace-all button self._replaceAll = QtGui.QToolButton(self) t = translate('search', 'Repl. all ::: Replace all matches in current document.') self._replaceAll.setText(t); self._replaceAll.setToolTip(t.tt) hsubLayout.addWidget(self._replaceAll, 0) hsubLayout.addStretch(1) # Add replace button self._replace = QtGui.QToolButton(self) t = translate('search', 'Replace ::: Replace this match.') self._replace.setText(t); self._replace.setToolTip(t.tt) hsubLayout.addWidget(self._replace, 0) layout.addSpacing(10) if True: # Create sub layouts vsubLayout = QtGui.QVBoxLayout() vsubLayout.setSpacing(0) layout.addLayout(vsubLayout, 0) # Add match-case checkbox t = translate('search', 'Match case ::: Find words that match case.') self._caseCheck = QtGui.QCheckBox(t, self) self._caseCheck.setToolTip(t.tt) vsubLayout.addWidget(self._caseCheck, 0) # Add regexp checkbox t = translate('search', 'RegExp ::: Find using regular expressions.') self._regExp = QtGui.QCheckBox(t, self) self._regExp.setToolTip(t.tt) vsubLayout.addWidget(self._regExp, 0) if True: # Create sub layouts vsubLayout = QtGui.QVBoxLayout() vsubLayout.setSpacing(0) layout.addLayout(vsubLayout, 0) # Add whole-word checkbox t = translate('search', 'Whole words ::: Find only whole words.') self._wholeWord = QtGui.QCheckBox(t, self) self._wholeWord.setToolTip(t.tt) self._wholeWord.resize(60, 16) vsubLayout.addWidget(self._wholeWord, 0) # Add autohide dropbox t = translate('search', 'Auto hide ::: Hide search/replace when unused for 10 s.') self._autoHide = QtGui.QCheckBox(t, self) self._autoHide.setToolTip(t.tt) self._autoHide.resize(60, 16) vsubLayout.addWidget(self._autoHide, 0) layout.addStretch(1) # Set placeholder texts for lineEdit in [self._findText, self._replaceText]: if hasattr(lineEdit, 'setPlaceholderText'): lineEdit.setPlaceholderText(lineEdit.toolTip()) lineEdit.textChanged.connect(self.autoHideTimerReset) # Set focus policy for but in [self._findPrev, self._findNext, self._replaceAll, self._replace, self._caseCheck, self._wholeWord, self._regExp]: #but.setFocusPolicy(QtCore.Qt.ClickFocus) but.clicked.connect(self.autoHideTimerReset) # create timer objects self._timerBeginEnd = QtCore.QTimer(self) self._timerBeginEnd.setSingleShot(True) self._timerBeginEnd.timeout.connect( self.resetAppearance ) # self._timerAutoHide = QtCore.QTimer(self) self._timerAutoHide.setSingleShot(False) self._timerAutoHide.setInterval(500) # ms self._timerAutoHide.timeout.connect( self.autoHideTimerCallback ) self._timerAutoHide_t0 = time.time() self._timerAutoHide.start() # create callbacks self._findText.returnPressed.connect(self.findNext) self._hidebut.clicked.connect(self.hideMe) self._findNext.clicked.connect(self.findNext) self._findPrev.clicked.connect(self.findPrevious) self._replace.clicked.connect(self.replaceOne) self._replaceAll.clicked.connect(self.replaceAll) # self._regExp.stateChanged.connect(self.handleReplacePossible) # init case and regexp self._caseCheck.setChecked( bool(iep.config.state.find_matchCase) ) self._regExp.setChecked( bool(iep.config.state.find_regExp) ) self._wholeWord.setChecked( bool(iep.config.state.find_wholeWord) ) self._autoHide.setChecked( bool(iep.config.state.find_autoHide) ) # show or hide? if bool(iep.config.state.find_show): self.show() else: self.hide()