def __init__(self, items, default="name", parent=None): QtGui.QWidget.__init__(self, parent) QtGui.QVBoxLayout(self) self.__default = default self.setMaximumHeight(200) self.list_widget = QtGui.QListWidget(self) self.list_widget.itemDoubleClicked.connect(self.list_widget.editItem) for item in (items or []): list_item = self.__newItem(item) self.list_widget.addItem(list_item) self.list_widget.sortItems() self.btn_add = QtGui.QPushButton(QtGui.QIcon(":/images/plus.png"), "", self) self.btn_add.setFlat(True) self.btn_add.clicked.connect(self.addItem) self.btn_sub = QtGui.QPushButton(QtGui.QIcon(":/images/minus.png"), "", self) self.btn_sub.setFlat(True) self.btn_sub.clicked.connect(self.removeItems) layout_btn = QtGui.QHBoxLayout() layout_btn.setContentsMargins(0, 0, 0, 0) layout_btn.setSpacing(1) layout_btn.addStretch() layout_btn.addWidget(self.btn_add) layout_btn.addWidget(self.btn_sub) self.layout().addWidget(self.list_widget) self.layout().addLayout(layout_btn)
def __init__(self, value, parent): QtGui.QWidget.__init__(self, parent) self.__locked = QtGui.QPushButton("Locked", self) self.__locked.setObjectName("Locked") self.__locked.setAutoExclusive(True) self.__locked.setCheckable(True) self.__locked.setStyleSheet(_LOCKED_BTN_STYLE) self.__locked.setFocusPolicy(QtCore.Qt.NoFocus) self.__unlocked = QtGui.QPushButton("UnLocked", self) self.__unlocked.setObjectName("Unlocked") self.__unlocked.setAutoExclusive(True) self.__unlocked.setCheckable(True) self.__unlocked.setStyleSheet(_UNLOCKED_BTN_STYLE) self.__unlocked.setFocusPolicy(QtCore.Qt.NoFocus) if value: self.__locked.setChecked(True) else: self.__unlocked.setChecked(True) l = QtGui.QHBoxLayout(self) l.setSpacing(0) l.setContentsMargins(0, 0, 0, 0) l.addWidget(self.__locked) l.addWidget(self.__unlocked)
def __init__(self, *args, **kwargs): super(DragDropItem, self).__init__(*args, **kwargs) self.__dragStartPos = QtCore.QPoint(0,0) self.setMinimumHeight(24) self.setMaximumHeight(50) self.setCheckable(True) self.setFocusPolicy(QtCore.Qt.NoFocus) self.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred) wrapperLayout = QtGui.QHBoxLayout(self) wrapperLayout.setSpacing(0) wrapperLayout.setContentsMargins(0,0,0,0) self._widgetLayout = layout = QtGui.QHBoxLayout() layout.setSpacing(self.ITEM_SPACING) layout.setContentsMargins(8,1,8,1) wrapperLayout.addLayout(layout) wrapperLayout.addStretch()
def __init__(self, node, parent): QtGui.QWidget.__init__(self, parent) l = QtGui.QHBoxLayout(self) for load in node.system.load: box = QtGui.QDoubleSpinBox(parent) box.setValue(load / 100.0) if box.value() > node.system.physicalCores + (node.system.logicalCores * .2): box.setStyleSheet("background-color: rgba(177, 24, 0, 192)") box.setReadOnly(True) box.setButtonSymbols(QtGui.QAbstractSpinBox.NoButtons) box.setFocusPolicy(QtCore.Qt.NoFocus) l.addWidget(box)
def __init__(self, name, ptype, parent=None): QtGui.QDockWidget.__init__(self, parent) # Add the standard dock action buttons in. # TODO: hook up signals self.__label = QtGui.QLabel(self) self.__label.setIndent(10) self.__name = None self.__ptype = ptype self.setName(name) self.attrs = {} self.__refreshTimer = None # Note: the widet in the panel adds more buttons # to this toolbar. titleBar = QtGui.QWidget(self) barLayout = QtGui.QHBoxLayout(titleBar) barLayout.setSpacing(0) barLayout.setContentsMargins(0, 0, 0, 0) self.__toolbar = toolbar = QtGui.QToolBar(self) toolbar.setIconSize(QtCore.QSize(18, 18)) toolbar.addAction(QtGui.QIcon(":/images/close.png"), "Close", self.__close) float_action = QtGui.QAction(QtGui.QIcon(":/images/float.png"), "Float", self) float_action.toggled.connect(self.__floatingChanged) float_action.setCheckable(True) toolbar.addAction(float_action) config_action = QtGui.QAction(QtGui.QIcon(":/images/config.png"), "Configure Panel", self) config_action.triggered.connect(self._openPanelSettingsDialog) toolbar.addAction(config_action) toolbar.addSeparator() barLayout.addWidget(toolbar) barLayout.addStretch() barLayout.addWidget(self.__label) barLayout.addSpacing(4) self.setTitleBarWidget(titleBar) self.init()
def __init__(self, filt=None, items=None, data=None, parent=None): QtGui.QWidget.__init__(self, parent) self.__data = {} self.__txt_label = QtGui.QLabel(self) self.__txt_filter = QtGui.QLineEdit(self) self.__txt_filter.textChanged.connect(self.__filterChanged) self.__model = QtGui.QStringListModel(self) self.__proxyModel = proxy = QtGui.QSortFilterProxyModel(self) proxy.setSourceModel(self.__model) self.__list = view = QtGui.QListView(self) view.setSelectionMode(self.__list.ExtendedSelection) view.setModel(proxy) proxy.sort(0) proxy.setDynamicSortFilter(True) layout = QtGui.QVBoxLayout(self) layout.setSpacing(4) layout.setContentsMargins(0, 0, 0, 0) hlayout = QtGui.QHBoxLayout() hlayout.setContentsMargins(0, 0, 0, 0) hlayout.addWidget(self.__txt_label) hlayout.addWidget(self.__txt_filter) layout.addLayout(hlayout) layout.addWidget(self.__list) # connections self.__list.doubleClicked.connect(self._itemDoubleClicked) self.__list.clicked.connect(self._itemClicked) self.__list.selectionModel().selectionChanged.connect( self._selectionChanged) if items: self.setStringList(items) if filt: self.setFilter(filt)
def __init__(self, minimum, maximum, value, parent=None): QtGui.QWidget.__init__(self, parent) layout = QtGui.QHBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) self.slider = QtGui.QSlider(QtCore.Qt.Horizontal, self) self.slider.setMaximum(maximum) self.slider.setMinimum(minimum) self.slider.setValue(value) self.spin = QtGui.QSpinBox(self) self.spin.setRange(minimum, maximum) self.spin.setValue(value) self.spin.valueChanged.connect(self.slider.setValue) self.slider.valueChanged.connect(self.spin.setValue) layout.addWidget(self.slider) layout.addWidget(self.spin)
def __init__(self, text, help, parent=None): QtGui.QWidget.__init__(self, parent) QtGui.QHBoxLayout(self) self.__help = help self.__btn = QtGui.QToolButton(self) self.__btn.setIcon(QtGui.QIcon(":/images/help.png")) self.__btn.setFocusPolicy(QtCore.Qt.NoFocus) self.__btn.clicked.connect(self.__show_popup) self.__btn.setStyleSheet("QToolButton { border: 0px }") self.__label = QtGui.QLabel(text, self) self.layout().setContentsMargins(0, 0, 0, 0) self.layout().setSpacing(0) self.layout().addWidget(self.__btn) self.layout().addSpacing(5) self.layout().addWidget(self.__label) self.layout().addStretch()
def __init__(self, parent=None): super(DragDropList, self).__init__(parent) self.setFrameStyle(self.Panel|self.Sunken) self.setAcceptDrops(True) self._buttonGroup = QtGui.QButtonGroup(self) self._buttonGroup.setExclusive(True) header = QtGui.QWidget(self) header.setFixedHeight(20) headerLayout = QtGui.QHBoxLayout(header) headerLayout.setSpacing(0) headerLayout.setContentsMargins(8, 0, 8, 0) self._headerLayer = headerLayout self._contentWidget = content = QtGui.QWidget(self) scroll = QtGui.QScrollArea(self) scroll.setFrameStyle(self.Panel|self.Raised) scroll.setWidgetResizable(True) scroll.setWidget(content) scrollLayout = QtGui.QVBoxLayout(content) scrollLayout.setSpacing(0) scrollLayout.setContentsMargins(0, 0, 0, 0) self._itemLayout = QtGui.QVBoxLayout() self._itemLayout.setSpacing(self.ITEM_SPACING) self._itemLayout.setContentsMargins(0, 12, 0, 12) scrollLayout.addLayout(self._itemLayout) scrollLayout.addStretch() layout = QtGui.QVBoxLayout(self) layout.setContentsMargins(4, 4, 4, 4) layout.addWidget(header) layout.addWidget(scroll) # Connections self._buttonGroup.buttonClicked.connect(self.itemClicked)
def __init__(self, parent=None): super(JobColumnWidget, self).__init__(parent) self.__currentJob = None self.__currentLayer = None self.__currentTask = None self.setFocusPolicy(QtCore.Qt.NoFocus) contentWidget = QtGui.QWidget(self) self.setWidget(contentWidget) self.setWidgetResizable(True) mainLayout = QtGui.QHBoxLayout(contentWidget) self._jobWidget = job = JobSelectionWidget(self) job.setMinimumWidth(220) self._layerWidget = layer = FilterableListBox(parent=self) layer.setLabel("Layer:") layer.setMinimumWidth(180) self._taskWidget = task = FilterableListBox(parent=self) task.setLabel("Task:") task.setMinimumWidth(120) mainLayout.addWidget(job) mainLayout.addWidget(layer) mainLayout.addWidget(task) # connections job.selectionChanged.connect(self._jobSelectionChanged) job.valueClicked.connect(layer.clearSelection) job.valueClicked.connect(task.clearSelection) layer.selectionChanged.connect(self._layerSelectionChanged) layer.valueClicked.connect(task.clearSelection) task.selectionChanged.connect(self._taskSelectionChanged)
def __init__(self, project, *args, **kwargs): super(FilterManager, self).__init__(*args, **kwargs) self._projectLabel = QtGui.QLabel(self) self._filtersList = filt = FiltersList(parent=self) self._matchersList = match = MatchersList(parent=self) self._actionsList = act = ActionsList(parent=self) self._toolbar = tb = QtGui.QToolBar(self) tb.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) tb.setMaximumHeight(32) tb.addAction(QtGui.QIcon(":/images/refresh.png"), "Refresh", self.refresh) self._status = QtGui.QStatusBar(self) h_splitter = QtGui.QSplitter(QtCore.Qt.Horizontal, self) h_splitter.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Expanding) v_splitter = QtGui.QSplitter(QtCore.Qt.Vertical, self) v_splitter.addWidget(self._matchersList) v_splitter.addWidget(self._actionsList) h_splitter.addWidget(self._filtersList) h_splitter.addWidget(v_splitter) tbLayout = QtGui.QHBoxLayout() tbLayout.setContentsMargins(0, 0, 4, 0) tbLayout.addWidget(self._toolbar) tbLayout.addWidget(self._projectLabel) layout = QtGui.QVBoxLayout(self) layout.setContentsMargins(6, 0, 6, 4) layout.setSpacing(2) layout.addLayout(tbLayout) layout.addWidget(h_splitter) layout.addWidget(self._status) v_splitter.setSizes([100,100]) h_splitter.setSizes([100,100]) self.setStyleSheet(""" DragDropItem { border: 1px solid black; border-radius: 4px; background-color: QLinearGradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 rgb(40, 40, 40), stop: 1 rgb(27, 28, 30) ); } DragDropItem:checked { border: 1px solid rgb(100,100,100); background-color: QLinearGradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 1 rgb(40, 40, 40), stop: 0 rgb(27, 28, 30) ); } """) self.setProject(project) # Connnections filt.filterSelected.connect(match.setFilterObject) filt.filterSelected.connect(act.setFilterObject)
def __init__(self, filt=None, items=None, data=None, parent=None): super(FilterableListBox, self).__init__(parent) self.__data = {} height = 20 self.__txt_label = QtGui.QLabel(self) self.__txt_filter = QtGui.QLineEdit(self) self.__txt_filter.setFixedHeight(height) self.__txt_filter.textChanged.connect(self.__filterChanged) self.__txt_clear = btn = QtGui.QPushButton(self) btn.setIcon(QtGui.QIcon(":/images/delete.png")) btn.setFlat(True) btn.setFixedSize(height, height) btn.setIconSize(QtCore.QSize(14, 14)) btn.setVisible(False) self.__model = QtGui.QStringListModel(self) self.__proxyModel = proxy = QtGui.QSortFilterProxyModel(self) proxy.setSourceModel(self.__model) self.__list = view = QtGui.QListView(self) view.setSelectionMode(self.__list.ExtendedSelection) view.setModel(proxy) proxy.sort(0) proxy.setDynamicSortFilter(True) layout = QtGui.QVBoxLayout(self) layout.setSpacing(4) layout.setContentsMargins(0, 0, 0, 0) hlayout = QtGui.QHBoxLayout() hlayout.setSpacing(0) hlayout.setContentsMargins(0, 0, 0, 0) hlayout.addWidget(self.__txt_label) hlayout.addSpacing(2) hlayout.addWidget(self.__txt_filter) hlayout.addWidget(self.__txt_clear) layout.addLayout(hlayout) layout.addWidget(self.__list) # connections self.__list.doubleClicked.connect(self._itemDoubleClicked) self.__list.clicked.connect(self._itemClicked) self.__selModel = self.__list.selectionModel() self.__selModel.selectionChanged.connect(self._selectionChanged) self.__txt_filter.textChanged.connect( lambda v: self.__txt_clear.setVisible(bool(v))) self.__txt_clear.clicked.connect(lambda: self.setFilter('')) if items: self.setStringList(items) if filt: self.setFilter(filt)