def main(): import sys from qarbon.qt.gui.icon import Icon from qarbon.qt.gui.application import Application app = Application() w = QtGui.QWidget() w.setWindowTitle("Led demo") w.setWindowIcon(Icon(":/led/led_green_on.png")) layout = QtGui.QGridLayout() layout.setContentsMargins(2, 2, 2, 2) layout.setSpacing(2) w.setLayout(layout) for i, color in enumerate(LedColor): led = Led() led.ledColor = color led.ledStatus = LedStatus.Off layout.addWidget(led, i, 0) led = Led() led.ledColor = color led.ledStatus = LedStatus.On layout.addWidget(led, i, 1) w.show() sys.exit(app.exec_())
def __init__(self, err_type=None, err_value=None, err_traceback=None, parent=None): QtGui.QWidget.__init__(self, parent) if err_type is None and err_value is None and err_traceback is None: err_type, err_value, err_traceback = sys.exc_info()[:3] self._exc_info = err_type, err_value, err_traceback ui_file_name = os.path.join(os.path.dirname(__file__), "ui", "errorpanel.ui") uic.loadUi(ui_file_name, baseinstance=self) self.detailsWidget.setVisible(False) self.checkBox.setVisible(False) self.checkBox.setCheckState(QtCore.Qt.Unchecked) self._initReportCombo() self.showDetailsButton.toggled.connect(self._onShowDetails) self.reportComboBox.activated.connect(self._onReportTriggered) self.setIcon(Icon("emblem-important")) if err_value is not None: self.setError(*self._exc_info) self.adjustSize()
def __init__(self, axis, parent=None): # media-skip-forward # media-seek-forward # go-next # edit-redo # fwk4:/forward.png # fwk4:/1rightarrow.png icon = Icon("edit-redo") super(StepRightButton, self).__init__(axis, icon=icon, parent=parent)
def __init__(self, axis, parent=None): # media-skip-backward # media-seek-backward # go-previous # edit-undo # fwk4:/backward.png # fwk4:/1leftarrow.png icon = Icon("edit-undo") super(StepLeftButton, self).__init__(axis, icon=icon, parent=parent)
def getAction(text, parent=None, shortcut=None, icon=None, tooltip=None, toggled=None, triggered=None, data=None, context=QtCore.Qt.WindowShortcut): """Create a new QAction. This is function as the same effect as :func:`Action`. Please use :func:`Action` instead. :param text: label for the action :type text: str :param parent: parent QObject :type parent: QObject :param shortcut: optional shortcut :type shortcut: QtGui.QKeySequence :param icon: optional icon. Can be a QIcon or a string :type icon: QIcon or str :param tooltip: optional tool tip :type tooltip: str :param toggled: optional toggled slot :type toggled: callable :param data: optional data :type data: object :param context: action context :type context: ShortcutContext :return: a customized QAction :rtype: QAction """ action = QtGui.QAction(text, parent) if triggered is not None: action.triggered.connect(triggered) if toggled is not None: action.toggled.connect(toggled) action.setCheckable(True) action.setIcon(Icon(icon)) if shortcut is not None: action.setShortcut(shortcut) if tooltip is not None: action.setToolTip(tooltip) action.setStatusTip(tooltip) if data is not None: action.setData(data) #TODO: Hard-code all shortcuts and choose context=Qt.WidgetShortcut # (this will avoid calling shortcuts from another dockwidget # since the context thing doesn't work quite well with these widgets) action.setShortcutContext(context) return action
def __init__(self, **kwargs): parent = kwargs.pop('parent', None) flags = kwargs.pop('flags', QtCore.Qt.WindowFlags()) super(XCommandWindow, self).__init__(parent=parent, flags=flags) x11 = self.Widget(parent=self, **kwargs) self.setCentralWidget(x11) toolBar = self.addToolBar("Actions") self.__actionsToolBar = weakref.ref(toolBar) self.__restartAction = Action("Restart", parent=self, icon=Icon("view-refresh"), tooltip="restart the current command", triggered=self.restart) toolBar.addAction(self.__restartAction)
def __init__(self, title=None, axes=None, parent=None): super(AxesWidget, self).__init__(parent) self._axes = {} contentWidget = QtGui.QWidget() layout = QtGui.QGridLayout() layout.setColumnStretch(Column.Position.value, 1) layout.setContentsMargins(2, 2, 2, 2) layout.setSpacing(2) contentWidget.setLayout(layout) self.setContent(contentWidget) self.setTitle(title) self.setTitleIcon(Icon(":/objects/motor.png")) self.setAxes(axes) self.resetUpdateStatusBar()
def onAxisStateChanged(self, name, old_state, state): axis = self.getAxis(name) position_widget = self.axisColumnWidget(axis, Column.Position) position_widget.setState(state) if self.updateStatusBar and old_state != state: icon = Icon(state) message = axis.label + " " if state == State.Moving: message += "started to move..." elif old_state == State.Moving: message += "stopped!" else: message += "changed from {0} to {1}".format( old_state.name, state.name) self.__setStatus(message, icon) self.__updateAxis(axis)
def __init__(self, parent=None, qobject=None): super(ObjectInfoWidget, self).__init__(parent) self.setWindowIcon(Icon("applications-development")) self.setWindowTitle("QObject Inspector") layout = QtGui.QHBoxLayout() self.setLayout(layout) layout.setSpacing(0) layout.setMargin(0) self.__splitter = splitter = QtGui.QSplitter(QtCore.Qt.Horizontal, self) layout.addWidget(splitter) self.__form = form = PropertyEditor(parent=splitter, qobject=qobject) self.__tree = tree = TreeQObjectWidget(parent=splitter, qobject=qobject) splitter.addWidget(tree) splitter.addWidget(form) treeSelectionModel = tree.viewWidget().selectionModel() QtCore.QObject.connect( treeSelectionModel, QtCore.SIGNAL("selectionChanged(QItemSelection, QItemSelection)"), self.__onSelectionChanged)
def getQObjectIcon(qo): if isinstance(qo, QtGui.QWidget): name = "widget" if isinstance(qo, QtGui.QLabel): name = "label" elif isinstance(qo, QtGui.QComboBox): name = "combobox" elif isinstance(qo, QtGui.QDoubleSpinBox): name = "doublespinbox" elif isinstance(qo, QtGui.QDateEdit): name = "dateedit" elif isinstance(qo, QtGui.QTimeEdit): name = "timeedit" elif isinstance(qo, QtGui.QDateTimeEdit): name = "datetimeedit" elif isinstance(qo, QtGui.QLineEdit): name = "linedit" elif isinstance(qo, QtGui.QPlainTextEdit): name = "plaintextedit" elif isinstance(qo, QtGui.QTextEdit): name = "textedit" elif isinstance(qo, QtGui.QTabWidget): name = "tabwidget" elif isinstance(qo, QtGui.QRadioButton): name = "radiobutton" elif isinstance(qo, QtGui.QPushButton): name = "pushbutton" elif isinstance(qo, QtGui.QToolButton): name = "toolbutton" elif isinstance(qo, QtGui.QCheckBox): name = "checkbox" elif isinstance(qo, QtGui.QToolBox): name = "toolbox" elif isinstance(qo, QtGui.QTreeView): name = "tree" elif isinstance(qo, QtGui.QTableView): name = "table" elif isinstance(qo, QtGui.QListView): name = "listbox" elif isinstance(qo, QtGui.QStackedWidget): name = "widgetstack" elif isinstance(qo, QtGui.QDockWidget): name = "dockwidget" elif isinstance(qo, QtGui.QDockWidget): name = "dockwidget" elif isinstance(qo, QtGui.QCalendarWidget): name = "calendarwidget" elif isinstance(qo, QtGui.QDialogButtonBox): name = "dialogbuttonbox" elif isinstance(qo, QtGui.QFrame): name = "frame" elif isinstance(qo, QtGui.QAbstractSpinBox): name = "spinbox" elif isinstance(qo, QtGui.QAbstractButton): name = "pushbutton" elif isinstance(qo, QtGui.QAbstractSlider): name = "hslider" return Icon(":/designer/" + name + ".png") elif isinstance(qo, QtGui.QLayout): name = "editform" if isinstance(qo, QtGui.QVBoxLayout): name = "editvlayout" elif isinstance(qo, QtGui.QHBoxLayout): name = "edithlayout" elif isinstance(qo, QtGui.QGridLayout): name = "editgrid" elif isinstance(qo, QtGui.QFormLayout): name = "editform" elif isinstance(qo, QtCore.QCoreApplication): return Icon("applications-development") return Icon("emblem-system")
def contextMenuEvent(self, event): menu = QtGui.QMenu(self) refreshAction = QtGui.QAction(Icon("view-refresh"), "Refresh", self) refreshAction.triggered.connect(self.axis.refresh) menu.addAction(refreshAction) menu.popup(event.globalPos())
def __init__(self, axis, parent=None): # media-playback-stop # process-stop icon = Icon("process-stop") super(StopButton, self).__init__(axis, icon=icon, parent=parent)
def addSteps(self, steps): icon = Icon(":/controls/step2.png") for step_label, step_value in steps: self.addItem(icon, step_label, step_value)