def __init__(self, parent=None): QWidget.__init__(self, parent) self.parent = parent #This variables are used to save the splitter sizes before hide self._splitterMainSizes = None self._splitterAreaSizes = None self.lateralPanel = None hbox = QHBoxLayout(self) hbox.setContentsMargins(0, 0, 0, 0) hbox.setSpacing(0) #Create Splitters to divide the UI in: MainPanel, Explorer, Misc self._splitterArea = QSplitter(Qt.Horizontal) self._splitterMain = QSplitter(Qt.Vertical) #Create scrollbar for follow mode self.scrollBar = QScrollBar(Qt.Vertical, self) self.scrollBar.setFixedWidth(20) self.scrollBar.setToolTip('Follow Mode: Scroll the Editors together') self.scrollBar.hide() self.connect(self.scrollBar, SIGNAL("valueChanged(int)"), self.move_follow_scrolls) #Add to Main Layout hbox.addWidget(self.scrollBar) hbox.addWidget(self._splitterArea)
def _initTopWidget(self): topWidget = QWidget(self) refreshButton = QPushButton("Refresh", topWidget) refreshButton.clicked.connect(self._updatePeers) self._clearButton = QPushButton("Clear Selected", topWidget) self._clearButton.setEnabled(False) self._clearButton.clicked.connect(self._clearSelected) self._openChatButton = QToolButton(topWidget) self._openChatButton.setText(u"Open chat with ") self._openChatButton.setToolButtonStyle(Qt.ToolButtonTextOnly) self._openChatButton.setPopupMode(QToolButton.InstantPopup) menu = QMenu(self._openChatButton) menu.aboutToShow.connect(partial(self._fillPeersPopup, menu)) self._openChatButton.setMenu(menu) self._searchField = QLineEdit(topWidget) if hasattr(self._searchField, "setPlaceholderText"): self._searchField.setPlaceholderText("Filter Messages") self._searchField.textChanged.connect(self._sortFilterModel.setFilterRegExp) layout = QHBoxLayout(topWidget) layout.setContentsMargins(0, 10, 10, 0) layout.addWidget(refreshButton, 0, Qt.AlignLeft) layout.addWidget(self._clearButton, 0, Qt.AlignLeft) layout.addWidget(self._openChatButton, 1, Qt.AlignLeft) layout.addWidget(self._searchField, 0, Qt.AlignRight) return topWidget
def __init__(self, main_combo=False): super(ActionBar, self).__init__() self.setObjectName("actionbar") hbox = QHBoxLayout(self) hbox.setContentsMargins(1, 1, 1, 1) hbox.setSpacing(1) self.lbl_checks = QLabel('') self.lbl_checks.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.lbl_checks.setFixedWidth(48) self.lbl_checks.setVisible(False) hbox.addWidget(self.lbl_checks) self.combo = ComboFiles() self.combo.setIconSize(QSize(16, 16)) #model = QStandardItemModel() #self.combo.setModel(model) #self.combo.view().setDragDropMode(QAbstractItemView.InternalMove) self.combo.setMaximumWidth(300) self.combo.setObjectName("combotab") self.connect(self.combo, SIGNAL("currentIndexChanged(int)"), self.current_changed) self.combo.setToolTip(translations.TR_COMBO_FILE_TOOLTIP) self.combo.setContextMenuPolicy(Qt.CustomContextMenu) self.connect(self.combo, SIGNAL( "customContextMenuRequested(const QPoint &)"), self._context_menu_requested) hbox.addWidget(self.combo) self.symbols_combo = QComboBox() self.symbols_combo.setIconSize(QSize(16, 16)) self.symbols_combo.setObjectName("combo_symbols") self.connect(self.symbols_combo, SIGNAL("activated(int)"), self.current_symbol_changed) hbox.addWidget(self.symbols_combo) self.code_navigator = CodeNavigator() hbox.addWidget(self.code_navigator) self._pos_text = "Line: %d, Col: %d" self.lbl_position = QLabel(self._pos_text % (0, 0)) self.lbl_position.setObjectName("position") self.lbl_position.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) hbox.addWidget(self.lbl_position) self.btn_close = QPushButton( self.style().standardIcon(QStyle.SP_DialogCloseButton), '') self.btn_close.setIconSize(QSize(16, 16)) if main_combo: self.btn_close.setObjectName('navigation_button') self.btn_close.setToolTip(translations.TR_CLOSE_FILE) self.connect(self.btn_close, SIGNAL("clicked()"), self.about_to_close_file) else: self.btn_close.setObjectName('close_split') self.btn_close.setToolTip(translations.TR_CLOSE_SPLIT) self.connect(self.btn_close, SIGNAL("clicked()"), self.close_split) self.btn_close.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) hbox.addWidget(self.btn_close)
def _initInputUI(self, layout): self.setWindowTitle(self._title) messageLabel = QLabel(self._message, self) messageLabel.setWordWrap(True) layout.addWidget(messageLabel) inputWidget = QWidget(self) inputLayout = QHBoxLayout(inputWidget) inputLayout.setContentsMargins(0, 0, 0, 0) if type(self._initialBegin) != QTime: initialBegin = QTime.fromString(self._initialBegin, lunch_settings.LUNCH_TIME_FORMAT_QT) if type(self._initialEnd) != QTime: initialEnd = QTime.fromString(self._initialEnd, lunch_settings.LUNCH_TIME_FORMAT_QT) inputLayout.addWidget(QLabel("From", self)) self.beginEdit = QTimeEdit(self) self.beginEdit.setDisplayFormat("HH:mm") self.beginEdit.setTime(initialBegin) inputLayout.addWidget(self.beginEdit) inputLayout.addWidget(QLabel("to", self)) self.endEdit = QTimeEdit(self) self.endEdit.setDisplayFormat("HH:mm") self.endEdit.setTime(initialEnd) inputLayout.addWidget(self.endEdit) layout.addWidget(inputWidget, 0, Qt.AlignLeft)
def __init__(self, icon_path, enabled=True, size_multiplier=0.7, tooltip=None, parent=None, icon_sz=(32, 32)): super(VmIconWidget, self).__init__(parent) self.label_icon = QLabel() if icon_path[0] in ':/': icon = QIcon(icon_path) else: icon = QIcon.fromTheme(icon_path) icon_sz = QSize(row_height * size_multiplier, row_height * size_multiplier) icon_pixmap = icon.pixmap( icon_sz, QIcon.Disabled if not enabled else QIcon.Normal) self.label_icon.setPixmap(icon_pixmap) self.label_icon.setFixedSize(icon_sz) if tooltip != None: self.label_icon.setToolTip(tooltip) layout = QHBoxLayout() layout.addWidget(self.label_icon) layout.setContentsMargins(0, 0, 0, 0) self.setLayout(layout)
def __init__(self, possible_items): QWidget.__init__(self) self._editing = True self._possible_items = possible_items self._list_edit_line = AutoCompleteLineEdit(possible_items, self) self._list_edit_line.setMinimumWidth(350) layout = QHBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self._list_edit_line) dialog_button = QToolButton(self) dialog_button.setIcon(resourceIcon("ide/small/add")) dialog_button.setIconSize(QSize(16, 16)) dialog_button.clicked.connect(self.addChoice) layout.addWidget(dialog_button) self.setLayout(layout) self._validation_support = ValidationSupport(self) self._valid_color = self._list_edit_line.palette().color(self._list_edit_line.backgroundRole()) self._list_edit_line.setText("") self._editing = False self._list_edit_line.editingFinished.connect(self.validateList) self._list_edit_line.textChanged.connect(self.validateList) self.validateList()
def create_scedit(self, text, option, default=NoDefault, tip=None, without_layout=False): label = QLabel(text) clayout = ColorLayout(QColor(Qt.black), self) clayout.lineedit.setMaximumWidth(80) if tip is not None: clayout.setToolTip(tip) cb_bold = QCheckBox() cb_bold.setIcon(get_icon("bold.png")) cb_bold.setToolTip(_("Bold")) cb_italic = QCheckBox() cb_italic.setIcon(get_icon("italic.png")) cb_italic.setToolTip(_("Italic")) self.scedits[(clayout, cb_bold, cb_italic)] = (option, default) if without_layout: return label, clayout, cb_bold, cb_italic layout = QHBoxLayout() layout.addWidget(label) layout.addLayout(clayout) layout.addSpacing(10) layout.addWidget(cb_bold) layout.addWidget(cb_italic) layout.addStretch(1) layout.setContentsMargins(0, 0, 0, 0) widget = QWidget(self) widget.setLayout(layout) return widget
def __init__(self, parent=None, icon=QIcon(), text="", wordWrap=False, textFormat=Qt.AutoText, standardButtons=NoButton, **kwargs): super().__init__(parent, **kwargs) self.__text = text self.__icon = QIcon() self.__wordWrap = wordWrap self.__standardButtons = MessageWidget.NoButton self.__buttons = [] layout = QHBoxLayout() layout.setContentsMargins(8, 0, 8, 0) self.__iconlabel = QLabel(objectName="icon-label") self.__iconlabel.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.__textlabel = QLabel(objectName="text-label", text=text, wordWrap=wordWrap, textFormat=textFormat) if sys.platform == "darwin": self.__textlabel.setAttribute(Qt.WA_MacSmallSize) layout.addWidget(self.__iconlabel) layout.addWidget(self.__textlabel) self.setLayout(layout) self.setIcon(icon) self.setStandardButtons(standardButtons)
def set_corner_widgets(self, corner_widgets): """ Set tabs corner widgets corner_widgets: dictionary of (corner, widgets) corner: Qt.TopLeftCorner or Qt.TopRightCorner widgets: list of widgets (may contains integers to add spacings) """ assert isinstance(corner_widgets, dict) assert all(key in (Qt.TopLeftCorner, Qt.TopRightCorner) for key in corner_widgets) self.corner_widgets.update(corner_widgets) for corner, widgets in self.corner_widgets.iteritems(): cwidget = QWidget() cwidget.hide() prev_widget = self.cornerWidget(corner) if prev_widget: prev_widget.close() self.setCornerWidget(cwidget, corner) clayout = QHBoxLayout() clayout.setContentsMargins(0, 0, 0, 0) for widget in widgets: if isinstance(widget, int): clayout.addSpacing(widget) else: clayout.addWidget(widget) cwidget.setLayout(clayout) cwidget.show()
def create_spinbox(self, prefix, suffix, option, default=NoDefault, min_=None, max_=None, step=None, tip=None): if prefix: plabel = QLabel(prefix) else: plabel = None if suffix: slabel = QLabel(suffix) else: slabel = None spinbox = QSpinBox() if min_ is not None: spinbox.setMinimum(min_) if max_ is not None: spinbox.setMaximum(max_) if step is not None: spinbox.setSingleStep(step) if tip is not None: spinbox.setToolTip(tip) self.spinboxes[spinbox] = (option, default) layout = QHBoxLayout() for subwidget in (plabel, spinbox, slabel): if subwidget is not None: layout.addWidget(subwidget) layout.addStretch(1) layout.setContentsMargins(0, 0, 0, 0) widget = QWidget(self) widget.setLayout(layout) return widget
def __init__(self, iterable=False, help_link=""): QWidget.__init__(self) self._iterable = iterable addHelpToWidget(self, help_link) layout = QHBoxLayout() analysis_module_combo = QComboBox() module_names = getAnalysisModuleNames(self._iterable) for module_name in module_names: analysis_module_combo.addItem(module_name) self._current_module_name = self._getCurrentAnalysisModuleName() if self._current_module_name is not None: analysis_module_combo.setCurrentIndex( module_names.index(self._current_module_name)) analysis_module_combo.currentIndexChanged[int].connect( self.analysisModuleChanged) variables_popup_button = QToolButton() variables_popup_button.setIcon(resourceIcon("ide/small/cog_edit.png")) variables_popup_button.clicked.connect(self.showVariablesPopup) variables_popup_button.setMaximumSize(20, 20) layout.addWidget(analysis_module_combo, 0, Qt.AlignLeft) layout.addWidget(variables_popup_button, 0, Qt.AlignLeft) layout.setContentsMargins(QMargins(0, 0, 0, 0)) layout.addStretch() self.setLayout(layout)
def setModel(self, model): """ Set model used to store the data. This method adds an extra row at the end, which is used to keep the "Add..." button. """ super(DatasetDetailedInfoTableView, self).setModel(model) widget = QWidget() layout = QHBoxLayout(widget) self._addButton = button = AddFileButton(widget, new=True) button.addFilesRequested.connect( partial(self.addFilesRequested.emit, -1)) button.addStackRequested.connect( partial(self.addStackRequested.emit, -1)) button.addRemoteVolumeRequested.connect( partial(self.addRemoteVolumeRequested.emit, -1)) layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(button) layout.addStretch() widget.setLayout(layout) lastRow = self.model().rowCount() - 1 modelIndex = self.model().index(lastRow, 0) self.setIndexWidget(modelIndex, widget) # the "Add..." button spans last row self.setSpan(lastRow, 0, 1, model.columnCount())
def __init__(self, symbol, color, parent=None): QFrame.__init__(self, parent) self._symbol = symbol self.backColor = color # define and set stylesheets self.setup_stylesheets() self.setStyleSheet(self._theStyleSheet) # layout layout = QHBoxLayout() layout.setContentsMargins(0, 0, 0, 0) self.setToolTip(symbol["description"]) # add the symbol's svg svgWidget = QSvgWidget(symbol["svgPath"]) svgWidth = int(symbol["width"]) self.setMinimumWidth(svgWidth * 25) self.setMaximumWidth(svgWidth * 25) self.setMinimumHeight(25) self.setMaximumHeight(25) layout.addWidget(svgWidget) self.setLayout(layout)
def __createLayout( self ): " Creates the widget layout " verticalLayout = QVBoxLayout( self ) verticalLayout.setContentsMargins( 0, 0, 0, 0 ) verticalLayout.setSpacing( 0 ) self.headerFrame = QFrame() self.headerFrame.setFrameStyle( QFrame.StyledPanel ) self.headerFrame.setAutoFillBackground( True ) headerPalette = self.headerFrame.palette() headerBackground = headerPalette.color( QPalette.Background ) headerBackground.setRgb( min( headerBackground.red() + 30, 255 ), min( headerBackground.green() + 30, 255 ), min( headerBackground.blue() + 30, 255 ) ) headerPalette.setColor( QPalette.Background, headerBackground ) self.headerFrame.setPalette( headerPalette ) self.headerFrame.setFixedHeight( 24 ) self.__threadsLabel = QLabel( "Threads" ) expandingSpacer = QSpacerItem( 10, 10, QSizePolicy.Expanding ) fixedSpacer = QSpacerItem( 3, 3 ) self.__showHideButton = QToolButton() self.__showHideButton.setAutoRaise( True ) self.__showHideButton.setIcon( PixmapCache().getIcon( 'less.png' ) ) self.__showHideButton.setFixedSize( 20, 20 ) self.__showHideButton.setToolTip( "Hide threads list" ) self.__showHideButton.setFocusPolicy( Qt.NoFocus ) self.__showHideButton.clicked.connect( self.__onShowHide ) headerLayout = QHBoxLayout() headerLayout.setContentsMargins( 0, 0, 0, 0 ) headerLayout.addSpacerItem( fixedSpacer ) headerLayout.addWidget( self.__threadsLabel ) headerLayout.addSpacerItem( expandingSpacer ) headerLayout.addWidget( self.__showHideButton ) self.headerFrame.setLayout( headerLayout ) self.__threadsList = QTreeWidget() self.__threadsList.setSortingEnabled( False ) # I might not need that because of two reasons: # - the window has no focus # - the window has custom current indicator # self.__threadsList.setAlternatingRowColors( True ) self.__threadsList.setRootIsDecorated( False ) self.__threadsList.setItemsExpandable( False ) self.__threadsList.setUniformRowHeights( True ) self.__threadsList.setSelectionMode( QAbstractItemView.NoSelection ) self.__threadsList.setSelectionBehavior( QAbstractItemView.SelectRows ) self.__threadsList.setItemDelegate( NoOutlineHeightDelegate( 4 ) ) self.__threadsList.setFocusPolicy( Qt.NoFocus ) self.__threadsList.itemClicked.connect( self.__onThreadClicked ) self.__threadsList.setHeaderLabels( [ "", "Name", "State", "TID" ] ) verticalLayout.addWidget( self.headerFrame ) verticalLayout.addWidget( self.__threadsList ) return
def _getCalendar(self, display_format, value = None): ''' Get a combobox filled with the given values :param values: The values as key = value, value = description or text :type values: Dict :returns: A combobox :rtype: QWidget ''' widget = QWidget() calendar = QDateTimeEdit() calendar.setCalendarPopup(True) calendar.setDisplayFormat(display_format) if value is not None: calendar.setDate(QDate.fromString(value, display_format)) else: calendar.setDate(QDate.currentDate()) layout = QHBoxLayout(widget) layout.addWidget(calendar, 1); layout.setAlignment(Qt.AlignCenter); layout.setContentsMargins(5,0,5,0); widget.setLayout(layout); return widget
def setupUI(self): lay = QVBoxLayout() lay.setContentsMargins(0, 0, 0, 0) self.removeButton = QPushButton(QIcon(QPixmap("img/moduleRemove.png")), "") self.addButton = QPushButton(QIcon(QPixmap("img/moduleAdd.png")),"") self.reloadButton = QPushButton(QIcon(QPixmap("img/moduleReload.png")), "") self.model = Model(self) self.list = QListView() self.list.setModel(self.model) self.list.setIconSize(QSize(32, 32)) lay.addWidget(self.list) hlay = QHBoxLayout() hlay.setContentsMargins(0, 0, 0, 0) hlay.addWidget(self.reloadButton) hlay.addStretch() hlay.addWidget(self.removeButton) hlay.addWidget(self.addButton) lay.addLayout(hlay) self.setLayout(lay) self.addButton.clicked.connect(self.addButtonClick) self.removeButton.clicked.connect(self.removeButtonClick) self.reloadButton.clicked.connect(self.reloadButtonClick) self.list.doubleClicked.connect(self.selectStrategy) self.modules = {}
def __init__(self, base, url): QDialog.__init__(self) self.base = base self.setWindowTitle(i18n.get('authorize_turpial')) self.resize(800, 550) self.setModal(True) self.webview = QWebView() qurl = QUrl(url) self.webview.setUrl(qurl) message = QLabel(i18n.get('copy_the_pin')) #message.setAlignment(Qt.AlignRight) self.pin = QLineEdit() self.pin.setPlaceholderText(i18n.get('type_the_pin')) authorize_btn = QPushButton(i18n.get('save')) authorize_btn.clicked.connect(self.accept) widgets_box = QHBoxLayout() widgets_box.setSpacing(3) widgets_box.setContentsMargins(3, 3, 3, 3) widgets_box.addWidget(message, 1) widgets_box.addWidget(self.pin) widgets_box.addWidget(authorize_btn) layout = QVBoxLayout() layout.addWidget(self.webview) layout.addLayout(widgets_box) layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) self.setLayout(layout) self.exec_()
def __init__(self): super(ActionBar, self).__init__() self.setObjectName("actionbar") hbox = QHBoxLayout(self) hbox.setContentsMargins(1, 1, 1, 1) combo = QComboBox() combo.setObjectName("combotab") hbox.addWidget(combo) combo.addItem("main_container.py") combo.addItem("ide.py") combo.addItem("editor.py") self.lbl_checks = QLabel('') self.lbl_checks.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) hbox.addWidget(self.lbl_checks) self._pos_text = "Ln: %d, Col: %d" self.lbl_position = QLabel(self._pos_text % (0, 0)) self.lbl_position.setObjectName("position") self.lbl_position.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) hbox.addWidget(self.lbl_position) self.btn_close = QPushButton( self.style().standardIcon(QStyle.SP_DialogCloseButton), '') self.btn_close.setObjectName('navigation_button') self.btn_close.setToolTip(translations.TR_CLOSE_SPLIT) self.btn_close.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) hbox.addWidget(self.btn_close)
def __init__(self, editor): QDialog.__init__(self, editor) self.editor = editor self.total = 0 # Popup! self.setWindowFlags(Qt.Popup) box = QHBoxLayout(self) box.setContentsMargins(5, 5, 5, 5) self.line = Line(self) self.line.setMinimumWidth(200) box.addWidget(self.line) # Botones btn_anterior = QToolButton() btn_anterior.setIcon(QIcon(paths.ICONOS['arrow-down'])) btn_siguiente = QToolButton() btn_siguiente.setIcon(QIcon(paths.ICONOS['arrow-up'])) box.addWidget(btn_anterior) box.addWidget(btn_siguiente) # Posición qpoint = self.editor.rect().topRight() global_point = self.editor.mapToGlobal(qpoint) self.move(global_point - QPoint(self.width() + 180, 0)) # Conexiones btn_anterior.clicked.connect(self.buscar_anterior) btn_siguiente.clicked.connect(self.buscar_siguiente)
def __init__(self, parent=None, editable=True, field_name='months', **kw): CustomEditor.__init__(self, parent) self.setObjectName( field_name ) self.years_spinbox = CustomDoubleSpinBox() self.months_spinbox = CustomDoubleSpinBox() self.years_spinbox.setMinimum(0) self.years_spinbox.setMaximum(10000) self.months_spinbox.setMinimum(0) self.months_spinbox.setMaximum(12) self.years_spinbox.setSuffix(_(' years')) self.months_spinbox.setSuffix(_(' months')) self.years_spinbox.setDecimals(0) self.years_spinbox.setAlignment(Qt.AlignRight|Qt.AlignVCenter) self.years_spinbox.setSingleStep(1) self.months_spinbox.setDecimals(0) self.months_spinbox.setAlignment(Qt.AlignRight|Qt.AlignVCenter) self.months_spinbox.setSingleStep(1) self.years_spinbox.editingFinished.connect( self._spinbox_editing_finished ) self.months_spinbox.editingFinished.connect( self._spinbox_editing_finished ) layout = QHBoxLayout() layout.addWidget(self.years_spinbox) layout.addWidget(self.months_spinbox) layout.setContentsMargins(0, 0, 0, 0) self.setLayout(layout)
def __init__(self, parent): super(XUrlWidget, self).__init__(parent) # define the interface self._urlEdit = XLineEdit(self) self._urlButton = QToolButton(self) self._urlButton.setAutoRaise(True) self._urlButton.setIcon(QIcon(resources.find('img/web.png'))) self._urlButton.setToolTip('Browse Link') self._urlButton.setFocusPolicy(Qt.NoFocus) self._urlEdit.setHint('http://') layout = QHBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) layout.addWidget(self._urlEdit) layout.addWidget(self._urlButton) self.setLayout(layout) self.setFocusPolicy(Qt.StrongFocus) # create connections self._urlEdit.textChanged.connect(self.urlChanged) self._urlEdit.textEdited.connect(self.urlEdited) self._urlButton.clicked.connect(self.browse)
def __init__(self, parent): QWidget.__init__(self, parent) hSearch = QHBoxLayout(self) hSearch.setContentsMargins(0, 0, 0, 0) self._checkSensitive = QCheckBox(self.tr("Respect Case Sensitive")) self._checkWholeWord = QCheckBox(self.tr("Find Whole Words")) self._line = TextLine(parent, self._checkSensitive) self._line.setMinimumWidth(250) self._btnClose = QPushButton( self.style().standardIcon(QStyle.SP_DialogCloseButton), '') self._btnFind = QPushButton(QIcon(resources.IMAGES['find']), '') self.btnPrevious = QPushButton( self.style().standardIcon(QStyle.SP_ArrowLeft), '') self.btnPrevious.setToolTip(self.tr("Press (%1 + Left Arrow)").arg( settings.OS_KEY)) self.btnNext = QPushButton( self.style().standardIcon(QStyle.SP_ArrowRight), '') self.btnNext.setToolTip(self.tr("Press (%1 + Right Arrow)").arg( settings.OS_KEY)) hSearch.addWidget(self._btnClose) hSearch.addWidget(self._line) hSearch.addWidget(self._btnFind) hSearch.addWidget(self.btnPrevious) hSearch.addWidget(self.btnNext) hSearch.addWidget(self._checkSensitive) hSearch.addWidget(self._checkWholeWord)
def setupUi(self): self.setLayout(QVBoxLayout()) self.layout().setContentsMargins(0, 0, 0, 0) self.layout().setSpacing(0) self.__mainLayout = QVBoxLayout() self.__mainLayout.setContentsMargins(0, 40, 0, 40) self.__mainLayout.setSpacing(65) self.layout().addLayout(self.__mainLayout) self.setStyleSheet(WELCOME_WIDGET_BUTTON_STYLE) bottom_bar = QWidget(objectName="bottom-bar") bottom_bar_layout = QHBoxLayout() bottom_bar_layout.setContentsMargins(20, 10, 20, 10) bottom_bar.setLayout(bottom_bar_layout) bottom_bar.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Maximum) check = QCheckBox(self.tr("Show at startup"), bottom_bar) check.setChecked(False) self.__showAtStartupCheck = check bottom_bar_layout.addWidget(check, alignment=Qt.AlignVCenter | \ Qt.AlignLeft) self.layout().addWidget(bottom_bar, alignment=Qt.AlignBottom, stretch=1) self.setSizeGripEnabled(False) self.setFixedSize(620, 390)
def __init__(self, project, content, itemRelated, parent=None): QWidget.__init__(self, parent) self.__content = content.toMap() self.__project = project self.__favorite = QPushButton(self) self.__delete = QPushButton(self) self.__delete.setIcon(QIcon(resources.IMAGES['delProj'])) self.__name = QLineEdit(self) self.__itemRelated = itemRelated self.setMouseTracking(True) self.__name.setText(self.__content[QString("name")].toString()) if QString("description") in self.__content: description = self.__content[QString("description")].toString() else: description = self.tr("no description available") self.__name.setToolTip(self.tr(self.__project) + '\n\n' + description) self.__delete.setToolTip(self.tr("Click to delete from the list")) self.__favorite.setToolTip(self.tr("Click to dock on the list")) hbox = QHBoxLayout() self.setLayout(hbox) hbox.setContentsMargins(0, 0, 0, 0) hbox.addWidget(self.__favorite) hbox.addWidget(self.__name) hbox.addWidget(self.__delete) self.__name.setCursor(QCursor(Qt.ArrowCursor)) self.__name.setReadOnly(True) self.connect(self.__favorite, SIGNAL("clicked(bool)"), self.__on_click_on_favorite) self.connect(self.__delete, SIGNAL("clicked(bool)"), self.__on_click_on_delete) #TODO: Change this click listen it doesn't work with ReadOnly = True self.connect(self.__name, SIGNAL("cursorPositionChanged(int, int)"), self.__on_click_on_name) self._set_favorite(self.__content[QString("isFavorite")].toBool())
def __init__(self, parent): super(XLocationWidget, self).__init__(parent) # define the interface self._locationEdit = XLineEdit(self) self._locationButton = QToolButton(self) self._urlTemplate = 'http://maps.google.com/maps?%(params)s' self._urlQueryKey = 'q' self._locationButton.setAutoRaise(True) self._locationButton.setIcon(QIcon(resources.find('img/map.png'))) self._locationEdit.setHint('no location set') layout = QHBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) layout.addWidget(self._locationEdit) layout.addWidget(self._locationButton) self.setLayout(layout) # create connections self._locationEdit.textChanged.connect(self.locationChanged) self._locationEdit.textEdited.connect(self.locationEdited) self._locationButton.clicked.connect(self.browseMaps)
def _getCalendar(self, display_format, value=None): ''' Get a combobox filled with the given values :param values: The values as key = value, value = description or text :type values: Dict :returns: A combobox :rtype: QWidget ''' widget = QWidget() calendar = QDateTimeEdit() calendar.setCalendarPopup(True) calendar.setDisplayFormat(display_format) if value is not None: calendar.setDate(QDate.fromString(value, display_format)) else: calendar.setDate(QDate.currentDate()) layout = QHBoxLayout(widget) layout.addWidget(calendar, 1) layout.setAlignment(Qt.AlignCenter) layout.setContentsMargins(5, 0, 5, 0) widget.setLayout(layout) return widget
def __init__( self, parent = None ): super(XViewProfileManager, self).__init__(parent) # define custom properties self._profiles = [] self._optionsMenuPolicy = Qt.DefaultContextMenu self._viewWidget = None # define the interface self._profileCombo = QComboBox(self) self._optionsButton = QToolButton(self) self._optionsButton.setAutoRaise(True) self._optionsButton.setToolTip('Advanced Options') self._optionsButton.setIcon(QIcon(resources.find('img/advanced.png'))) layout = QHBoxLayout() layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self._profileCombo) layout.addWidget(self._optionsButton) self.setLayout(layout) # create connections self._profileCombo.currentIndexChanged.connect(self.handleProfileChange) self._optionsButton.clicked.connect(self.showOptionsMenu)
def __init__(self, iterable=False, load_all = False, help_link=""): QWidget.__init__(self) self._iterable = iterable addHelpToWidget(self, help_link) layout = QHBoxLayout() analysis_module_combo = QComboBox() self._module_names = getAnalysisModuleNames(self._iterable) if load_all: self._module_names += getAnalysisModuleNames(not self._iterable) for module_name in self._module_names: analysis_module_combo.addItem(module_name) self._current_module_name = self._getCurrentAnalysisModuleName() if self._current_module_name is not None: analysis_module_combo.setCurrentIndex(self._module_names.index(self._current_module_name)) analysis_module_combo.currentIndexChanged[int].connect(self.analysisModuleChanged) variables_popup_button = QToolButton() variables_popup_button.setIcon(resourceIcon("ide/small/cog_edit.png")) variables_popup_button.clicked.connect(self.showVariablesPopup) variables_popup_button.setMaximumSize(20, 20) layout.addWidget(analysis_module_combo, 0, Qt.AlignLeft) layout.addWidget(variables_popup_button, 0, Qt.AlignLeft) layout.setContentsMargins(QMargins(0, 0, 0, 0)) layout.addStretch() self.setLayout(layout)
def __init__(self, parent=None): super(CentralWidget, self).__init__(parent) self.parent = parent #This variables are used to save the splitter sizes before hide self._splitterBaseSizes = None self._splitterInsideSizes = None self.lateralPanel = LateralPanel() self._add_functions = { "central": self._insert_widget_region0, "lateral": self._insert_widget_region1, } self._items = {} hbox = QHBoxLayout(self) hbox.setContentsMargins(0, 0, 0, 0) hbox.setSpacing(0) #Create Splitters to divide the UI 3 regions self._splitterBase = dynamic_splitter.DynamicSplitter(Qt.Horizontal) self._splitterInside = dynamic_splitter.DynamicSplitter(Qt.Vertical) self._splitterBase.addWidget(self._splitterInside) #Add to Main Layout hbox.addWidget(self._splitterBase) IDE.register_service('central_container', self)
def _getSpinbox(self, minvalue, maxvalue, step, nullable = True, value = 0): ''' Get a combobox filled with the given values :param values: The values as key = value, value = description or text :type values: Dict :returns: A combobox :rtype: QWidget ''' widget = QWidget() spinbox = QDoubleSpinBox() spinbox.setMinimum(minvalue) spinbox.setMaximum(maxvalue) spinbox.setSingleStep(step) spinbox.setDecimals(len(str(step).split('.')[1]) if len(str(step).split('.'))==2 else 0) if nullable: spinbox.setMinimum(minvalue - step) spinbox.setValue(spinbox.minimum()) spinbox.setSpecialValueText(str(QSettings().value('qgis/nullValue', 'NULL' ))) if value is not None: spinbox.setValue(value) layout = QHBoxLayout(widget) layout.addWidget(spinbox, 1); layout.setAlignment(Qt.AlignCenter); layout.setContentsMargins(5,0,5,0); widget.setLayout(layout); return widget
def _initUI(self): layout = QVBoxLayout(self) layout.setContentsMargins(0, 10, 0, 0) layout.setSpacing(0) labelLayout = QHBoxLayout() labelLayout.addWidget(QLabel(u"Sorry, something went wrong:", self)) labelLayout.setContentsMargins(10, 0, 0, 0) layout.addLayout(labelLayout) layout.addSpacing(5) self._errorLog = QTextEdit(self) self._errorLog.setReadOnly(True) self._errorLog.setWordWrapMode(QTextOption.NoWrap) self._errorLog.setTextColor(QColor(180, 0, 0)) self._errorLog.setObjectName(u"__ERROR_LOG_") self._errorLog.setFrameShape(QFrame.StyledPanel) if getPlatform() == PLATFORM_MAC: self._errorLog.setStyleSheet("QFrame#__ERROR_LOG_{border-width: 1px; border-top-style: solid; border-right-style: none; border-bottom-style: solid; border-left-style: none; border-color:palette(mid)}"); layout.addWidget(self._errorLog) bottomWidget = QWidget(self) bottomLayout = QHBoxLayout(bottomWidget) self._notAgain = QCheckBox(u"Please, no more error messages!", self) bottomLayout.addWidget(self._notAgain, 1, Qt.AlignTop) buttonBox = QDialogButtonBox(QDialogButtonBox.Close, Qt.Horizontal, self) buttonBox.rejected.connect(self.reject) bottomLayout.addWidget(buttonBox) layout.addWidget(bottomWidget)
def __createLayout(self): " Creates the widget layout " verticalLayout = QVBoxLayout(self) verticalLayout.setContentsMargins(0, 0, 0, 0) verticalLayout.setSpacing(0) self.headerFrame = QFrame() self.headerFrame.setFrameStyle(QFrame.StyledPanel) self.headerFrame.setAutoFillBackground(True) headerPalette = self.headerFrame.palette() headerBackground = headerPalette.color(QPalette.Background) headerBackground.setRgb(min(headerBackground.red() + 30, 255), min(headerBackground.green() + 30, 255), min(headerBackground.blue() + 30, 255)) headerPalette.setColor(QPalette.Background, headerBackground) self.headerFrame.setPalette(headerPalette) self.headerFrame.setFixedHeight(24) self.__threadsLabel = QLabel("Threads") expandingSpacer = QSpacerItem(10, 10, QSizePolicy.Expanding) fixedSpacer = QSpacerItem(3, 3) self.__showHideButton = QToolButton() self.__showHideButton.setAutoRaise(True) self.__showHideButton.setIcon(PixmapCache().getIcon('less.png')) self.__showHideButton.setFixedSize(20, 20) self.__showHideButton.setToolTip("Hide threads list") self.__showHideButton.setFocusPolicy(Qt.NoFocus) self.__showHideButton.clicked.connect(self.__onShowHide) headerLayout = QHBoxLayout() headerLayout.setContentsMargins(0, 0, 0, 0) headerLayout.addSpacerItem(fixedSpacer) headerLayout.addWidget(self.__threadsLabel) headerLayout.addSpacerItem(expandingSpacer) headerLayout.addWidget(self.__showHideButton) self.headerFrame.setLayout(headerLayout) self.__threadsList = QTreeWidget() self.__threadsList.setSortingEnabled(False) # I might not need that because of two reasons: # - the window has no focus # - the window has custom current indicator # self.__threadsList.setAlternatingRowColors( True ) self.__threadsList.setRootIsDecorated(False) self.__threadsList.setItemsExpandable(False) self.__threadsList.setUniformRowHeights(True) self.__threadsList.setSelectionMode(QAbstractItemView.NoSelection) self.__threadsList.setSelectionBehavior(QAbstractItemView.SelectRows) self.__threadsList.setItemDelegate(NoOutlineHeightDelegate(4)) self.__threadsList.setFocusPolicy(Qt.NoFocus) self.__threadsList.itemClicked.connect(self.__onThreadClicked) self.__threadsList.setHeaderLabels(["", "Name", "State", "TID"]) verticalLayout.addWidget(self.headerFrame) verticalLayout.addWidget(self.__threadsList) return
def __init__(self, symbol, color, parent = None): QFrame.__init__(self, parent) self._symbol = symbol self.backColor = color # define and set stylesheets self.setup_stylesheets() self.setStyleSheet(self._theStyleSheet) # layout layout = QHBoxLayout() layout.setContentsMargins( 0, 0, 0, 0 ) self.setToolTip(symbol["description"]) # add the symbol's svg svgWidget = QSvgWidget(symbol["svgPath"]) svgWidth = int(symbol["width"]) self.setMinimumWidth(svgWidth * 25) self.setMaximumWidth(svgWidth * 25) self.setMinimumHeight(25) self.setMaximumHeight(25) layout.addWidget(svgWidget) self.setLayout(layout)
def create_main_frame(self): # p = self.palette() # p.setColor(self.backgroundRole(), Qt.white) # self.setPalette(p) figColor = self.palette().color(QPalette.Background) self.fig = Figure(facecolor=[ figColor.red() / 255., figColor.blue() / 255., figColor.green() / 255. ]) self.canvas = FigureCanvas(self.fig) self.canvas.setParent(self) self.axes = self.fig.add_subplot(111) # Create the navigation toolbar, tied to the canvas self.mpl_toolbar = NavigationToolbar_mod(self.canvas, self) vbox = QGridLayout() vbox.addWidget(self.canvas, 0, 0) menu = QWidget(self) hbox = QHBoxLayout() menu.setLayout(hbox) hbox.addWidget(self.mpl_toolbar) vbox.addWidget(menu, 1, 0) hbox.setContentsMargins(0, 0, 0, 0) vbox.setContentsMargins(0, 0, 0, 0) vbox.setSpacing(0) self.setLayout(vbox) vbox.setRowStretch(0, 10) self.tipBut = QPushButton("?") self.tipBut.clicked.connect(self.show_tip) hbox.addWidget(self.tipBut)
def __init__(self, vm, parent=None): super(VmInfoWidget, self).__init__(parent) self.vm = vm layout = QHBoxLayout() self.on_icon = VmStatusIcon(vm) self.upd_info = VmUpdateInfoWidget(vm, show_text=False) self.error_icon = VmIconWidget(":/warning.png") self.blk_icon = VmIconWidget(":/mount.png") self.rec_icon = VmIconWidget(":/mic.png") layout.addWidget(self.on_icon) layout.addWidget(self.upd_info) layout.addWidget(self.error_icon) layout.addItem( QSpacerItem(0, 10, QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)) layout.addWidget(self.blk_icon) layout.addWidget(self.rec_icon) layout.setContentsMargins(5, 0, 5, 0) self.setLayout(layout) self.rec_icon.setVisible(False) self.blk_icon.setVisible(False) self.error_icon.setVisible(False) self.tableItem = self.VmInfoItem(self.upd_info.tableItem, vm)
class QImageWidget(QWidget): def __init__(self, parent=None): super(QImageWidget, self).__init__(parent) self.layout = QHBoxLayout(self) self.label = QLabel() self.layout.addWidget(self.label) self.pixmap = QPixmap() self.label.setPixmap(self.pixmap) self.image = QImage() self.setContentsMargins(0, 0, 0, 0) self.layout.setContentsMargins(0, 0, 0, 0) self.layout.setAlignment(Qt.AlignCenter) def set_opencv_image(self, raw_image): if raw_image is not None: self.image = QImage(raw_image, raw_image.shape[1], \ raw_image.shape[0], raw_image.shape[1] * 3, QImage.Format_RGB888) self.pixmap = QPixmap(self.image) self.label.setPixmap(self.pixmap) def show_on_second_screen(self): desktop_widget = QApplication.desktop() if desktop_widget.screenCount() > 1: second_screen_size = desktop_widget.screenGeometry(1) self.move(second_screen_size.left(), second_screen_size.top()) self.resize(second_screen_size.width(), second_screen_size.height()) self.showMaximized()
def create_doublespinbox(self, prefix, suffix, option, min_=None, max_=None, step=None, tip=None): if prefix: plabel = QLabel(prefix) else: plabel = None if suffix: slabel = QLabel(suffix) else: slabel = None spinbox = QDoubleSpinBox() if min_ is not None: spinbox.setMinimum(min_) if max_ is not None: spinbox.setMaximum(max_) if step is not None: spinbox.setSingleStep(step) if tip is not None: spinbox.setToolTip(tip) self.spinboxes[spinbox] = option layout = QHBoxLayout() for subwidget in (plabel, spinbox, slabel): if subwidget is not None: layout.addWidget(subwidget) layout.addStretch(1) layout.setContentsMargins(0, 0, 0, 0) widget = QWidget(self) widget.setLayout(layout) widget.spin = spinbox return widget
def __init__(self, parent=None, text="", icon=QIcon(), alignment=Qt.AlignTop, wordWrap=False, standardButtons=NoButton, **kwargs): super().__init__(parent, alignment=alignment, **kwargs) layout = QHBoxLayout() layout.setContentsMargins(0, 0, 0, 0) self.__msgwidget = MessageWidget(parent=self, text=text, icon=icon, wordWrap=wordWrap, standardButtons=standardButtons) self.__msgwidget.accepted.connect(self.accepted) self.__msgwidget.rejected.connect(self.rejected) self.__msgwidget.clicked.connect(self.clicked) self.__msgwidget.helpRequested.connect(self.helpRequested) self.__msgwidget.accepted.connect(self.hide) self.__msgwidget.rejected.connect(self.hide) layout.addWidget(self.__msgwidget) self.setLayout(layout)
class ArgumentWidget(QWidget): def __init__(self, argument, parent=None): super(ArgumentWidget, self).__init__(parent) self.layout = QHBoxLayout() self.layout.setContentsMargins(1, 0, 1, 1) self.setLayout(self.layout) label = QLabel(argument) self.component_id = None self.layout.addWidget(label) self.editor = QLineEdit() self.editor.setReadOnly(True) self.layout.addWidget(self.editor) self.setAcceptDrops(True) def dragEnterEvent(self, event): if event.mimeData().hasFormat('application/py_instance'): event.accept() else: event.ignore() def dropEvent(self, event): obj = event.mimeData().data('application/py_instance') if not isinstance(obj, core.data.ComponentID): return self.component_id = obj self.editor.setText(str(obj))
def initMainUi(self): role_names = self.parentApplet.dataSelectionApplet.topLevelOperator.DatasetRoles.value self.list_widgets = [] # Create a tab for each role for role_index, role_name in enumerate(role_names): select_button = QPushButton("Select " + role_name + " Files...", clicked=partial(self.select_files, role_index) ) clear_button = QPushButton("Clear " + role_name + " Files", clicked=partial(self.clear_files, role_index) ) button_layout = QHBoxLayout() button_layout.addWidget(select_button) button_layout.addSpacerItem( QSpacerItem(0,0,hPolicy=QSizePolicy.Expanding) ) button_layout.addWidget(clear_button) button_layout.setContentsMargins(0, 0, 0, 0) button_layout_widget = QWidget() button_layout_widget.setLayout(button_layout) button_layout_widget.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum) ) list_widget = QListWidget(parent=self) list_widget.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) ) self.list_widgets.append( list_widget ) tab_layout = QVBoxLayout() tab_layout.setContentsMargins(0, 0, 0, 0) tab_layout.addWidget( button_layout_widget ) tab_layout.addWidget( list_widget ) layout_widget = QWidget(parent=self) layout_widget.setLayout(tab_layout) self.addTab(layout_widget, role_name)
def __init__(self, parent=None, editable=True, **kw): CustomEditor.__init__(self, parent) self.years_spinbox = CustomDoubleSpinBox() self.months_spinbox = CustomDoubleSpinBox() self.years_spinbox.setMinimum(0) self.years_spinbox.setMaximum(10000) self.months_spinbox.setMinimum(0) self.months_spinbox.setMaximum(12) self.years_spinbox.setSuffix(_(' years')) self.months_spinbox.setSuffix(_(' months')) self.years_spinbox.setDecimals(0) self.years_spinbox.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.years_spinbox.setSingleStep(1) self.months_spinbox.setDecimals(0) self.months_spinbox.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.months_spinbox.setSingleStep(1) self.years_spinbox.editingFinished.connect( self._spinbox_editing_finished) self.months_spinbox.editingFinished.connect( self._spinbox_editing_finished) layout = QHBoxLayout() layout.addWidget(self.years_spinbox) layout.addWidget(self.months_spinbox) layout.setContentsMargins(0, 0, 0, 0) self.setLayout(layout)
def __init__(self): QWidget.__init__(self) self._line_edit = ClearableLineEdit() self._calendar_button = QToolButton() self._calendar_button.setPopupMode(QToolButton.InstantPopup) self._calendar_button.setFixedSize(26, 26) self._calendar_button.setAutoRaise(True) self._calendar_button.setIcon(resourceIcon("calendar.png")) self._calendar_button.setStyleSheet( "QToolButton::menu-indicator { image: none; }") tool_menu = QMenu(self._calendar_button) self._calendar_widget = QCalendarWidget(tool_menu) action = QWidgetAction(tool_menu) action.setDefaultWidget(self._calendar_widget) tool_menu.addAction(action) self._calendar_button.setMenu(tool_menu) layout = QHBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self._line_edit) layout.addWidget(self._calendar_button) self.setLayout(layout) self._calendar_widget.activated.connect(self.setDate)
def _align(widget, checkbox=None): l = QHBoxLayout() if checkbox is not None: checkbox.setMaximumWidth(23) l.addWidget(checkbox, 0) else: l.addSpacing(25) l.addStretch(0.5) if widget is not None: widget.setMinimumWidth(180) widget.setMaximumWidth(180) l.addWidget(widget) else: l.addSpacing(180) l.setContentsMargins(0, 0, 0, 0) l.addStretch(1) w = QWidget() w.setContentsMargins(0, 2, 0, 2) w.setLayout(l) return w
def __init__(self, parent, prefix = None, suffix = None, option = None, min_ = None, max_ = None, step = None, tip = None, value = None, changed =None): super(MyDoubleSpinBox, self).__init__(parent) if prefix: plabel = QLabel(prefix) else: plabel = None if suffix: slabel = QLabel(suffix) else: slabel = None spinbox = QDoubleSpinBox(parent) if min_ is not None: spinbox.setMinimum(min_) if max_ is not None: spinbox.setMaximum(max_) if step is not None: spinbox.setSingleStep(step) if tip is not None: spinbox.setToolTip(tip) layout = QHBoxLayout() for subwidget in (plabel, spinbox, slabel): if subwidget is not None: layout.addWidget(subwidget) if value is not None: spinbox.setValue(value) if changed is not None: self.connect(spinbox, SIGNAL('valueChanged(double)'), changed) layout.addStretch(1) layout.setContentsMargins(0, 0, 0, 0) self.setLayout(layout) self.spin = spinbox
def __init__(self, parent=None): super(ReplaceWidget, self).__init__(parent) hReplace = QHBoxLayout(self) hReplace.setContentsMargins(0, 0, 0, 0) self._lineReplace = QLineEdit() self._lineReplace.setMinimumWidth(250) self._btnCloseReplace = QPushButton( self.style().standardIcon(QStyle.SP_DialogCloseButton), '') self._btnCloseReplace.setIconSize(QSize(16, 16)) self._btnReplace = QPushButton(self.trUtf8("Replace")) self._btnReplaceAll = QPushButton(self.trUtf8("Replace All")) self._btnReplaceSelection = QPushButton( self.trUtf8("Replace Selection")) hReplace.addWidget(self._btnCloseReplace) hReplace.addWidget(self._lineReplace) hReplace.addWidget(self._btnReplace) hReplace.addWidget(self._btnReplaceAll) hReplace.addWidget(self._btnReplaceSelection) self.connect(self._btnReplace, SIGNAL("clicked()"), self.replace) self.connect(self._btnReplaceAll, SIGNAL("clicked()"), self.replace_all) self.connect(self._btnReplaceSelection, SIGNAL("clicked()"), self.replace_selected)
def __init__(self, text, icon_pixmap, parent=None): super(PaneButton, self).__init__(parent) button = QtGui.QPushButton(QtGui.QIcon(icon_pixmap), unicode(text), self) button.pressed.connect( self._button_pressed ) #button.setFlat(True) layout = QHBoxLayout() layout.setSpacing(0) layout.setContentsMargins(0,0,0,0) #self.icon = QLabel(self) #self.icon.setSizePolicy(QSizePolicy( # QSizePolicy.Fixed, QSizePolicy.Preferred)) #self.icon.setPixmap(icon_pixmap) #self.icon.setObjectName('PaneButtonIcon') #layout.addWidget(self.icon) #self.label = UserTranslatableLabel(text, self) #self.label.setAlignment(Qt.AlignLeft|Qt.AlignVCenter) #self.label.setObjectName('PaneButtonLabel') layout.addWidget( button ) self.setLayout(layout) self.setFixedHeight(self.height) self.setMinimumWidth(self.width) self.resize(self.width, self.height) self.setObjectName('PaneButton')
def setModel(self, model): """ Set model used to store the data. This method adds an extra row at the end, which is used to keep the "Add..." button. """ super( DatasetDetailedInfoTableView, self ).setModel(model) widget = QWidget() layout = QHBoxLayout(widget) self._addButton = button = AddFileButton(widget, new=True) button.addFilesRequested.connect( partial(self.addFilesRequested.emit, -1)) button.addStackRequested.connect( partial(self.addStackRequested.emit, -1)) button.addRemoteVolumeRequested.connect( partial(self.addRemoteVolumeRequested.emit, -1)) layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(button) layout.addStretch() widget.setLayout(layout) lastRow = self.model().rowCount()-1 modelIndex = self.model().index( lastRow, 0 ) self.setIndexWidget( modelIndex, widget ) # the "Add..." button spans last row self.setSpan(lastRow, 0, 1, model.columnCount())
def __init__(self, explorer): QWidget.__init__(self) vbox = QVBoxLayout(self) vbox.setContentsMargins(0, 0, 0, 0) vbox.addWidget(explorer) hbox = QHBoxLayout() hbox.setContentsMargins(0, 0, 0, 0) self.labelText = "Ln: %s, Col: %s" self.labelCursorPosition = QLabel(self.trUtf8(self.labelText % (0, 0))) hbox.addWidget(self.labelCursorPosition) self.combo = QComboBox() ui_tools.ComboBoxButton(self.combo, self.combo.clear, self.style().standardPixmap(self.style().SP_TrashIcon)) self.combo.setToolTip( self.trUtf8( "Select the item from the Paste " "Historial list.\nYou can Copy items into this list with: " "%s\nor Paste them using: %s" % ( resources.get_shortcut("History-Copy").toString(QKeySequence.NativeText), resources.get_shortcut("History-Paste").toString(QKeySequence.NativeText), ) ) ) self.combo.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) hbox.addWidget(self.combo) vbox.addLayout(hbox)
class PDF(QWidget, Script): def __init__(self): Script.__init__(self, "pdf") self.type = "pdfviewer" def updateWidget(self): pass def start(self, args): self.args = args try: self.node = args["file"].value() f = self.node.open() buff = f.read() f.close() self.document = popplerqt4.Poppler.Document.loadFromData(buff) except: pass def g_display(self): QWidget.__init__(self) self.hbox = QHBoxLayout() self.hbox.setContentsMargins(0, 0, 0, 0) pdfPage = self.document.page(1) image = pdfPage.renderToImage() label = QLabel() label.setPixmap(QPixmap.fromImage(image)) self.hbox.addWidget(label) self.setLayout(self.hbox)
def __init__(self, parent=None): QWidget.__init__(self, parent) self.parent = parent # This variables are used to save the splitter sizes before hide self._splitterMainSizes = None self._splitterAreaSizes = None self.lateralPanel = None hbox = QHBoxLayout(self) hbox.setContentsMargins(0, 0, 0, 0) hbox.setSpacing(0) # Create Splitters to divide the UI in: MainPanel, Explorer, Misc self._splitterArea = QSplitter(Qt.Horizontal) self._splitterMain = QSplitter(Qt.Vertical) # Create scrollbar for follow mode self.scrollBar = QScrollBar(Qt.Vertical, self) self.scrollBar.setFixedWidth(20) self.scrollBar.setToolTip("Follow Mode: Scroll the Editors together") self.scrollBar.hide() self.connect(self.scrollBar, SIGNAL("valueChanged(int)"), self.move_follow_scrolls) # Add to Main Layout hbox.addWidget(self.scrollBar) hbox.addWidget(self._splitterArea)
def __init__(self, explorer): QWidget.__init__(self) vbox = QVBoxLayout(self) vbox.setContentsMargins(0, 0, 0, 0) vbox.addWidget(explorer) hbox = QHBoxLayout() hbox.setContentsMargins(0, 0, 0, 0) self.labelText = "Ln: %s, Col: %s" self.labelCursorPosition = QLabel(self.trUtf8(self.labelText % (0, 0))) hbox.addWidget(self.labelCursorPosition) self.combo = QComboBox() ui_tools.ComboBoxButton( self.combo, self.combo.clear, self.style().standardPixmap(self.style().SP_TrashIcon)) self.combo.setToolTip( self.trUtf8( "Select the item from the Paste " "Historial list.\nYou can Copy items into this list with: " "%s\nor Paste them using: %s") % (resources.get_shortcut("History-Copy").toString( QKeySequence.NativeText), resources.get_shortcut("History-Paste").toString( QKeySequence.NativeText))) self.combo.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) hbox.addWidget(self.combo) vbox.addLayout(hbox)
def __init__(self, main_combo=False): super(ActionBar, self).__init__() self.setObjectName("actionbar") hbox = QHBoxLayout(self) hbox.setContentsMargins(1, 1, 1, 1) hbox.setSpacing(1) self.lbl_checks = QLabel('') self.lbl_checks.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.lbl_checks.setFixedWidth(48) self.lbl_checks.setVisible(False) hbox.addWidget(self.lbl_checks) self.combo = QComboBox() self.combo.setIconSize(QSize(16, 16)) #model = QStandardItemModel() #self.combo.setModel(model) #self.combo.view().setDragDropMode(QAbstractItemView.InternalMove) self.combo.setMaximumWidth(300) self.combo.setObjectName("combotab") self.connect(self.combo, SIGNAL("currentIndexChanged(int)"), self.current_changed) self.combo.setToolTip(translations.TR_COMBO_FILE_TOOLTIP) self.combo.setContextMenuPolicy(Qt.CustomContextMenu) self.connect(self.combo, SIGNAL( "customContextMenuRequested(const QPoint &)"), self._context_menu_requested) hbox.addWidget(self.combo) self.symbols_combo = QComboBox() self.symbols_combo.setIconSize(QSize(16, 16)) self.symbols_combo.setObjectName("combo_symbols") self.connect(self.symbols_combo, SIGNAL("activated(int)"), self.current_symbol_changed) hbox.addWidget(self.symbols_combo) self.code_navigator = CodeNavigator() hbox.addWidget(self.code_navigator) self._pos_text = "Line: %d, Col: %d" self.lbl_position = QLabel(self._pos_text % (0, 0)) self.lbl_position.setObjectName("position") self.lbl_position.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) hbox.addWidget(self.lbl_position) self.btn_close = QPushButton( self.style().standardIcon(QStyle.SP_DialogCloseButton), '') self.btn_close.setIconSize(QSize(16, 16)) if main_combo: self.btn_close.setObjectName('navigation_button') self.btn_close.setToolTip(translations.TR_CLOSE_FILE) self.connect(self.btn_close, SIGNAL("clicked()"), self.about_to_close_file) else: self.btn_close.setObjectName('close_split') self.btn_close.setToolTip(translations.TR_CLOSE_SPLIT) self.connect(self.btn_close, SIGNAL("clicked()"), self.close_split) self.btn_close.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) hbox.addWidget(self.btn_close)
def _getSpinbox(self, minvalue, maxvalue, step, nullable=True, value=0): ''' Get a combobox filled with the given values :param values: The values as key = value, value = description or text :type values: Dict :returns: A combobox :rtype: QWidget ''' widget = QWidget() spinbox = QDoubleSpinBox() spinbox.setMinimum(minvalue) spinbox.setMaximum(maxvalue) spinbox.setSingleStep(step) spinbox.setDecimals( len(str(step).split('.')[1]) if len(str(step).split('.')) == 2 else 0) if nullable: spinbox.setMinimum(minvalue - step) spinbox.setValue(spinbox.minimum()) spinbox.setSpecialValueText( str(QSettings().value('qgis/nullValue', 'NULL'))) if value is not None: spinbox.setValue(value) layout = QHBoxLayout(widget) layout.addWidget(spinbox, 1) layout.setAlignment(Qt.AlignCenter) layout.setContentsMargins(5, 0, 5, 0) widget.setLayout(layout) return widget