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.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 loadIcons(): """ loadIcons() Load all icons in the icon dir. """ # Get directory containing the icons iconDir = os.path.join(pyzo.pyzoDir, 'resources', 'icons') # Construct other icons dummyIcon = IconArtist().finish() pyzo.icons = ssdf.new() for fname in os.listdir(iconDir): if fname.startswith('pyzo'): continue if fname.endswith('.png'): try: # Short and full name name = fname.split('.')[0] ffname = os.path.join(iconDir, fname) # Create icon icon = QtGui.QIcon() icon.addFile(ffname, QtCore.QSize(16, 16)) # Store pyzo.icons[name] = icon except Exception as err: pyzo.icons[name] = dummyIcon print('Could not load icon %s: %s' % (fname, str(err)))
def loadAppIcons(): """ loadAppIcons() Load the application iconsr. """ # Get directory containing the icons appiconDir = os.path.join(pyzo.pyzoDir, 'resources', 'appicons') # Determine template for filename of the application icon-files. fnameT = 'pyzologo{}.png' # Construct application icon. Include a range of resolutions. Note that # Qt somehow does not use the highest possible res on Linux/Gnome(?), even # the logo of qt-designer when alt-tabbing looks a bit ugly. pyzo.icon = QtGui.QIcon() for sze in [16, 32, 48, 64, 128, 256]: fname = os.path.join(appiconDir, fnameT.format(sze)) if os.path.isfile(fname): pyzo.icon.addFile(fname, QtCore.QSize(sze, sze)) # Set as application icon. This one is used as the default for all # windows of the application. QtGui.qApp.setWindowIcon(pyzo.icon) # Construct another icon to show when the current shell is busy artist = IconArtist(pyzo.icon) # extracts the 16x16 version artist.setPenColor('#0B0') for x in range(11, 16): d = x - 11 # runs from 0 to 4 artist.addLine(x, 6 + d, x, 15 - d) pm = artist.finish().pixmap(16, 16) # pyzo.iconRunning = QtGui.QIcon(pyzo.icon) pyzo.iconRunning.addPixmap(pm) # Change only 16x16 icon
def __init__(self): QtGui.QToolButton.__init__(self) # Init self.setIconSize(QtCore.QSize(*self.SIZE)) self.setStyleSheet( "QToolButton{ border:none; padding:0px; margin:0px; }") self.setIcon(self.getCrossIcon1())
def __init__(self): QtGui.QToolButton.__init__(self) # Init self.setIconSize(QtCore.QSize(*self.SIZE)) self.setStyleSheet("QToolButton{ border: none; }") # Create arrow pixmaps self._menuarrow1 = self._createMenuArrowPixmap(0) self._menuarrow2 = self._createMenuArrowPixmap(70) self._menuarrow = self._menuarrow1 # Variable to keep icon self._icon = None # Variable to keep track of when the mouse was pressed, so that # we can allow dragging as well as clicking the menu. self._menuPressed = False
def __init__(self, parent): QtGui.QWidget.__init__(self, parent) # create toolbar self._toolbar = QtGui.QToolBar(self) self._toolbar.setMaximumHeight(25) self._toolbar.setIconSize(QtCore.QSize(16, 16)) # create stack self._stack = QtGui.QStackedWidget(self) # Populate toolbar self._shellButton = ShellControl(self._toolbar, self._stack) self._debugmode = 0 self._dbs = DebugStack(self._toolbar) # self._toolbar.addWidget(self._shellButton) self._toolbar.addSeparator() # self._toolbar.addWidget(self._dbc) -> delayed, see addContextMenu() self._condahelp = CondaHelper(self) # widget layout layout = QtGui.QVBoxLayout() layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self._toolbar) layout.addWidget(self._stack, 0) layout.addWidget(self._condahelp, 0) self.setLayout(layout) # make callbacks self._stack.currentChanged.connect(self.onCurrentChanged) # Make shared history (shared among shells) if PythonHistory is None: self.sharedHistory = None else: self.sharedHistory = PythonHistory('shellhistory.py') self.showCondaHelper()
def __init__(self, *args): QtGui.QToolButton.__init__(self, *args) # Init self.setIconSize(QtCore.QSize(*self.SIZE)) self.setStyleSheet("QToolButton{ border: none; }")
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')