def __init__(self, parent, appdata): super(SessionInfos, self).__init__(parent) self.appdata = appdata self.setWindowTitle( 'Information for the session' ) self.setFixedSize(250, 300) self.buttonBox = QDialogButtonBox( self ) self.buttonBox.setOrientation( Qt.Horizontal ) self.buttonBox.setStandardButtons( QDialogButtonBox.Cancel|QDialogButtonBox.Ok ) labelcombo = QLabel( 'Breathing Zone:' ) self.breathzone = QComboBox() self.breathzone.addItem( '', '' ) self.breathzone.addItem( 'Abdominal', 1 ) self.breathzone.addItem( 'Thoracic', 2 ) self.breathzone.move(10, 10) labelnote = QLabel( 'Note:' ) self.note = QTextEdit() layout = QVBoxLayout() layout.addWidget( self.create_SessionType_Group() ) layout.addWidget( labelcombo ) layout.addWidget( self.breathzone ) layout.addWidget( labelnote ) layout.addWidget( self.note ) layout.addWidget( self.buttonBox ) self.setLayout( layout ) self.buttonBox.accepted.connect( self.accept ) self.buttonBox.rejected.connect( self.reject )
def __init__(self, item, parent_layout): super(TextEditWidget, self).__init__(item, parent_layout) self.edit = self.group = QTextEdit() self.edit.setToolTip(item.get_help()) if hasattr(item, "min_equals_max") and item.min_equals_max(): if item.check_item(): self.edit.setEnabled(False) self.edit.setToolTip(_("Value is forced to %d") % item.get_max()) self.edit.textChanged.connect(self.text_changed)
def setupMainWidget(self) : self.main_dock = QDockWidget(_('')) self.addDockWidget(Qt.BottomDockWidgetArea, self.main_dock) self.dockTab = QTabWidget() dockSplitter = QSplitter() dockSplitter.setOrientation(Qt.Vertical) #----- toolbar = self.addToolBar("Curve") self.plotWidget = CentralWidget(self, toolbar) # Set central widget: self.dockTab.addTab(self.plotWidget, "Plot") #----- self.statusEdit = QTextEdit() self.statusEdit.setText("Status updates to go here.") self.statusEdit.setEnabled(False) self.statusEdit.moveCursor(QTextCursor.End) #----- self.testButton = QPushButton("Test Button") self.testButton.clicked.connect(self.__testClick__) dockSplitter.addWidget(self.testButton) dockSplitter.addWidget(self.statusEdit) self.dockTab.addTab(dockSplitter, "Status Info") if DockableConsole is None: self.console = None else: import time, scipy.signal as sps, scipy.ndimage as spi import sys, os import numpy as np ns = {'np': np, 'sps': sps, 'spi': spi, 'os': os, 'sys': sys, 'time': time} msg = "Example: np.arange(20)\n"\ "Modules imported at startup: "\ "os, sys, os.path as osp, time, "\ "numpy as np, scipy.signal as sps, scipy.ndimage as spi" self.console = DockableConsole(self, namespace=ns, message=msg) # console_dock = QDockWidget(_('Console')) # self.addDockWidget(Qt.BottomDockWidgetArea, console_dock) # console_dock.setWidget(self.console) self.dockTab.addTab(self.console, "Console") # dockSplitter.addWidget(self.console) # main_dock.setWidget(dockSplitter) self.main_dock.setWidget(self.dockTab)
def __init__(self, parent=None): QTextEdit.__init__(self, parent) self.setReadOnly(True) self.setHtml(self.latest_status())
def __init__(self, parent=None): QTextEdit.__init__(self, parent) self.setReadOnly(True) self.setHtml(self.latest_status())
class MainWindow(QMainWindow): def __init__(self, parent = None): QMainWindow.__init__(self, parent) self.console = None self.setup() def closeEvent(self, event): if self.console is not None: self.console.exit_interpreter() event.accept() def setup(self): """Setup window parameters""" self.setWindowIcon(get_icon('python.png')) self.setWindowTitle(APP_NAME) self.resize(QSize(600, 800)) # Welcome message in statusbar: status = self.statusBar() status.showMessage(_("Welcome to guiqwt application example!"), 5000) self.setupMainWidget() # File menu file_menu = self.menuBar().addMenu(_("File")) new_action = create_action(self, _("New..."), shortcut="Ctrl+N", icon=get_icon('filenew.png'), tip=_("Create a new image"), triggered=self.new_image) open_action = create_action(self, _("Open..."), shortcut="Ctrl+O", icon=get_icon('fileopen.png'), tip=_("Open an image"), triggered=self.open_image) quit_action = create_action(self, _("Quit"), shortcut="Ctrl+Q", icon=get_std_icon("DialogCloseButton"), tip=_("Quit application"), triggered=self.close) add_actions(file_menu, (new_action, open_action, None, quit_action)) processing_menu = self.menuBar().addMenu(_("Processing")) autoscale_action = create_action(self, _("Autoscale"), shortcut="Ctrl+W", tip=_("Autoscale Graph"), triggered=self.plotWidget.autoScale) add_actions(processing_menu, (autoscale_action,)) # Help menu help_menu = self.menuBar().addMenu("?") about_action = create_action(self, _("About..."), icon=get_std_icon('MessageBoxInformation'), triggered=self.about) add_actions(help_menu, (about_action,)) main_toolbar = self.addToolBar("Main") add_actions(main_toolbar, (new_action, open_action, )) self.curFIFOVal = 0 self.rdb = r.Redis('localhost') # self.setShortcuts() # self.setCentralWidget(self.plotWidget) self.setCentralWidget(self.main_dock) def setShortcuts(self): self.autoScaleAction = QAction(QIcon(), '&Autoscale', self) self.autoScaleAction.setShortcut("Ctrl+W") self.autoScaleAction.triggered.connect(self.plotWidget.autoScale) # print "initiating shortcuts" #------ def setupMainWidget(self) : self.main_dock = QDockWidget(_('')) self.addDockWidget(Qt.BottomDockWidgetArea, self.main_dock) self.dockTab = QTabWidget() dockSplitter = QSplitter() dockSplitter.setOrientation(Qt.Vertical) #----- toolbar = self.addToolBar("Curve") self.plotWidget = CentralWidget(self, toolbar) # Set central widget: self.dockTab.addTab(self.plotWidget, "Plot") #----- self.statusEdit = QTextEdit() self.statusEdit.setText("Status updates to go here.") self.statusEdit.setEnabled(False) self.statusEdit.moveCursor(QTextCursor.End) #----- self.testButton = QPushButton("Test Button") self.testButton.clicked.connect(self.__testClick__) dockSplitter.addWidget(self.testButton) dockSplitter.addWidget(self.statusEdit) self.dockTab.addTab(dockSplitter, "Status Info") if DockableConsole is None: self.console = None else: import time, scipy.signal as sps, scipy.ndimage as spi import sys, os import numpy as np ns = {'np': np, 'sps': sps, 'spi': spi, 'os': os, 'sys': sys, 'time': time} msg = "Example: np.arange(20)\n"\ "Modules imported at startup: "\ "os, sys, os.path as osp, time, "\ "numpy as np, scipy.signal as sps, scipy.ndimage as spi" self.console = DockableConsole(self, namespace=ns, message=msg) # console_dock = QDockWidget(_('Console')) # self.addDockWidget(Qt.BottomDockWidgetArea, console_dock) # console_dock.setWidget(self.console) self.dockTab.addTab(self.console, "Console") # dockSplitter.addWidget(self.console) # main_dock.setWidget(dockSplitter) self.main_dock.setWidget(self.dockTab) #------ def __testClick__(self): # self.statusEdit.append("Clicked") self.dataList = self.rdb.lrange('activeData', 0, -1) if self.curFIFOVal>20: self.curFIFOVal = 0 dataID = self.dataList[self.curFIFOVal] # metaDict, raw = WR.processDataJson(self.rdb, dataID) # metaDict, raw = WR.processData(self.rdb, dataID) metaDict, raw = WR.processDataSegmented(self.rdb, dataID) xVals = np.arange(len(raw)) self.curFIFOVal+=1 self.statusEdit.append(str(raw[0:5])) self.plotWidget.add_curve(dataID, xVals, raw) #------? def about(self): QMessageBox.about( self, _("About ")+APP_NAME, """<b>%s</b> v%s<p>%s Brian H. Clowers <br> <br>Copyright © 2016 <p>Python %s, Qt %s, PyQt %s %s %s""" % \ (APP_NAME, VERSION, _("Developped by"), platform.python_version(), QT_VERSION_STR, PYQT_VERSION_STR, _("on"), platform.system()) ) #------I/O def new_image(self): """Create a new image""" imagenew = ImageParamNew(title=_("Create a new image")) if not imagenew.edit(self): return image = ImageParam() image.title = imagenew.title if imagenew.type == 'zeros': image.data = np.zeros((imagenew.width, imagenew.height)) elif imagenew.type == 'rand': image.data = np.random.randn(imagenew.width, imagenew.height) self.mainwidget.add_image(image) def open_image(self): """Open image file""" saved_in, saved_out, saved_err = sys.stdin, sys.stdout, sys.stderr sys.stdout = None filename, _filter = getopenfilename(self, _("Open"), "", io.iohandler.get_filters('load')) sys.stdin, sys.stdout, sys.stderr = saved_in, saved_out, saved_err if filename: self.mainwidget.add_image_from_file(filename)