예제 #1
0
 def __init__(self, item, parent_layout):
     super(TabGroupWidget, self).__init__(item, parent_layout)
     self.tabs = QTabWidget()
     items = item.item.group
     self.widgets = []
     for item in items:
         if item.get_prop_value("display", parent_layout.instance,
                                "hide", False):
             continue
         item.set_prop("display", embedded=True)
         widget = parent_layout.build_widget(item)
         frame = QFrame()
         label = widget.item.get_prop_value("display", "label")
         icon = widget.item.get_prop_value("display", "icon", None)
         if icon is not None:
             self.tabs.addTab(frame, get_icon(icon), label)
         else:
             self.tabs.addTab(frame, label)
         layout = QGridLayout()
         layout.setAlignment(Qt.AlignTop)
         frame.setLayout(layout)
         widget.place_on_grid(layout, 0, 0, 1)
         try:
             widget.get()
         except Exception:
             print("Error building item :", item.item._name)
             raise
         self.widgets.append(widget)
예제 #2
0
class TabGroupWidget(AbstractDataSetWidget):
    def __init__(self, item, parent_layout):
        super(TabGroupWidget, self).__init__(item, parent_layout)
        self.tabs = QTabWidget()
        items = item.item.group
        self.widgets = []
        for item in items:
            if item.get_prop_value("display", parent_layout.instance, "hide",
                                   False):
                continue
            item.set_prop("display", embedded=True)
            widget = parent_layout.build_widget(item)
            frame = QFrame()
            label = widget.item.get_prop_value("display", "label")
            icon = widget.item.get_prop_value("display", "icon", None)
            if icon is not None:
                self.tabs.addTab(frame, get_icon(icon), label)
            else:
                self.tabs.addTab(frame, label)
            layout = QGridLayout()
            layout.setAlignment(Qt.AlignTop)
            frame.setLayout(layout)
            widget.place_on_grid(layout, 0, 0, 1)
            try:
                widget.get()
            except Exception:
                print("Error building item :", item.item._name)
                raise
            self.widgets.append(widget)

    def get(self):
        """Override AbstractDataSetWidget method"""
        for widget in self.widgets:
            widget.get()

    def set(self):
        """Override AbstractDataSetWidget method"""
        for widget in self.widgets:
            widget.set()

    def check(self):
        """Override AbstractDataSetWidget method"""
        return True

    def place_on_grid(self,
                      layout,
                      row,
                      label_column,
                      widget_column,
                      row_span=1,
                      column_span=1):
        """Override AbstractDataSetWidget method"""
        layout.addWidget(self.tabs, row, label_column, row_span,
                         column_span + 1)
예제 #3
0
 def __init__(self,
              parent,
              spec=[],
              autoX=lambda: False,
              autoY=lambda: False):
     QTabWidget.__init__(self)
     self.parent = parent
     self.autoX = autoX
     self.autoY = autoY
     self.sp = []
     self.spec = spec
     self.setTabs(self.spec)
예제 #4
0
class TabGroupWidget(AbstractDataSetWidget):
    def __init__(self, item, parent_layout):
        super(TabGroupWidget, self).__init__(item, parent_layout)
        self.tabs = QTabWidget()
        items = item.item.group
        self.widgets = []
        for item in items:
            if item.get_prop_value("display", parent_layout.instance,
                                   "hide", False):
                continue
            item.set_prop("display", embedded=True)
            widget = parent_layout.build_widget(item)
            frame = QFrame()
            label = widget.item.get_prop_value("display", "label")
            icon = widget.item.get_prop_value("display", "icon", None)
            if icon is not None:
                self.tabs.addTab(frame, get_icon(icon), label)
            else:
                self.tabs.addTab(frame, label)
            layout = QGridLayout()
            layout.setAlignment(Qt.AlignTop)
            frame.setLayout(layout)
            widget.place_on_grid(layout, 0, 0, 1)
            try:
                widget.get()
            except Exception:
                print("Error building item :", item.item._name)
                raise
            self.widgets.append(widget)

    def get(self):
        """Override AbstractDataSetWidget method"""
        for widget in self.widgets:
            widget.get()
    
    def set(self):
        """Override AbstractDataSetWidget method"""
        for widget in self.widgets:
            widget.set()
        
    def check(self):
        """Override AbstractDataSetWidget method"""
        return True

    def place_on_grid(self, layout, row, label_column, widget_column,
                      row_span=1, column_span=1):
        """Override AbstractDataSetWidget method"""
        layout.addWidget(self.tabs, row, label_column, row_span, column_span+1)
