def __init(self): panelLayout = QtGui.QVBoxLayout() panelLayout.setSpacing(0) panelLayout.setContentsMargins(0, 0, 0, 0) self.setLayout(panelLayout) self.__titleBar = titleBar = TitleBar() panelLayout.addWidget(titleBar, 0) l = QtGui.QHBoxLayout() l.setContentsMargins(2, 2, 2, 2) l.setSpacing(2) self.__titleBar.setLayout(l) self.__titleButton = QtGui.QToolButton() self.__titleButton.setStyleSheet("border: 0px") styleOption = QtGui.QStyleOption() styleOption.initFrom(self.__titleButton) style = Application().style() icon = style.standardIcon(QtGui.QStyle.SP_DesktopIcon, styleOption, self.__titleButton) self.__titleButton.setIcon(icon) self.__titleLabel = TitleLabel() self.__upDownButton = QtGui.QToolButton() self.__upDownButton.setStyleSheet("border: 0px") self.__upDownButton.clicked.connect(self.switchContentVisible) l.addWidget(self.__titleButton, 0) l.addWidget(self.__titleLabel, 1) l.addWidget(self.__upDownButton, 0) self.__contentPanel = contentPanel = ContentPanel() panelLayout.addWidget(contentPanel, 1)
def report(self, message): app = Application() clipboard = app.clipboard() clipboard.setText(message) QtGui.QMessageBox.information(None, "Done!", "Message Copied to clipboard")
def main(): from qarbon.qt.gui.application import Application app = Application() class Axes(object): axes = {} def get(self, name): if not name in self.axes: self.axes[name] = [State.On, 0, [-10, 10]] return self.axes[name] def state(self, name): return self.get(name)[0] def position(self, name): return self.get(name)[1] def limits(self, name): return self.get(name)[2] def move(self, name, v): self.get(name)[1] = v def abort(self, name): pass p = QtGui.QWidget() layout = QtGui.QVBoxLayout() p.setLayout(layout) axes = Axes() axes_list = [] for i in range(16): name = "axis%02d" % i label = "Axis %02d" % i info = dict(name=name, label=label, role=str(i), index=i) axis = Axis(info, axes) axis.steps = [["1 um", 0.001], ["10 um", 0.01], ["1 mm", 1]] axis.currentStep = 0.01 axis.unit = "mm" axis.state = State(i) axes_list.append(axis) axis_w1 = AxesWidget(axes=axes_list) axis_w1.title = "First axes" layout.addWidget(axis_w1) axes_list[0].setLabel("Bla") # simulate motor at 5.4 axes.move("axis00", 5.4) axes_list[0].setPosition(5.4) axis_w2 = AxesWidget(axes=axes_list[:5]) axis_w2.title = "Second axes" layout.addWidget(axis_w2) layout.addStretch(1) p.show() app.exec_()
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 main(): log.initialize(log_level='debug') app = Application() w = XTermWindow() w.extraParams = ["-e", "ipython"] w.start() w.show() app.exec_()
def main(): from qarbon.qt.gui.application import Application app = Application() inspector = PropertyEditor(qobject=None) # watch myself... weard inspector.setQObject(inspector) inspector.show() app.exec_()
def main(): logging.basicConfig(level=logging.DEBUG) app = Application() w = XTermWidget() # w.extraParams = ["-e", "spec"] w.start() w.show() app.exec_()
def main(): from qarbon.qt.gui.application import Application app = Application() w = buildGUI() w.show() inspector = ObjectInfoWidget(qobject=w) inspector.setAttribute(QtCore.Qt.WA_QuitOnClose, False) inspector.show() app.exec_()
def main(): app = Application() w = buildGUI() w.show() inspector = TreeQObjectWidget(qobject=w) inspector.setAttribute(QtCore.Qt.WA_QuitOnClose, False) inspector.show() app.exec_()
def _onReportTriggered(self, index): report_handlers = get_report_handlers() combo = self.reportComboBox name = combo.itemData(index) report_handler = report_handlers[name] report = report_handler(self) app = Application() txt = _REPORT.format(appName=app.applicationName(), appVersion=app.applicationVersion(), time=datetime.datetime.now().ctime(), text=self.getText(), detail=self.getDetailedText(), origin=self.getOriginText()) report.report(txt)
def getQObjectTreeAsDict(qobject=None, ffilter=_filter): if qobject is None: app = Application() qobjects = [app] + app.topLevelWidgets() else: qobjects = [qobject] tree = {} for qobject in qobjects: if not ffilter(qobject) is None: _buildQObjectsAsDict(qobject, tree, ffilter=ffilter) return tree
def _onReportTriggered(self, index): report_handlers = get_report_handlers() combo = self.reportComboBox name = combo.itemData(index) report_handler = report_handlers[name] report = report_handler(self) app = Application() txt = _REPORT.format( appName=app.applicationName(), appVersion=app.applicationVersion(), time=datetime.datetime.now().ctime(), text=self.getText(), detail=self.getDetailedText(), origin=self.getOriginText(), ) report.report(txt)
def main(): config.APPLICATION_NAME = "Qarbon demo" app = Application() buggy() beamer = Beamer() turnBeamOn(beamer)
def main(): app = Application() d = dict(prompt="What's your favourite car brand?", data_type=["Mazda", "Skoda", "Citroen", "Mercedes", "Audi", "Ferrari"], default_value="Mercedes") w = InputPanel(d) class Listener(object): def onAccept(self): print "user selected", w.value() l = Listener() w.buttonBox().accepted.connect(l.onAccept) w.show() app.exec_()
def report(self, message): app = Application() subject = "Error in " + app.applicationName() dialog = self.createDialog(subject=subject, message=message) if not dialog.exec_(): return mail_info = dialog.getMailInfo() try: self.sendMail(*mail_info) QtGui.QMessageBox.information(None, "Done!", "Email has been sent!") except: einfo = sys.exc_info()[:2] msg = "".join(traceback.format_exception_only(*einfo)) QtGui.QMessageBox.warning(None, "Failed to send email", "Failed to send email. Reason:\n\n" + msg)
def report(self, message): app = Application() subject = "Error in " + app.applicationName() dialog = self.createDialog(subject=subject, message=message) if not dialog.exec_(): return mail_info = dialog.getMailInfo() try: self.sendMail(*mail_info) QtGui.QMessageBox.information(None, "Done!", "Email has been sent!") except: einfo = sys.exc_info()[:2] msg = "".join(traceback.format_exception_only(*einfo)) QtGui.QMessageBox.warning( None, "Failed to send email", "Failed to send email. Reason:\n\n" + msg)
def handle(self, *exc_info): app = Application() if app is None: return msgbox = self._getMessageBox(*exc_info) if msgbox is None: return if self._title is not None: msgbox.setWindowTitle(self._title) if self._msg is not None: msgbox.setText(self._msg) msgbox.show() return True
def main(): import sys import qarbon.config from qarbon.qt.gui.application import Application app = Application() M = 2 class QPixmapWidgetTestPanel(QtGui.QWidget): def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) panel_l = QtGui.QVBoxLayout() self.setLayout(panel_l) panel_l.setContentsMargins(M, M, M, M) panel_l.setSpacing(M) w = PixmapWidget() display_panel = QtGui.QGroupBox("Pixmap Widget Display") display_l = QtGui.QHBoxLayout() display_l.setContentsMargins(M, M, M, M) display_l.setSpacing(M) display_panel.setLayout(display_l) display_l.addWidget(w, 1) control_panel = QtGui.QGroupBox("Control Panel") control_l = QtGui.QFormLayout() control_l.setContentsMargins(M, M, M, M) control_l.setSpacing(M) control_panel.setLayout(control_l) pixmap_widget = QtGui.QLineEdit() ratio_widget = QtGui.QComboBox() transformation_widget = QtGui.QComboBox() halign_widget = QtGui.QComboBox() valign_widget = QtGui.QComboBox() control_l.addRow("pixmap:", pixmap_widget) control_l.addRow("Aspect ratio mode:", ratio_widget) control_l.addRow("Transformation mode:", transformation_widget) control_l.addRow("Horiz. alignment:", halign_widget) control_l.addRow("Vert. alignment:", valign_widget) panel_l.addWidget(display_panel, 1) panel_l.addWidget(control_panel, 0) ratio_widget.addItems(["Ignore", "Keep", "Keep by expanding"]) transformation_widget.addItem("Fast", QtCore.Qt.FastTransformation) transformation_widget.addItem("Smooth", QtCore.Qt.SmoothTransformation) halign_widget.addItem("Left", QtCore.Qt.AlignLeft) halign_widget.addItem("Center", QtCore.Qt.AlignHCenter) halign_widget.addItem("Right", QtCore.Qt.AlignRight) valign_widget.addItem("Top", QtCore.Qt.AlignTop) valign_widget.addItem("Center", QtCore.Qt.AlignVCenter) valign_widget.addItem("Bottom", QtCore.Qt.AlignBottom) pixmap_widget.textChanged.connect(self.changePixmap) ratio_widget.currentIndexChanged.connect(self.changeAspectRatio) halign_widget.currentIndexChanged.connect(self.changeAlignment) valign_widget.currentIndexChanged.connect(self.changeAlignment) self.w = w self.w_pixmap = pixmap_widget self.w_aspect_ratio = ratio_widget self.w_transformation = transformation_widget self.w_halign = halign_widget self.w_valign = valign_widget pixmap_widget.setText(qarbon.config.NAMESPACE + \ ":/led/led_red_on.png") ratio_widget.setCurrentIndex(1) transformation_widget.setCurrentIndex(1) halign_widget.setCurrentIndex(0) valign_widget.setCurrentIndex(1) def changePixmap(self, name): self.w.pixmap = QtGui.QPixmap(name) def changeAspectRatio(self, i): v = QtCore.Qt.IgnoreAspectRatio if i == 1: v = QtCore.Qt.KeepAspectRatio elif i == 2: v = QtCore.Qt.KeepAspectRatioByExpanding self.w.setAspectRatioMode(v) def changeTransformationMode(self, i): v = QtCore.Qt.FastTransformation if i == 1: v = QtCore.Qt.SmoothTransformation self.w.setTransformationMode(v) def changeAlignment(self, i): halign = self.w_halign.itemData(self.w_halign.currentIndex()) valign = self.w_valign.itemData(self.w_valign.currentIndex()) self.w.alignment = halign | valign panel = QtGui.QWidget() layout = QtGui.QGridLayout() panel.setLayout(layout) layout.setContentsMargins(M, M, M, M) layout.setSpacing(M) p1 = QPixmapWidgetTestPanel() layout.addWidget(p1, 0, 0) panel.show() sys.exit(app.exec_())
def setUp(self): self.app = Application()
def main(): from qarbon.qt.gui.icon import getIcon app = Application() app.setStyleSheet(GROUPBOX_NEBULA_STYLESHEET) w = QtGui.QWidget() l = QtGui.QVBoxLayout() w.setLayout(l) panel = GroupBox() panel.title = "Database" content = QtGui.QWidget() contentLayout = QtGui.QFormLayout() content.setLayout(contentLayout) panel.setContent(content) contentLayout.addRow("&Host", QtGui.QLineEdit()) contentLayout.addRow("&Port", QtGui.QLineEdit()) l.addWidget(panel, 0) panel = GroupBox() panel.title = "Hello world" panel.titleIcon = getIcon("video-x-generic") panel.styleMap = { 'title_start_color': 'rgb(255, 60, 60)', 'title_stop_color': 'rgb(200, 0, 0)', 'title_font_color': 'rgb(140, 0, 0)', 'title_border_radius': '10px', 'content_border_radius': '0px', } content = QtGui.QWidget() contentLayout = QtGui.QFormLayout() content.setLayout(contentLayout) panel.setContent(content) contentLayout.addRow("State", QtGui.QPushButton("Press here")) contentLayout.addRow("Status", QtGui.QLineEdit()) contentLayout.addRow("Coment", QtGui.QLineEdit()) contentLayout.addRow("Build", QtGui.QCheckBox()) contentLayout.addRow("Upper limit", QtGui.QSpinBox()) contentLayout.addRow("Lower limit", QtGui.QSpinBox()) l.addWidget(panel, 0) panel = GroupBox() panel.title = "Hello world 2" panel.titleIcon = getIcon("network-server") panel.titleVisible = False content = QtGui.QWidget() contentLayout = QtGui.QFormLayout() content.setLayout(contentLayout) panel.setContent(content) contentLayout.addRow("Something", QtGui.QLineEdit()) contentLayout.addRow("More", QtGui.QLineEdit()) l.addWidget(panel, 0) panel = GroupBox() panel.title = "5" panel.titleIcon = getIcon("folder") content = QtGui.QWidget() contentLayout = QtGui.QVBoxLayout() content.setLayout(contentLayout) panel.setContent(content) panel2 = GroupBox() panel2.title = "5.1" panel2.titleIcon = getIcon("folder") panel2.titleHeight = 48 content2 = QtGui.QWidget() contentLayout2 = QtGui.QFormLayout() content2.setLayout(contentLayout2) panel2.setContent(content2) contentLayout2.addRow("Something", QtGui.QLineEdit()) contentLayout2.addRow("More", QtGui.QLineEdit()) contentLayout.addWidget(panel2, 0) l.addWidget(panel, 0) l.addStretch(1) w.show() w.adjustSize() app.exec_() return w
def getStyle(): """Returns the current active application style :return: the current active application style :rtype: QtGui.QStyle""" return Application().style()
def main(): class __DemoException(Exception): pass def s1(): return s2() def s2(): return s3() def s3(): raise __DemoException("A demo exception occurred") def py_exc(): try: s1() except: msgbox = ErrorDialog(*sys.exc_info()) msgbox.exec_() def tg_exc(): try: import PyTango PyTango.Except.throw_exception("TangoException", "A simple tango exception", "right here") except PyTango.DevFailed: msgbox = ErrorDialog(*sys.exc_info()) msgbox.exec_() def tg_serv_exc(): try: import PyTango dev = PyTango.DeviceProxy("sys/tg_test/1") dev.read_attribute("throw_exception") except PyTango.DevFailed: msgbox = ErrorDialog(*sys.exc_info()) msgbox.exec_() except: msgbox = ErrorDialog(*sys.exc_info()) msgbox.exec_() def py_tg_serv_exc(): try: import PyTango PyTango.Except.throw_exception("TangoException", "A simple tango exception", "right here") except PyTango.DevFailed as df1: try: import StringIO origin = StringIO.StringIO() traceback.print_stack(file=origin) origin.seek(0) origin = origin.read() PyTango.Except.re_throw_exception( df1, "PyDs_Exception", "DevFailed: A simple tango " "exception", origin ) except PyTango.DevFailed: msgbox = ErrorDialog(*sys.exc_info()) msgbox.exec_() app = Application() app.setApplicationName("Message dialog demo") app.setApplicationVersion("1.0") panel = QtGui.QWidget() layout = QtGui.QVBoxLayout() panel.setLayout(layout) m1 = QtGui.QPushButton("Python exception") layout.addWidget(m1) m1.clicked.connect(py_exc) m2 = QtGui.QPushButton("Tango exception") layout.addWidget(m2) m2.clicked.connect(py_exc) layout.addWidget(m2) m3 = QtGui.QPushButton("Tango server exception") layout.addWidget(m3) m3.clicked.connect(tg_serv_exc) layout.addWidget(m3) m4 = QtGui.QPushButton("Python tango server exception") layout.addWidget(m4) m4.clicked.connect(py_tg_serv_exc) layout.addWidget(m4) panel.show() sys.exit(app.exec_())
def main(): class __DemoException(Exception): pass def s1(): return s2() def s2(): return s3() def s3(): raise __DemoException("A demo exception occurred") def py_exc(): try: s1() except: msgbox = ErrorDialog(*sys.exc_info()) msgbox.exec_() def tg_exc(): try: import PyTango PyTango.Except.throw_exception('TangoException', 'A simple tango exception', 'right here') except PyTango.DevFailed: msgbox = ErrorDialog(*sys.exc_info()) msgbox.exec_() def tg_serv_exc(): try: import PyTango dev = PyTango.DeviceProxy("sys/tg_test/1") dev.read_attribute("throw_exception") except PyTango.DevFailed: msgbox = ErrorDialog(*sys.exc_info()) msgbox.exec_() except: msgbox = ErrorDialog(*sys.exc_info()) msgbox.exec_() def py_tg_serv_exc(): try: import PyTango PyTango.Except.throw_exception('TangoException', 'A simple tango exception', 'right here') except PyTango.DevFailed as df1: try: import StringIO origin = StringIO.StringIO() traceback.print_stack(file=origin) origin.seek(0) origin = origin.read() PyTango.Except.re_throw_exception( df1, 'PyDs_Exception', 'DevFailed: A simple tango ' 'exception', origin) except PyTango.DevFailed: msgbox = ErrorDialog(*sys.exc_info()) msgbox.exec_() app = Application() app.setApplicationName("Message dialog demo") app.setApplicationVersion("1.0") panel = QtGui.QWidget() layout = QtGui.QVBoxLayout() panel.setLayout(layout) m1 = QtGui.QPushButton("Python exception") layout.addWidget(m1) m1.clicked.connect(py_exc) m2 = QtGui.QPushButton("Tango exception") layout.addWidget(m2) m2.clicked.connect(py_exc) layout.addWidget(m2) m3 = QtGui.QPushButton("Tango server exception") layout.addWidget(m3) m3.clicked.connect(tg_serv_exc) layout.addWidget(m3) m4 = QtGui.QPushButton("Python tango server exception") layout.addWidget(m4) m4.clicked.connect(py_tg_serv_exc) layout.addWidget(m4) panel.show() sys.exit(app.exec_())