Beispiel #1
0
    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)
Beispiel #2
0
    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)
Beispiel #3
0
 def __init__(self, parent, widget, systemValue):
     # Do not pass parent, because is a sublayout
     QtGui.QVBoxLayout.__init__(self) 
     
     # Layout
     self.setSpacing(1)
     self.addWidget(widget)
     
     # Create checkbox widget
     if not self.DISABLE_SYSTEM_DEFAULT:
         t = translate('shell', 'Use system default')
         self._check = QtGui.QCheckBox(t, parent)
         self._check.stateChanged.connect(self.onCheckChanged)
         self.addWidget(self._check)
     
     # The actual value of this shell config attribute
     self._value = ''
     
     # The value of self._value if the system default is selected
     self._systemValue = systemValue
     
     # A buffered version, so that clicking the text box does not
     # remove the value at once
     self._bufferedValue = ''
Beispiel #4
0
 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()