예제 #5
0
    def __init__(self, parent, toolbar):
        QSplitter.__init__(self, parent)
        # QTabWidget.__init__(self, parent)
        self.setContentsMargins(10, 10, 10, 10)
        self.setOrientation(Qt.Vertical)

        linelistwithproperties = LineListWithProperties(self)
        # self.addWidget(linelistwithproperties)
        self.lineList = linelistwithproperties.lineList
        self.connect(self.lineList, SIGNAL("currentRowChanged(int)"),
                     self.current_item_changed)
        self.connect(self.lineList, SIGNAL("itemSelectionChanged()"),
                     self.selection_changed)
        self.curveProperties = linelistwithproperties.properties
        self.connect(self.curveProperties, SIGNAL("apply_button_clicked()"),
                     self.curve_properties_changed)
        
        self.curvewidget = CurveWidget(self)
        self.curvewidget.register_all_curve_tools()
        self.curve_item = make.curve([], [], color='b')
        self.peak_item = make.curve([],[], markerfacecolor = 'r', marker = 'o', curvestyle="NoCurve")#, alpha = 0.75)
        self.curvewidget.plot.add_item(self.curve_item)
        self.curvewidget.plot.add_item(self.peak_item)
        self.curvewidget.plot.set_antialiasing(True)
        self.addWidget(self.curvewidget)
        
        self.lines = [] # List of ImageParam instances
        self.peaks = []

        
        vSplitter = QSplitter()
        vSplitter.setOrientation(Qt.Vertical)
        daqParamProperties = DAQParamsProperties(self)
        self.daqProperties = daqParamProperties.properties
        self.connect(self.daqProperties, SIGNAL("apply_button_clicked()"), self.daq_properties_changed)
        # daqButton = QPushButton("Upload DAQ Params")
        vSplitter.addWidget(daqParamProperties)
        # vSplitter.addWidget(daqButton)
        tabWidget = QTabWidget()
        tab1 = tabWidget.addTab(linelistwithproperties, "Curve Params")
        tab2 = tabWidget.addTab(vSplitter, "DAQ Params")
        
        self.addWidget(tabWidget)

        self.setStretchFactor(0, 0)
        self.setStretchFactor(1, 1)
        self.setHandleWidth(10)
        self.setSizes([1, 2])
예제 #6
0
    def _generateFrame(self):
        '''
        Return the frame containing the presentation, check if the frame was created, otherwise it is created
        :return:
        '''
        # generate the frame if necessary
        if self._frame is None:
            # Generate frame and define the layout based on the frame
            self._frame = QFrame(self._parentFrame)
            _layout = QVBoxLayout()
            self._frame.setLayout(_layout)

            # Add the "Main" group box for this view, if present. It is rendered in foreground
            if self._generateGroupBox() is not None:
                _layout.addWidget(self._groupbox)
            else:
                self._frame.setFrameStyle(QFrame.Panel|QFrame.Raised)
                self._frame.setLineWidth(1)

            # Add to layout eventually the other subview
            if self._viewtype == 'Tabs':
                _tabs = QTabWidget()
                _layout.addWidget(_tabs)
            elif self._viewtype == 'Splitter':
                _splitter =QSplitter()
                _layout.addWidget(_splitter)
            else:
                _sub_frame = QFrame()
                _sub_frame_layout = QHBoxLayout()
                _sub_frame.setLayout(_sub_frame_layout)
                _layout.addWidget(_sub_frame)

            # Add all the sub view as sub frames in the layout
            for sw in self._subViewDictionary.values():
                sw.setParentView(self._frame)
                if self._viewtype == 'Tabs':
                    _tabs.addTab(sw.getFrame(), sw.viewname)
                elif self._viewtype == 'Splitter':
                    _splitter.addWidget(sw.getFrame())
                else:
                    _sub_frame_layout.addWidget(sw.getFrame())

        return self._frame
예제 #7
0
    def setup_instance(self, instance):
        """Override DataSetEditDialog method"""
        from guidata.dataset.datatypes import DataSetGroup
        assert isinstance(instance, DataSetGroup)
        tabs = QTabWidget()
#        tabs.setUsesScrollButtons(False)
        self.layout.addWidget(tabs)
        for dataset in instance.datasets:
            layout = QVBoxLayout()
            layout.setAlignment(Qt.AlignTop)
            if dataset.get_comment():
                label = QLabel(dataset.get_comment())
                label.setWordWrap(self.wordwrap)
                layout.addWidget(label)
            grid = QGridLayout()
            self.edit_layout.append( self.layout_factory(dataset, grid) )
            layout.addLayout(grid)
            page = QWidget()
            page.setLayout(layout)
            if dataset.get_icon():
                tabs.addTab( page, get_icon(dataset.get_icon()),
                             dataset.get_title() )
            else:
                tabs.addTab( page, dataset.get_title() )
예제 #8
0
    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)
예제 #9
0
파일: qtwidgets.py 프로젝트: gyenney/Tools
    def setup_instance(self, instance):
        """Override DataSetEditDialog method"""
        from guidata.dataset.datatypes import DataSetGroup
        assert isinstance(instance, DataSetGroup)
        tabs = QTabWidget()
#        tabs.setUsesScrollButtons(False)
        self.layout.addWidget(tabs)
        for dataset in instance.datasets:
            layout = QVBoxLayout()
            layout.setAlignment(Qt.AlignTop)
            if dataset.get_comment():
                label = QLabel(dataset.get_comment())
                label.setWordWrap(self.wordwrap)
                layout.addWidget(label)
            grid = QGridLayout()
            self.edit_layout.append( self.layout_factory(dataset, grid) )
            layout.addLayout(grid)
            page = QWidget()
            page.setLayout(layout)
            if dataset.get_icon():
                tabs.addTab( page, get_icon(dataset.get_icon()),
                             dataset.get_title() )
            else:
                tabs.addTab( page, dataset.get_title() )
예제 #10
0
파일: FTIR.py 프로젝트: BenMoon/LabSoft
 def __init__(self, parent):
     if PYQT5:
         super(DockableTabWidget, self).__init__(parent, parent=parent)
     else:
         QTabWidget.__init__(self, parent)
         DockableWidgetMixin.__init__(self, parent)
예제 #11
0
파일: base.py 프로젝트: mindw/guiqwt
 def __init__(self, parent, options=None):
     QTabWidget.__init__(self, parent)
     self.options = options
     self.output_arrays = None
예제 #12
0
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 &copy; 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)
예제 #13
0
파일: _gui_tmp.py 프로젝트: BD75/mpsrad
 def __init__(self, parent, spec_names):
     QTabWidget.__init__(self)
     self.parent = parent
     self.setTabs(spec_names)