def createLayerToolbar(self): """ TOWRITE """ toolbarLayer = self.toolbarLayer actionHash = self.actionHash layerSelector = self.layerSelector qDebug("MainWindow createLayerToolbar()") toolbarLayer.setObjectName("toolbarLayer") toolbarLayer.addAction(actionHash["ACTION_makelayercurrent"]) toolbarLayer.addAction(actionHash["ACTION_layers"]) icontheme = self.getSettingsGeneralIconTheme() # QString layerSelector.setFocusProxy(self.prompt) # NOTE: Qt4.7 wont load icons without an extension... # TODO: Create layer pixmaps by concatenating several icons layerSelector.addItem(QIcon("icons/" + icontheme + "/" + "linetypebylayer" + ".png"), "0") layerSelector.addItem(QIcon("icons/" + icontheme + "/" + "linetypebylayer" + ".png"), "1") layerSelector.addItem(QIcon("icons/" + icontheme + "/" + "linetypebylayer" + ".png"), "2") layerSelector.addItem(QIcon("icons/" + icontheme + "/" + "linetypebylayer" + ".png"), "3") layerSelector.addItem(QIcon("icons/" + icontheme + "/" + "linetypebylayer" + ".png"), "4") layerSelector.addItem(QIcon("icons/" + icontheme + "/" + "linetypebylayer" + ".png"), "5") layerSelector.addItem(QIcon("icons/" + icontheme + "/" + "linetypebylayer" + ".png"), "6") layerSelector.addItem(QIcon("icons/" + icontheme + "/" + "linetypebylayer" + ".png"), "7") layerSelector.addItem(QIcon("icons/" + icontheme + "/" + "linetypebylayer" + ".png"), "8") layerSelector.addItem(QIcon("icons/" + icontheme + "/" + "linetypebylayer" + ".png"), "9") toolbarLayer.addWidget(layerSelector) self.connect(layerSelector, SIGNAL("currentIndexChanged(int)"), self, SLOT("layerSelectorIndexChanged(int)")) toolbarLayer.addAction(actionHash["ACTION_layerprevious"]) self.connect(toolbarLayer, SIGNAL("topLevelChanged(bool)"), self, SLOT("floatingChangedToolBar(bool)"))
def CreateActions(self): """ Function to create actions for menus """ self.newAction = QAction(QIcon('new.png'), '&New', self, shortcut=QKeySequence.New, statusTip="Create a New File", triggered=self.newFile) self.copyAction = QAction(QIcon('copy.png'), 'C&opy', self, shortcut="Ctrl+C", statusTip="Copy", triggered=self.textEdit.copy) self.pasteAction = QAction(QIcon('paste.png'), '&Paste', self, shortcut="Ctrl+V", statusTip="Paste", triggered=self.textEdit.paste) self.aboutAction = QAction(QIcon('about.png'), 'A&bout', self, statusTip="Displays info about text editor", triggered=self.aboutHelp) self.exitAction = QAction(QIcon('exit.png'), 'E&xit', self, shortcut="Ctrl+Q", statusTip="Exit the Application", triggered=self.exitFile)
def run(self): mw = self.mw if mw.google_radio.isChecked(): mw.setStatusTip("Loading...") mw.start_button.setText("Loading...") mw.setEnabled(False) try: streetdb = table2dbf.load_from_google(mw.username.text(), mw.password.text(), mw.document_id.text()) except: import traceback traceback.print_exc() self.mbox = ("Google-Fail", QMessageBox.Warning, QIcon.fromTheme("dialog-warning"), "Couldn't login or load data from google!", None) return else: streetdb = table2dbf.load_street_db(mw.csv_file.text()) mw.setStatusTip("Updating...") mw.start_button.setText("Updating...") try: table = dbf.Table(mw.dbf_file.text()) table.open() self.updates = table2dbf.update_table(table, streetdb) table.close() except dbf.DbfError as e: self.mbox = ("DB-Fail", QMessageBox.Warning, QIcon.fromTheme("dialog-warning"), "Couldn't open/update table!", e.message) return self.streetdb = streetdb if mw.split_check.checkState(): import split_dbf split_dbf.split_files(mw.dbf_file.text())
def check_image(self): if self._image: if os.path.exists(self.save_path): self.btnDownload.setIcon(QIcon(":/check.png")) return True self.btnDownload.setIcon(QIcon(":/folder.png")) return False
def show_calorie_calc(self, row_count=0): ''' show calorie calculator :return: ''' if row_count > 0: row_count += 1 self.clear_table(None, None) self.stuff_table.clearContents() self.stuff_table.setColumnCount(3) self.stuff_table.setRowCount(row_count) self.stuff_table.setHorizontalHeaderLabels(['Amount', 'Unit', 'Name']) if row_count > 0: stuff_widget = QWidget() stuff_pixmap = QPixmap('icons/add.png') stuff_icon = QIcon() stuff_add_bt = QToolButton() stuff_icon.addPixmap(stuff_pixmap) stuff_add_bt.setIcon(stuff_icon) stuff_add_bt.setIconSize(QSize(8, 8)) stuff_add_bt.clicked.connect( lambda: self.stuff_table.insertRow(row_count - 1)) stuff_layout = QHBoxLayout() stuff_layout.addWidget(stuff_add_bt) stuff_widget.setLayout(stuff_layout) self.stuff_table.setCellWidget(row_count - 1, 2, stuff_widget)
def __init__(self, app, *args, **kwargs): QDialog.__init__(self, *args, **kwargs) self.app = app self.closed = False self.sort_order = None self.ui = Ui_List() self.ui.setupUi(self) self.setWindowIcon(get_icon()) self.notebooksModel = QStandardItemModel() self.ui.notebooksList.setModel(self.notebooksModel) self.ui.notebooksList.selection.connect(self.selection_changed) self.ui.notebooksList.setContextMenuPolicy(Qt.CustomContextMenu) self.ui.notebooksList.customContextMenuRequested.connect(self.notebook_context_menu) self.notesModel = QStandardItemModel() self.notesModel.setHorizontalHeaderLabels( [self.tr('Title'), self.tr('Last Updated')]) self.ui.notesList.setModel(self.notesModel) self.ui.notesList.doubleClicked.connect(self.note_dblclicked) self.ui.notesList.setContextMenuPolicy(Qt.CustomContextMenu) self.ui.notesList.customContextMenuRequested.connect(self.note_context_menu) self.ui.notesList.header().sortIndicatorChanged.connect(self.sort_order_updated) self.ui.newNotebookBtn.setIcon(QIcon.fromTheme('folder-new')) self.ui.newNotebookBtn.clicked.connect(self.new_notebook) self.ui.newNoteBtn.setIcon(QIcon.fromTheme('document-new')) self.ui.newNoteBtn.clicked.connect(self.new_note) self.ui.newNoteBtn.setShortcut(QKeySequence(self.tr('Ctrl+n'))) self.ui.newNotebookBtn.setShortcut(QKeySequence(self.tr('Ctrl+Shift+n'))) QShortcut(QKeySequence(self.tr('Ctrl+q')), self, self.close)
def createWidgets(self): self.listWidget = Widgets.List.HtmlListWidget(self.state) self.tooltips.append((self.listWidget, """\ <p><b>Recreatable Entries view</b></p> <p>The list of this index's recreatable entries.</p>""")) self.recreateSubentriesCheckBox = QCheckBox("Recreate &Subentries") self.recreateSubentriesCheckBox.setChecked(True) self.tooltips.append((self.recreateSubentriesCheckBox, """\ <p><b>Recreate Subentries</b></p> <p>If checked, when an entry or subentry is recreated, all of its subentries, and their subentries, and so on (if any), will also be recrected if possible.</p>""")) self.recreateButton = QPushButton(QIcon(":/recreate.svg"), "&Recreate") self.recreateButton.setDefault(True) self.recreateButton.setAutoDefault(True) self.tooltips.append((self.recreateButton, """\ <p><b>Recreate</b></p> <p>Recreate the current entry or subentry (and its subentries and their subentries, and so on, if the <b>Recreate Subentries</b> checkbox is checked), and then close the dialog.</p> <p>Note that it is possible to get rid of the recreated entries by clicking <b>Index→Undo</b> immediately after the dialog closes. (Or, at any later time by simply deleting them.)""")) self.deleteButton = QPushButton(QIcon(":/delete.svg"), "&Delete...") self.tooltips.append((self.deleteButton, """\ <p><b>Delete</b></p> <p>Permanently delete the current recreatable entry or subentry from this index's list of recreatable entries.</p>""")) self.helpButton = QPushButton(QIcon(":/help.svg"), "Help") self.tooltips.append( (self.helpButton, "Help on the Recreate Entries dialog")) self.closeButton = QPushButton(QIcon(":/dialog-close.svg"), "&Close") self.tooltips.append((self.closeButton, """<p><b>Close</b></p> <p>Close the dialog.</p>"""))
def _reload_notebooks_list(self, select_notebook_id=None): # TODO could enable selecting an already selected stack self.notebooksModel.clear() root = QStandardItem(QIcon.fromTheme('user-home'), self.tr('All Notes')) self.notebooksModel.appendRow(root) selected_item = root stacks = {} for notebook_struct in self.app.provider.list_notebooks(): notebook = Notebook.from_tuple(notebook_struct) count = self.app.provider.get_notebook_notes_count(notebook.id) item = QNotebookItem(notebook, count) if (notebook.stack == ''): root.appendRow(item) else: if (notebook.stack not in stacks.keys()): stack = QStandardItem(QIcon.fromTheme('user-home'), notebook.stack) stack.stack = notebook.stack root.appendRow(stack) stacks[notebook.stack] = stack stacks[notebook.stack].appendRow(item) if select_notebook_id and notebook.id == select_notebook_id: selected_item = item self.ui.notebooksList.expandAll() if selected_item and not select_notebook_id == SELECT_NONE: index = self.notebooksModel.indexFromItem(selected_item) self.ui.notebooksList.setCurrentIndex(index) self.notebook_selected(index)
def createActions(self): """ Function to create actions for menus """ self.newAction=QAction( QIcon(), '&New', self, shortcut=QKeySequence.New, statusTip="Create a New file" ) self.exitAction=QAction( QIcon(), '&Exit', self, shortcut="Ctrl+Q", statusTip="Exit the application", triggered=self.exitFile ) self.copyAction=QAction( QIcon(), '&Copy', self, shortcut="Ctrl+C", statusTip="Copy", triggered=self.textEdit.copy ) self.pasteAction=QAction( QIcon(), '&Paste', self, shortcut="Ctrl+V", triggered=self.textEdit.paste) self.aboutAction=QAction( QIcon(), '&About', self, statusTip="Displays info", triggered=self.aboutHelp )
def __init__(self, app, *args, **kwargs): QDialog.__init__(self, *args, **kwargs) self.app = app self.closed = False self.sort_order = None self.ui = Ui_List() self.ui.setupUi(self) self.setWindowIcon(get_icon()) self.notebooksModel = QStandardItemModel() self.ui.notebooksList.setModel(self.notebooksModel) self.ui.notebooksList.selection.connect(self.selection_changed) self.ui.notebooksList.setContextMenuPolicy(Qt.CustomContextMenu) self.ui.notebooksList.customContextMenuRequested.connect( self.notebook_context_menu) self.notesModel = QStandardItemModel() self.notesModel.setHorizontalHeaderLabels( [self.tr('Title'), self.tr('Last Updated')]) self.ui.notesList.setModel(self.notesModel) self.ui.notesList.doubleClicked.connect(self.note_dblclicked) self.ui.notesList.setContextMenuPolicy(Qt.CustomContextMenu) self.ui.notesList.customContextMenuRequested.connect( self.note_context_menu) self.ui.notesList.header().sortIndicatorChanged.connect( self.sort_order_updated) self.ui.newNotebookBtn.setIcon(QIcon.fromTheme('folder-new')) self.ui.newNotebookBtn.clicked.connect(self.new_notebook) self.ui.newNoteBtn.setIcon(QIcon.fromTheme('document-new')) self.ui.newNoteBtn.clicked.connect(self.new_note)
def __init__(self, parent=None, warningAction=None, warningService=None): """ Constructor @param parent: Qt widget parent of this dialog window @type parent: QWidget @param warningAction: The action to connect to. @type warningAction: QAction """ super(WarningsDialog, self).__init__(parent) self.setupUi(self) self.setWarningAction(warningAction) self.setWarningService(warningService) self.statusBarService = StatusBarService() self.errorString = "" self.errorMsgTextEdit.setPlainText(self.errorString) self.iconWarning = QIcon() self.iconWarning.addPixmap( QPixmap( ":/tango-status-32px/images/tango-icon-theme/32x32/status/weather-severe-alert.png" ), QIcon.Normal, QIcon.Off) self.iconNoWarning = QIcon() self.iconNoWarning.addPixmap( QPixmap( ":/tango-status-32px/images/tango-icon-theme/32x32/status/weather-clear.png" ), QIcon.Normal, QIcon.Off)
def __init__(self, parent=None, warningAction=None, warningService=None): """ Constructor @param parent: Qt widget parent of this dialog window @type parent: QWidget @param warningAction: The action to connect to. @type warningAction: QAction """ super(WarningsDialog, self).__init__(parent) self.setupUi(self) self.setWarningAction(warningAction) self.setWarningService(warningService) self.statusBarService = StatusBarService() self.errorString = "" self.errorMsgTextEdit.setPlainText(self.errorString) self.iconWarning = QIcon() self.iconWarning.addPixmap(QPixmap(":/tango-status-32px/images/tango-icon-theme/32x32/status/weather-severe-alert.png"), QIcon.Normal, QIcon.Off) self.iconNoWarning = QIcon() self.iconNoWarning.addPixmap(QPixmap(":/tango-status-32px/images/tango-icon-theme/32x32/status/weather-clear.png"), QIcon.Normal, QIcon.Off)
def initUI(self): # Create container for action buttons self.actionContainer = ButtonContainer() self.parameterModel = ParameterModel() self.parameterView = ParameterListView() self.parameterView.setAttribute(Qt.WA_MacShowFocusRect, False) self.parameterView.setRootIsDecorated(False) self.parameterView.setModel(self.parameterModel) # Create a main layout (vertical) for this widget self.layout = QVBoxLayout() self.layout.setSpacing(0) self.layout.setContentsMargins(0, 0, 0, 0) self.layout.addWidget(self.parameterView) self.layout.addWidget(self.actionContainer) self.setLayout(self.layout) # Add a button to the container addButton = QPushButton() addButton.setIcon(QIcon(AppVars.imagePath() + "AddButton.png")) addButton.clicked.connect(self.addButtonClicked) self.actionContainer.addButton(addButton) removeButton = QPushButton() removeButton.setIcon(QIcon(AppVars.imagePath() + "RemoveButton.png")) removeButton.clicked.connect(self.removeButtonClicked) self.actionContainer.addButton(removeButton)
def createWidgets(self): self.extensionLabel = QLabel("&Extension") self.extensionComboBox = QComboBox() for markup in self.state.model.markups(): self.extensionComboBox.addItem(markup) self.tooltips.append((self.extensionComboBox, """\ <p><b>Extension</b></p> <p>Choose the file extension to view and edit its custom markup.</p>""")) self.extensionLabel.setBuddy(self.extensionComboBox) self.helpButton = QPushButton(QIcon(":/help.svg"), "Help") self.tooltips.append( (self.helpButton, "Help on the Custom Markup dialog")) self.addButton = QPushButton(QIcon(":/add.svg"), "&Add...") self.tooltips.append((self.addButton, """\ <p><b>Add</b></p> <p>Add a new custom markup to the index.</p>""")) self.deleteButton = QPushButton(QIcon(":/delete.svg"), "&Delete...") self.tooltips.append((self.deleteButton, """\ <p><b>Delete</b></p> <p>Permanently delete the custom markup from the index's <tt>.xix</tt> file. (Note that <tt>.ucp</tt> custom markup cannot be deleted.)</p>""")) self.closeButton = QPushButton(QIcon(":/dialog-close.svg"), "&Close") self.tooltips.append((self.closeButton, """<p><b>Close</b></p> <p>Close the dialog.</p>""")) self.tabWidget = QTabWidget() self.documentPanel = CustomMarkupPanels.Document.Panel( self.state, self) self.characterPanel = CustomMarkupPanels.Character.Panel( self.state, self) self.tabWidget.addTab(self.documentPanel, "D&ocument") self.tabWidget.addTab(self.characterPanel, "C&haracter")
def get_tray_icon(is_black=False): if os.environ.get('DESKTOP_SESSION', 'default') == 'gnome': return QIcon.fromTheme('everpad', QIcon('../../data/everpad.png')) if is_black: return QIcon.fromTheme('everpad-black', QIcon('../../data/everpad-black.png')) else: return QIcon.fromTheme('everpad-mono', QIcon('../../data/everpad-mono.png'))
def __init__(self, switcherState, parent=None): super(AllInputsPanel, self).__init__(parent) self.switcherState = switcherState self.selectedInput = None self.page = 0 self.sources = [] self.layout = QGridLayout() self.input_buttons = QButtonGroup() self.btnPageUp = ExpandingButton() self.btnPageUp.setIcon(QIcon(":icons/go-up")) self.btnPageUp.clicked.connect(lambda: self.setPage(self.page - 1)) self.layout.addWidget(self.btnPageUp, 0, 5, 3, 1) self.btnPageDown = ExpandingButton() self.btnPageDown.setIcon(QIcon(":icons/go-down")) self.btnPageDown.clicked.connect(lambda: self.setPage(self.page + 1)) self.layout.addWidget(self.btnPageDown, 3, 5, 3, 1) for col in range(5): self.layout.setColumnStretch(col, 1) for row in range(3): btn = InputButton(None) self.layout.addWidget(btn, row * 2, col, 2, 1) self.input_buttons.addButton(btn) btn.clicked.connect(self.selectInput) btn.setFixedWidth(120) self.setLayout(self.layout) self.switcherState.inputsChanged.connect(self.setSources) self.setSources() self.displayInputs()
def note_context_menu(self, pos): menu = QMenu(self.ui.notesList) menu.addAction(QIcon.fromTheme('gtk-edit'), self.tr('Edit'), self.edit_note) menu.addAction(QIcon.fromTheme('gtk-delete'), self.tr('Remove'), self.remove_note) menu.exec_(self.ui.notesList.mapToGlobal(pos))
def __init__(self,winTitle='Rotate WP', icon='rotWP.svg'): super(rotWPForm,self).__init__() self.move(QPoint(100,250)) self.setWindowFlags(Qt.WindowStaysOnTopHint) self.setWindowTitle(winTitle) iconPath=join(dirname(abspath(__file__)),"icons",icon) from PySide.QtGui import QIcon Icon=QIcon() Icon.addFile(iconPath) self.setWindowIcon(Icon) self.grid=QGridLayout() self.setLayout(self.grid) self.radioX=QRadioButton('X') self.radioX.setChecked(True) self.radioY=QRadioButton('Y') self.radioZ=QRadioButton('Z') self.lab1=QLabel('Angle:') self.edit1=QLineEdit('45') self.edit1.setAlignment(Qt.AlignCenter) self.edit1.setValidator(QDoubleValidator()) self.btn1=QPushButton('Rotate working plane') self.btn1.clicked.connect(self.rotate) self.grid.addWidget(self.radioX,0,0,1,1,Qt.AlignCenter) self.grid.addWidget(self.radioY,0,1,1,1,Qt.AlignCenter) self.grid.addWidget(self.radioZ,0,2,1,1,Qt.AlignCenter) self.grid.addWidget(self.lab1,1,0,1,1) self.grid.addWidget(self.edit1,1,1,1,2) self.grid.addWidget(self.btn1,2,0,1,3,Qt.AlignCenter) self.show() self.sg=FreeCADGui.ActiveDocument.ActiveView.getSceneGraph() s=FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft").GetInt("gridSize") sc=[float(x*s) for x in [1,1,.2]] from polarUtilsCmd import arrow self.arrow =arrow(FreeCAD.DraftWorkingPlane.getPlacement(),scale=sc,offset=s)
def createWidgets(self): self.termLabelLabel = QLabel("Term") self.termLabel = Widgets.Label.HtmlLabel() self.originalPagesLabel = Widgets.Label.HtmlLabel() self.originalPagesLabel.setStyleSheet(_BG_SAME) self.combinedPagesLabel = Widgets.Label.HtmlLabel() self.combinedPagesLabel.setStyleSheet(_BG_SAME) self.buttonBox = QDialogButtonBox() self.combineButton = QPushButton(QIcon(":/combinepages.svg"), "Co&mbine") self.tooltips.append((self.combineButton, """\ <p><b>Combine</b></p> <p>Combine overlapping pages as shown, and move to the next term with overlapping pages.</p>""")) self.buttonBox.addButton(self.combineButton, QDialogButtonBox.ActionRole) self.skipButton = QPushButton(QIcon(":/skip.svg"), "S&kip") self.tooltips.append((self.skipButton, """\ <p><b>Skip</b></p> <p>Skip this term's overlapping pages, and move to the next term with overlapping pages.</p>""")) self.buttonBox.addButton(self.skipButton, QDialogButtonBox.ActionRole) self.closeButton = QPushButton(QIcon(":/dialog-close.svg"), "&Close") self.tooltips.append((self.closeButton, """<p><b>Close</b></p> <p>Close the dialog.</p>""")) self.buttonBox.addButton(self.closeButton, QDialogButtonBox.RejectRole) self.helpButton = QPushButton(QIcon(":/help.svg"), "Help") self.tooltips.append( (self.helpButton, "Help on the Combine Overlapping Pages dialog")) self.buttonBox.addButton(self.helpButton, QDialogButtonBox.HelpRole)
def __init__(self, parent=None): super(TouchSpinner, self).__init__(parent) self._value = 50 self._max = 100 self._min = 0 layout = QHBoxLayout() self.btnMinus = ExpandingButton() self.btnMinus.setIcon(QIcon(":icons/list-remove")) self.btnMinus.setText("-") self.btnMinus.clicked.connect(lambda: self.setValue(self._value - 1)) layout.addWidget(self.btnMinus, 1) self.lblValue = QLabel(self.formattedValue(self._value)) self.lblValue.setAlignment(Qt.AlignHCenter) layout.addWidget(self.lblValue, 1) self.btnPlus = ExpandingButton() self.btnPlus.setIcon(QIcon(":icons/list-add")) self.btnPlus.setText("+") self.btnPlus.clicked.connect(lambda: self.setValue(self._value + 1)) layout.addWidget(self.btnPlus, 1) self.setLayout(layout)
def __init__(self): super(SafeLock, self).__init__() main_layout = QVBoxLayout(self) self.Version = '0.5 beta' self.s_error = "QStatusBar{color:red;font-weight:1000;}" self.s_loop = "QStatusBar{color:black;font-weight:1000;}" self.s_norm = "QStatusBar{color:blue;font-style:italic;" self.s_norm += "font-weight:500;}" self.Processing = None self.CP = None self.PPbar = None self.key = None self.DFiles = [] self.picon = r_path("images/favicon.png") self.plogo = r_path("images/logo.png") if name == 'nt': self.picon = r_path("images\\favicon.png") self.plogo = r_path("images\\logo.png") self.icon = QIcon(self.picon) self.logo = QIcon(self.plogo) self.center() self.setStyle() self.setMW(main_layout) self.setSB(main_layout) self.show()
def _createToolBarActions(self): self.rizzoProduceAction = QtGui.QAction(QIcon(self.iconp + 'tag-add.png'), '&Generate Rizzo signatures', self, triggered=self._rizzo_produce) self.rizzoLoadAction = QtGui.QAction(QIcon(self.iconp + 'tag-icon.png'), '&Apply Rizzo signatures', self, triggered=self._rizzo_load) self.codatifyFixCode = QtGui.QAction(QIcon(self.iconp + 'processor-icon.png'), '&Fix Code', self, triggered=self._codatify_fix_code) self.codatifyFixData = QtGui.QAction(QIcon(self.iconp + 'server_components.png'), '&Fix Data', self, triggered=self._codatify_fix_data) self.toolbar.addAction(self.rizzoProduceAction) self.toolbar.addAction(self.rizzoLoadAction) self.toolbar.addSeparator() self.toolbar.addAction(self.codatifyFixCode) self.toolbar.addAction(self.codatifyFixData)
def _reload_notebooks_list(self, select_notebook_id=None): # TODO could enable selecting an already selected stack self.notebooksModel.clear() root = QStandardItem(QIcon.fromTheme('user-home'), self.tr('All Notes')) self.notebooksModel.appendRow(root) selected_item = root stacks = {} for notebook_struct in self.app.provider.list_notebooks(): notebook = Notebook.from_tuple(notebook_struct) count = self.app.provider.get_notebook_notes_count(notebook.id) item = QNotebookItem(notebook, count) if(notebook.stack == ''): root.appendRow(item) else: if(notebook.stack not in stacks.keys()): stack = QStandardItem(QIcon.fromTheme('user-home'), notebook.stack) stack.stack = notebook.stack root.appendRow(stack) stacks[notebook.stack] = stack stacks[notebook.stack].appendRow(item) if select_notebook_id and notebook.id == select_notebook_id: selected_item = item self.ui.notebooksList.expandAll() if selected_item and not select_notebook_id == SELECT_NONE: index = self.notebooksModel.indexFromItem(selected_item) self.ui.notebooksList.setCurrentIndex(index) self.notebook_selected(index)
def paint(self, painter, option, index): painter.save() index0 = index.sibling( index.row(), 0 ) utype = index0.data( Qt.UserRole ) # # set background color if option.state & QStyle.State_Selected: painter.setPen ( Qt.NoPen ) painter.setBrush( GraphTreeItemDelegate._backgroundBrushSelected ) painter.drawRect(option.rect) elif option.state & QStyle.State_MouseOver: painter.setPen ( Qt.NoPen ) painter.setBrush( GraphTreeItemDelegate._backgroundBrushHovered ) painter.drawRect(option.rect) rect = option.rect icon = QIcon( index.data( Qt.DecorationRole) ) rect.adjust( 5, 0, 0, 0 ) if icon and not icon.isNull(): icon.paint( painter, rect, Qt.AlignLeft ) rect.adjust( 22, 0, 0, 0 ) text = index.data(Qt.DisplayRole) if utype == 1: #GROUP painter.setPen( GraphTreeItemDelegate._textPenGroup ) else: painter.setPen( GraphTreeItemDelegate._textPen ) painter.drawText( rect, Qt.AlignLeft | Qt.AlignVCenter, text ) painter.restore()
def update_icon(self): if int(self.settings.value('black-icon', 0)): self.icon = QIcon.fromTheme('everpad-black', QIcon('../../data/everpad-black.png')) else: self.icon = QIcon.fromTheme('everpad-mono', QIcon('../../data/everpad-mono.png')) self.indicator.setIcon(self.icon)
def notebook_context_menu(self, pos): index = self.ui.notebooksList.currentIndex() item = self.notebooksModel.itemFromIndex(index) if hasattr(item, 'notebook'): menu = QMenu(self.ui.notebooksList) menu.addAction(QIcon.fromTheme('gtk-edit'), self.tr('Rename'), self.rename_notebook) menu.addAction(QIcon.fromTheme('gtk-delete'), self.tr('Remove'), self.remove_notebook) menu.exec_(self.ui.notebooksList.mapToGlobal(pos))
def __init__(self,winTitle='Title', PType='Pipe', PRating='SCH-STD', icon='flamingo.svg'): ''' __init__(self,winTitle='Title', PType='Pipe', PRating='SCH-STD') winTitle: the window's title PType: the pipeFeature type PRating: the pipeFeature pressure rating class It lookups in the directory ./tables the file PType+"_"+PRating+".csv", imports it's content in a list of dictionaries -> .pipeDictList and shows a summary in the QListWidget -> .sizeList Also create a property -> PRatingsList with the list of available PRatings for the selected PType. ''' super(protopypeForm,self).__init__() self.move(QPoint(100,250)) self.PType=PType self.PRating=PRating self.setWindowFlags(Qt.WindowStaysOnTopHint) self.setWindowTitle(winTitle) iconPath=join(dirname(abspath(__file__)),"icons",icon) from PySide.QtGui import QIcon Icon=QIcon() Icon.addFile(iconPath) self.setWindowIcon(Icon) self.mainHL=QHBoxLayout() self.setLayout(self.mainHL) self.firstCol=QWidget() self.firstCol.setLayout(QVBoxLayout()) self.mainHL.addWidget(self.firstCol) self.currentRatingLab=QLabel('Rating: '+self.PRating) self.firstCol.layout().addWidget(self.currentRatingLab) self.sizeList=QListWidget() self.firstCol.layout().addWidget(self.sizeList) self.pipeDictList=[] self.fileList=listdir(join(dirname(abspath(__file__)),"tables")) self.fillSizes() self.PRatingsList=[s.lstrip(PType+"_").rstrip(".csv") for s in self.fileList if s.startswith(PType) and s.endswith('.csv')] self.secondCol=QWidget() self.secondCol.setLayout(QVBoxLayout()) self.combo=QComboBox() self.combo.addItem('<none>') try: self.combo.addItems([o.Label for o in FreeCAD.activeDocument().Objects if hasattr(o,'PType') and o.PType=='PypeLine']) except: None self.combo.currentIndexChanged.connect(self.setCurrentPL) if FreeCAD.__activePypeLine__ and FreeCAD.__activePypeLine__ in [self.combo.itemText(i) for i in range(self.combo.count())]: self.combo.setCurrentIndex(self.combo.findText(FreeCAD.__activePypeLine__)) self.secondCol.layout().addWidget(self.combo) self.ratingList=QListWidget() self.ratingList.addItems(self.PRatingsList) self.ratingList.itemClicked.connect(self.changeRating) self.ratingList.setCurrentRow(0) self.secondCol.layout().addWidget(self.ratingList) self.btn1=QPushButton('Insert') self.secondCol.layout().addWidget(self.btn1) self.mainHL.addWidget(self.secondCol) self.resize(350,350) self.mainHL.setContentsMargins(0,0,0,0)
def apply_status_to_icon(icon, index_status, work_tree_status): result = QIcon() overlay = status_icon[index_status, work_tree_status] for size in icon.availableSizes(): pixmap = icon.pixmap(size).copy() x, y = (size - overlay.size()).toTuple() QPainter(pixmap).drawPixmap(x, y, overlay) result.addPixmap(pixmap) return result
def __init__(self, hyperdeck, state, mainWindow): super(RecorderClipSelectionScreen, self).__init__() self.hyperdeck = hyperdeck self.state = state self.mainWindow = mainWindow self.selected_clip = None layout = QGridLayout() lblTitle = TitleLabel("Select clip") layout.addWidget(lblTitle, 0, 0, 1, 3) self.clipTable = QTableWidget() self.clipTable.setColumnCount(2) self.clipTable.setHorizontalHeaderLabels(['ID', 'Clip name']) self.clipTable.horizontalHeader().setStretchLastSection(True) self.clipTable.setSelectionBehavior( QAbstractItemView.SelectionBehavior.SelectRows) self.clipTable.itemSelectionChanged.connect(self._onClipSelected) layout.addWidget(self.clipTable, 1, 0, 1, 3) b = ExpandingButton() b.setText("Back") b.setIcon(QIcon(":icons/go-previous")) b.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon) b.clicked.connect(mainWindow.stepBack) layout.addWidget(b, 2, 0) btnRefresh = ExpandingButton() btnRefresh.setText('Refresh') btnRefresh.setIcon(QIcon(':icons/refresh')) btnRefresh.setToolButtonStyle( Qt.ToolButtonStyle.ToolButtonTextBesideIcon) def refresh(): self.populateClipsList({}) hyperdeck.broadcastClipsList() btnRefresh.clicked.connect(refresh) layout.addWidget(btnRefresh, 2, 1) self.btnSelect = ExpandingButton() self.btnSelect.setText("Cue clip") self.btnSelect.clicked.connect(self._cueClip) layout.addWidget(self.btnSelect, 2, 2) layout.setRowStretch(0, 0) layout.setRowStretch(1, 1) layout.setRowStretch(2, 0) self.setLayout(layout) self.populateClipsList(state.clip_listing)
def __init__(self, parent=uic.getMayaWindow()): super(Submitter, self).__init__(parent) self.setupUi(self) self.__colors_mapping__ = { 'Red': 4, 'Green': 14, 'Yellow': 17, 'Black': 1 } self.progressBar.hide() self.collapsed = False self.stop = False self.breakdownWindow = None self.addButton.setIcon(QIcon(osp.join(icon_path, 'ic_add.png'))) self.collapseButton.setIcon( QIcon(osp.join(icon_path, 'ic_toggle_collapse'))) self.deleteSelectedButton.setIcon( QIcon(osp.join(icon_path, 'ic_delete.png'))) self.sceneBreakdownButton.setIcon( QIcon(osp.join(icon_path, 'ic_update.png'))) search_ic_path = osp.join(icon_path, 'ic_search.png').replace('\\', '/') style_sheet = ('\nbackground-image: url(%s);' + '\nbackground-repeat: no-repeat;' + '\nbackground-position: center left;') % search_ic_path style_sheet = self.searchBox.styleSheet() + style_sheet self.searchBox.setStyleSheet(style_sheet) self.collapseButton.clicked.connect(self.toggleCollapseAll) self.addButton.clicked.connect(self.showForm) self.selectAllButton.clicked.connect(self.selectAll) self.deleteSelectedButton.clicked.connect(self.deleteSelected) self.searchBox.textChanged.connect(self.searchShots) self.searchBox.returnPressed.connect( lambda: self.searchShots(str(self.searchBox.text()))) self.exportButton.clicked.connect(self.export) self.browseButton.clicked.connect(self.browseFolder) self.cacheEnableAction.triggered.connect(self.enableCacheSelected) self.cacheDisableAction.triggered.connect(self.disableCacheSelected) self.playblastEnableAction.triggered.connect( self.enablePlayblastSelected) self.playblastDisableAction.triggered.connect( self.disablePlayblastSelected) self.sceneBreakdownButton.clicked.connect(self.sceneBreakdown) self.stopButton.clicked.connect(self.setStop) self.hdButton.toggled.connect(self.hdToggled) self._playlist = Playlist() self.items = [] self.populate() self.applyCacheButton.hide() self.audioButton.hide() self.stopButton.hide() self.sceneBreakdownButton.hide() self.hdButton.hide() self.defaultResolutionButton.hide() self.localButton.hide() self.hdOnlyButton.hide() return
def _init_window(self): """Init window attributes""" self.setWindowTitle('Series list') if os.path.exists(const.ICON_PATH): icon = QIcon() icon.addFile(const.ICON_PATH) else: icon = QIcon.fromTheme('series_list_icon') self.setWindowIcon(icon)
def setAbout(self, m): self.pushButton = QPushButton() self.icon1 = QIcon() self.icon1.addPixmap(QPixmap(self.plogo), QIcon.Normal, QIcon.Off) self.pushButton.setIcon(self.icon1) self.pushButton.setIconSize(QSize(300, 100)) self.pushButton.clicked.connect(self.show_about) m.addWidget(self.pushButton)
def createWidgets(self): self.fontLabel = QLabel("Fon&t:") self.fontComboBox = QFontComboBox() self.tooltips.append((self.fontComboBox, """\ <p><b>Font</b></p> <p>The font for displaying the characters.</p>""")) self.fontLabel.setBuddy(self.fontComboBox) self.sizeLabel = QLabel("&Size:") self.sizeComboBox = QComboBox() self.tooltips.append((self.sizeComboBox, """\ <p><b>Size</b></p> <p>The size of font for displaying the characters.</p>""")) self.sizeLabel.setBuddy(self.sizeComboBox) self.scrollArea = QScrollArea() self.scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.panel = Panel() self.scrollArea.setWidget(self.panel) self.copyTextLabel = QLabel("Copy T&ext") self.copyTextLineEdit = QLineEdit() self.tooltips.append((self.copyTextLineEdit, """\ <p><b>Copy Text editor</b></p> <p>The text for copying to the clipboard when <b>Copy</b> is pressed.</p>""")) self.copyTextLabel.setBuddy(self.copyTextLineEdit) self.findTextLabel = QLabel("&Find Text") self.findTextLineEdit = QLineEdit() self.tooltips.append((self.findTextLineEdit, """\ <p><b>Find Text editor</b></p> <p>The name or partial name of Unicode characters to be found, e.g., “star” will match many characters, including U+22C6 “Star operator”.</p>""")) self.findTextLabel.setBuddy(self.findTextLineEdit) self.buttonBox = QDialogButtonBox() self.addSelectedButton = QPushButton(QIcon(":/add.svg"), "&Add Selected") self.tooltips.append((self.addSelectedButton, """\ <p><b>Add Selected</b></p> <p>Append the selected character to the <b>Copy Text</b> editor.</p>""")) self.buttonBox.addButton(self.addSelectedButton, QDialogButtonBox.ActionRole) self.findNextButton = QPushButton(QIcon(":/edit-find.svg"), "Find &Next") self.tooltips.append((self.findNextButton, """\ <p><b>Find Next</b></p> <p>Find the next character whose Unicode name contains or equals the <b>Find Text</b>.</p>""")) self.buttonBox.addButton(self.findNextButton, QDialogButtonBox.ActionRole) self.helpButton = QPushButton(QIcon(":/help.svg"), "Help") self.tooltips.append( (self.helpButton, "Help on the Copy Character dialog")) self.buttonBox.addButton(self.helpButton, QDialogButtonBox.HelpRole) self.closeButton = QPushButton(QIcon(":/dialog-close.svg"), "&Close") self.tooltips.append((self.closeButton, """<p><b>Cancel</b></p> <p>Close the dialog.</p>""")) self.buttonBox.addButton(self.closeButton, QDialogButtonBox.RejectRole)
def set_pixmap_as_icon(self, pixmap): self.pixmap_as_icon = pixmap if pixmap: icon = QIcon(pixmap) self.setIconSize(QSize(pixmap.width(), pixmap.height())) self.setIcon(pixmap) else: self.setIcon(QIcon())
def initUI(self): programIcon = QIcon('img/download.png') infoIcon = QIcon('img/info.png') if is_keyplus_device(self.device): self.setup_keyplus_label() elif is_xusb_bootloader_device(self.device): self.setup_xusb_bootloader_label() elif is_nrf24lu1p_bootloader_device(self.device): self.setup_nrf24lu1p_label() else: raise Exception("Unsupported USB device {}:{}".format( self.device.vendor_id, self.device.product_id)) if self.label == None: return self.label.setTextInteractionFlags(Qt.TextSelectableByMouse) self.label.setStyleSheet(""" QLabel { background: #FFF; border: 1px solid; padding: 2px; font: 11pt; } """) self.label.setFixedHeight(90) self.label.setMinimumWidth(390) self.programButton = QPushButton(' Program') self.programButton.setIcon(programIcon) self.programButton.clicked.connect(self.programSignal) if is_bootloader_device(self.device): self.secondaryButton = QPushButton('Reset') self.secondaryButton.clicked.connect(self.resetSignal) else: self.secondaryButton = QPushButton('Info') self.secondaryButton.setIcon(infoIcon) self.secondaryButton.clicked.connect(self.infoSignal) self.layout = QGridLayout() self.layout.addWidget(self.label, 0, 0, 2, 1) self.layout.addWidget(self.programButton, 0, 1) self.layout.addWidget(self.secondaryButton, 1, 1) self.setLayout(self.layout) self.setMaximumHeight(150) self.setContentsMargins(0, 0, 0, 0) self.setStyleSheet(""" QGroupBox { border: 1px solid #CCC; } """)
def init_toolbar(self): self.save_btn = self.ui.toolBar.addAction(QIcon.fromTheme("document-save"), self.tr("Save"), self.save) self.close_btn = self.ui.toolBar.addAction( QIcon.fromTheme("window-close"), self.tr("Close without saving"), self.close ) self.ui.toolBar.addAction(QIcon.fromTheme("edit-delete"), self.tr("Remove note"), self.delete) self.print_btn = self.ui.toolBar.addAction( QIcon.fromTheme("document-print"), self.tr("Print note"), self.note_edit.print_ ) self.email_btn = self.ui.toolBar.addAction( QIcon.fromTheme("mail-unread"), self.tr("Email note"), self.note_edit.email_note ) self.email_btn = self.ui.toolBar.addAction( QIcon.fromTheme("emblem-shared"), self.tr("Share note"), self.share_note ) self.ui.toolBar.addSeparator() for action in self.note_edit.get_format_actions(): self.ui.toolBar.addAction(action) self.ui.toolBar.addSeparator() self.find_action = QAction(QIcon.fromTheme("edit-find"), self.tr("Find"), self) self.find_action.setCheckable(True) self.find_action.triggered.connect(self.findbar.toggle_visible) self.ui.toolBar.addAction(self.find_action) self.ui.toolBar.addSeparator() self.pin = self.ui.toolBar.addAction( QIcon.fromTheme("edit-pin", QIcon.fromTheme("everpad-pin")), self.tr("Pin note"), self.mark_touched ) self.pin.setCheckable(True) self.pin.setChecked(self.note.pinnded)
def createWidgets(self): self.backButton = QToolButton() self.backButton.setIcon(QIcon(":/go-back.svg")) self.backButton.setText("&Back") self.backButton.setToolTip("""\ <p><b>Back</b> ({})</p> <p>Navigate to the previous page.</p>""".format( QKeySequence("Alt+Left").toString())) self.forwardButton = QToolButton() self.forwardButton.setIcon(QIcon(":/go-forward.svg")) self.forwardButton.setText("&Forward") self.forwardButton.setToolTip("""\ <p><b>Forward</b> ({})</p> <p>Navigate to the page you've just come back from.</p>""".format( QKeySequence("Alt+Right").toString())) self.contentsButton = QToolButton() self.contentsButton.setIcon(QIcon(":/go-home.svg")) self.contentsButton.setText("&Contents") self.contentsButton.setToolTip("""\ <p><b>Contents</b> ({})</p> <p>Navigate to the contents page.</p>""".format( QKeySequence("Alt+Home").toString())) self.searchLineEdit = Widgets.LegendLineEdit.LineEdit( "Search (F3 or Ctrl+F)") self.searchLineEdit.setToolTip("""\ <p><b>Search editor</p> <p>Type in a word to search for in the online help pages and press <b>Enter</b> or <b>F3</b> to search.</p>""") self.zoomInButton = QToolButton() self.zoomInButton.setIcon(QIcon(":/zoomin.svg")) self.zoomInButton.setText("&Zoom In") self.zoomInButton.setToolTip("""\ <p><b>Zoom In</b> ({})</p> <p>Make the text bigger.</p>""".format( QKeySequence("Alt++").toString())) self.zoomOutButton = QToolButton() self.zoomOutButton.setIcon(QIcon(":/zoomout.svg")) self.zoomOutButton.setText("Zoom &Out") self.zoomOutButton.setToolTip("""\ <p><b>Zoom Out</b> ({})</p> <p>Make the text smaller.</p>""".format( QKeySequence("Alt+-").toString())) width = self.fontMetrics().width(self.zoomOutButton.text() + " ") for button in (self.backButton, self.forwardButton, self.contentsButton, self.zoomInButton, self.zoomOutButton): button.setToolButtonStyle(Qt.ToolButtonTextUnderIcon) button.setMinimumWidth(width) button.setFocusPolicy(Qt.NoFocus) self.browser = QWebView() page = self.browser.page() page.setLinkDelegationPolicy(QWebPage.DelegateAllLinks) if self.debug: self.urlLabel = QLabel()
def get(name): if QFile('icons:{}.svg'.format(name)).exists(): return QIcon('icons:{}.svg'.format(name)) if QIcon.hasThemeIcon(name): return QIcon.fromTheme(name) if os.path.exists(name): return QIcon(name) return QIcon()
def _get_icon(self, icons): """Get icon""" if len(icons): icon, other = icons[0], icons[1:] fallback = self._get_icon(other) if fallback: return QIcon.fromTheme(icon, fallback=fallback) else: return QIcon.fromTheme(icon) else: return None
def __init__(self, parent=None): super(About, self).__init__(parent) icon = QIcon() icon.addPixmap( QPixmap(":/Images/aktools_48x48.png"), QIcon.Normal, QIcon.Off) self.setWindowIcon(icon) self.setWindowTitle("Tietoja") label = QLabel("Tehnyt: Aleksi Kauppila 2014") layout = QVBoxLayout() layout.addWidget(label) self.setLayout(layout)
def _action_with_icon(self, action_type, icon_names, is_action=False): if is_action: action = action_type else: action = self.page.action(action_type) for icon_name in icon_names: if QIcon.hasThemeIcon(icon_name): action.setIcon(QIcon.fromTheme(icon_name)) break self.copy_available.connect(action.setEnabled) return action
def on_filter_change_text(self, text): """ Apply filter string """ if len(text): icon = QIcon(':/filtersOn.png') self.filter_reset_btn.setIcon(icon) else: icon = QIcon(':/filtersOff.png') self.filter_reset_btn.setIcon(icon) self.files_model.setNameFilters([ '*%s*' % item.strip() for item in text.split(',') if item.strip() ])
def __init__(self, amount_files, parent=None): super(Progressbar, self).__init__(parent) self.amount_files = amount_files self.setWindowTitle("Mitataan...") icon = QIcon() icon.addPixmap( QPixmap(":/Images/aktools_48x48.png"), QIcon.Normal, QIcon.Off) self.setWindowIcon(icon) self.setMinimum(0) self.setMaximum(self.amount_files) self.setValue(0)
def by_name(name): """Locates and loads an icon for the user, finding by name""" filename = os.path.join(ICONROOT, "%s.png" % name) if os.path.isfile(filename): #pixmap = QPixmap(filename) #icon = QIcon(pixmap) icon = QIcon(filename) return icon if QIcon.hasThemeIcon(name): return QIcon.fromTheme(name) raise KeyError, "No such icon %s exists." % name
def _init_interface(self): self.ui = Ui_List() self.ui.setupUi(self) self.setWindowIcon(get_icon()) self.setWindowTitle(self.tr("Everpad / All Notes")) self.ui.newNotebookBtn.setIcon(QIcon.fromTheme('folder-new')) self.ui.newNotebookBtn.clicked.connect(self.new_notebook) self.ui.newNoteBtn.setIcon(QIcon.fromTheme('document-new')) self.ui.newNoteBtn.clicked.connect(self.new_note) self.ui.newNoteBtn.setShortcut(QKeySequence(self.tr('Ctrl+n'))) self.ui.newNotebookBtn.setShortcut(QKeySequence(self.tr('Ctrl+Shift+n'))) QShortcut(QKeySequence(self.tr('Ctrl+q')), self, self.close)
def init_toolbar(self): self.save_btn = self.ui.toolBar.addAction(QIcon.fromTheme("document-save"), self.tr("Save"), self.save) self.ui.toolBar.addAction(QIcon.fromTheme("cancel"), self.tr("Close without saving"), self.close) self.ui.toolBar.addAction(QIcon.fromTheme("edit-delete"), self.tr("Remove note"), self.delete) self.ui.toolBar.addSeparator() for action in self.note_edit.get_format_actions(): self.ui.toolBar.addAction(action) self.ui.toolBar.addSeparator() self.ui.toolBar.addAction(QIcon.fromTheme("add"), self.tr("Attache file"), self.resource_edit.add) self.ui.toolBar.addSeparator() self.options = self.ui.toolBar.addAction( QIcon.fromTheme("gtk-properties"), self.tr("Options"), self.show_options ) self.options.setCheckable(True)
def __getitem__(self, path): icon = QIcon() has_images = False with disposable_hicon(get_file_icon(path)) as hicon: pixmap = pixmap_from_hicon(hicon) if pixmap: icon.addPixmap(pixmap) has_images = True with disposable_hicon(get_file_icon(path, large=True)) as hicon: pixmap = pixmap_from_hicon(hicon) if pixmap: icon.addPixmap(pixmap) has_images = True if has_images: return icon return self.qt_provider.icon(QFileIconProvider.File)
def setup_gui(self): """Sets up a sample gui interface.""" central_widget = QWidget(self) central_widget.setObjectName('central_widget') self.label = QLabel('Hello World') self.input_field = QLineEdit() change_button = QPushButton('Change text') close_button = QPushButton('close') quit_button = QPushButton('quit') central_layout = QVBoxLayout() button_layout = QHBoxLayout() central_layout.addWidget(self.label) central_layout.addWidget(self.input_field) # a separate layout to display buttons horizontal button_layout.addWidget(change_button) button_layout.addWidget(close_button) button_layout.addWidget(quit_button) central_layout.addLayout(button_layout) central_widget.setLayout(central_layout) self.setCentralWidget(central_widget) # create a system tray icon. Uncomment the second form, to have an # icon assigned, otherwise you will only be seeing an empty space in # system tray self.systemtrayicon = QSystemTrayIcon(self) self.systemtrayicon.show() # set a fancy icon self.systemtrayicon.setIcon(QIcon.fromTheme('help-browser')) change_button.clicked.connect(self.change_text) quit_button.clicked.connect(QApplication.instance().quit) close_button.clicked.connect(self.hide) # show main window, if the system tray icon was clicked self.systemtrayicon.activated.connect(self.icon_activated)
def __init__(self, parent=None): super(LoginForm, self).__init__(parent) self.setWindowTitle("Login") self.status_icon = QIcon.fromTheme("user-offline") self.setWindowIcon(self.status_icon) self.server_status = QLabel() self.server_status.setAlignment(Qt.AlignCenter) self.server_status.setPixmap(self.status_icon.pixmap(64)) self.username = QLineEdit("Username") self.password = QLineEdit("Password") self.password.setEchoMode(QLineEdit.Password) self.login_button = QPushButton("Getting server status...") self.login_button.setEnabled(False) self.login_button.clicked.connect(self.login) self.login_button.setIcon(self.status_icon) self.ping_timer = QTimer(self) self.connect(self.ping_timer, SIGNAL("timeout()"), self.is_server_up) self.ping_timer.start(1000) layout = QVBoxLayout() for w in (self.server_status, self.username, self.password, self.login_button): layout.addWidget(w) self.setLayout(layout) self.logged_in.connect(qtclient.login)
def setupActions(self): action_slots = dict( New=self.newFile, Open=self.askOpenFile, Save=self.saveFile, SaveAs=self.askSaveFile, Print=self.askPrint, Quit=self.close, Undo=self.editor.undo, Redo=self.editor.redo, Cut=self.editor.cut, Copy=self.editor.copy, Paste=self.editor.paste, Find=self.toggleSearchDock, FindNext=self.find, FindPrevious=partial(self.find, backwards=True), SelectAll=self.editor.selectAll, GoToLine=self.askGoToLine, AboutQt=QApplication.instance().aboutQt, About=self.about) for action in self.findChildren(QAction): object_name = action.objectName() if not object_name: continue action_name = object_name[len(self.ACTION_PREFIX):] icon_name = self.ACTION_ICONS.get(action_name) if icon_name: action.setIcon(QIcon.fromTheme(icon_name)) key = self.ACTION_KEYS.get(action_name) if key: action.setShortcut(key) slot = action_slots.get(action_name) if slot: action.triggered.connect(slot) if action_name in self.DISABLED_ACTIONS: action.setEnabled(False) for action in self.menuEdit.actions(): self.editor.addAction(action)
def tag_context_menu(self, pos): index = self.ui.tagsList.currentIndex() item = self.tagsModel.itemFromIndex(index) if hasattr(item, 'tag'): menu = QMenu(self.ui.tagsList) menu.addAction(QIcon.fromTheme('gtk-delete'), self.tr('Remove'), self.remove_tag) menu.exec_(self.ui.tagsList.mapToGlobal(pos))
def __init__(self, obj): super(WorldObject, self).__init__() objloc = obj.get('loc', {'x':0, 'y':0}) self.setPos(int(objloc['x']), int(objloc['y'])) self.setPixmap(QIcon.fromTheme('user-online').pixmap(32)) self.setToolTip(obj.get('name', 'Object'))
def __init__(self, parent=None): global client super(CharacterSelect, self).__init__(parent) self.setWindowTitle("Select A Character") # Character Portrait # Character Sprite # Name # Current zone # Money self.charbuttons = {} for char in client.characters: button = QPushButton() button.setText(char) button.setIcon(QIcon.fromTheme('applications-games')) func = functools.partial(self.select_character, char=char) button.clicked.connect(func) self.charbuttons[char] = button layout = QVBoxLayout() for w in self.charbuttons.values(): layout.addWidget(w) self.setLayout(layout) self.character_chosen.connect(qtclient.choose_char)
def __init__(self): super(LayerListWithToolBar, self).__init__() layout = QVBoxLayout() self.setLayout(layout) self.list = LayerList() self.toolbar = QToolBar() add_action = self.toolbar.addAction( QIcon.fromTheme('list-add'), 'add', ).triggered.connect(self._add) remove_action = self.toolbar.addAction( QIcon.fromTheme('list-remove'), 'remove', ).triggered.connect(self._remove) self.layout().addWidget(self.toolbar) self.layout().addWidget(self.list)
def start(self): incomplete = [] if self.google_radio.isChecked(): if not self.username.text(): incomplete.append(self.username) if not self.password.text(): incomplete.append(self.password) if not self.document_id.text(): incomplete.append(self.document_id) elif not self.csv_file.text(): incomplete.append(self.csv_file) if not self.dbf_file.text(): incomplete.append(self.dbf_file) if len(incomplete) > 0: mbox = QMessageBox(self) mbox.setWindowTitle("Warning, incomplete fields!") mbox.setIcon(QMessageBox.Warning) mbox.setWindowIcon(QIcon.fromTheme("dialog-warning")) mbox.setText("%d fields are incomplete" % len(incomplete)) mbox.exec() for field in self.changed_styles: field.setStyleSheet("") for field in incomplete: field.setStyleSheet("border: 1.5px solid red; border-radius: 5px") self.changed_styles = incomplete.copy() return for field in self.changed_styles: field.setStyleSheet("") self.setStatusTip("Working...") self.working_thread = WorkThread(self) self.working_thread.finished.connect(self.finished_start) self.working_thread.start()
def init_notebooks(self): frame = QFrame() layout = QVBoxLayout() frame.setLayout(layout) self.ui.scrollArea.setWidget(frame) for notebook_struct in self.app.provider.list_notebooks(): notebook = Notebook.from_tuple(notebook_struct) count = self.app.provider.get_notebook_notes_count(notebook.id) widget = QWidget() menu = QMenu(self) menu.addAction(self.tr('Change Name'), Slot()(partial( self.change_notebook, notebook=notebook, ))) action = menu.addAction(self.tr('Remove Notebook'), Slot()(partial( self.remove_notebook, notebook=notebook, ))) action.setEnabled(False) widget.ui = Ui_Notebook() widget.ui.setupUi(widget) widget.ui.name.setText(notebook.name) widget.ui.content.setText(self.tr('Containts %d notes') % count) widget.ui.actionBtn.setIcon(QIcon.fromTheme('gtk-properties')) widget.setFixedHeight(50) layout.addWidget(widget) widget.ui.actionBtn.clicked.connect(Slot()(partial( self.show_notebook_menu, menu=menu, widget=widget, )))
def __init__(self, files_not_processed, parent=None): super(ErrorDialog, self).__init__(parent) self.files_not_processed = files_not_processed self.setMinimumWidth(600) self.setWindowTitle(u'Kaikkia tiedostoja ei pystytty mittaamaan') icon = QIcon() icon.addPixmap( QPixmap(":/Images/aktools_48x48.png"), QIcon.Normal, QIcon.Off) self.setWindowIcon(icon) self.text_browser = QTextBrowser() self.label = QLabel(u'Seuraavissa tiedostoissa havaittiin virheitä:') self.layout = QVBoxLayout() self.layout.addWidget(self.label) self.layout.addWidget(self.text_browser) self.setLayout(self.layout) self.list_files_not_processed()