Esempio n. 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)
Esempio n. 2
0
    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
Esempio n. 3
0
 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)
Esempio n. 4
0
    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)
Esempio n. 5
0
 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())