Exemplo n.º 1
0
    def drawPanel(self):
        frame = sqt.frame(self)
        self.c = sqt.combobox(self)
        self.c.addItems(['keywords', 'builtins', 'comments', 'strings'])
        self.color = colorpicker()
        self.set = sqt.button(frame, 'set color!')
        self.set.bindClicked(self.setcolor)
        self.c.bindChanged(self.textChanged)
        self.datastore = {}
        self.getSettings()
        self.color.setNamedColor(self.datastore['keywords'])
        frame.position(
            [[sqt.label(self, 'Select and set python editor colors:')],
             [self.c], [self.color], [self.set]])
        d = conf.DataStorage()
        prompt = sqt.frame(self)
        p = conf.check(self.config, ['CONSOLE', 'prompt'], '>>>: ')

        pp = conf.check(self.config, ['EDITOR', 'runname'], '^f')
        limit = int(conf.check(self.config, ['CONSOLE', 'history'], '100'))
        self.spin = QSpinBox(self)
        self.spin.setMaximum(500)
        self.spin.setMinimum(20)  # change back to 20
        self.spin.setValue(limit)
        self.promptentry = QLineEdit(p)
        self.runname = QLineEdit(pp)
        prompt.position([
            [sqt.label(self, 'Enter Prompt for Python Console')],
            [self.promptentry],
            [
                sqt.label(
                    self,
                    'Enter format of file name shown in <br> Python Editor errors:<br>use ^f as the filename'
                )
            ], [self.runname],
            [sqt.label(self, 'Enter maximum amount of history.')], [self.spin]
        ])
        loros = self.config.get('RunOnStartup', [])
        self.rosbox = PrefBox(self, paths=loros, dirmode=False)

        ff = sqt.frame(self)
        fonte = conf.check(self.config, ['EDITOR', 'font'], 'Courier')
        fontc = conf.check(self.config, ['CONSOLE', 'font'], 'Courier')

        self.fstore = {'editor-font': fonte, 'console-font': fontc}
        b1 = QPushButton('Select Font')
        b2 = QPushButton('Select Font')
        b1.clicked.connect(self.setFont1)
        b2.clicked.connect(self.setFont2)

        ff.position([[sqt.label(ff, 'Select font for editor:'), b1],
                     [sqt.label(ff, 'Select font for console'), b2]])
        d['color'] = frame
        d['console'] = prompt
        d['font'] = ff
        d['Run On Startup'] = self.rosbox
        self.setupTabs(d)
Exemplo n.º 2
0
    def drawPanel(self, *args):
        print(args)
        if not args:

            self.conf = self.API.conf
        else:
            try:
                self.conf = {}
                for i in args:
                    self.conf[i] = self.API.conf[i]
            except Exception as ec:
                w = sqt.frame(self)
                w.position([[
                    sqt.label(
                        self,
                        '<font color=#ff0000>Error in config %s - \n %s:\n %s</font>'
                        % (i, ec.__class__.__name__, ec))
                ]])
                w.onSave = lambda: None
                self.conf = {'error': w}
        self.tabs = QTabWidget()
        #self.tabs.show()
        self.button = QPushButton('Save')
        self.button.clicked.connect(self.save)
        l = QVBoxLayout(self)
        l.addWidget(self.button)
        l.addWidget(self.tabs)

        self.widgets = {}
        for i in self.conf.keys():
            try:
                w = self.conf[i](self.API)
            except Exception as ec:
                w = sqt.frame(self)
                w.position([[
                    sqt.label(
                        self,
                        '<font color=#ff0000>Error in config %s - \n %s:\n %s</font>'
                        % (i, ec.__class__.__name__, ec))
                ]])
                w.onSave = lambda: None

            print(i)
            print(w)
            print(self.conf[i])
            #w.show()
            self.tabs.addTab(w, i)
            #self.tabs.addTab(w,i)
            self.widgets[i] = w

        self.setLayout(l)
Exemplo n.º 3
0
    def addWidgets(self, widgets):
        frame = sqt.frame(self.parent)
        toadd = []

        for i in widgets:
            w = i.create()
            self.widgets.append(w)
            toadd.append([sqt.label(frame, i.name), w])

        frame.position(toadd)
        return frame
Exemplo n.º 4
0
 def __init__(self, parent, paths=[], dirmode=True):
     self.selected = None
     super(PrefBox, self).__init__(parent)
     self.fnameline = fileBrowseLine(self, dirmode=dirmode)
     mainframe = sqt.frame(self)
     self.listbox = QListWidget(self)
     self.listbox.addItems(paths)
     self.connect(self.listbox,
                  SIGNAL('currentTextChanged (const QString&)'),
                  self.setSelected)
     buttonframe = sqt.frame(self)
     a = sqt.button(buttonframe, 'Add [a]')
     a.setShortcut('a')
     d = sqt.button(buttonframe, 'Delete [d]')
     d.setShortcut('d')
     #b = sqt.button(buttonframe,'Add')
     d.bindClicked(self.delete)
     a.bindClicked(self.add)
     buttonframe.position([[a], [d]])
     mainframe.position([[self.listbox, buttonframe]])
     self.position([[self.fnameline], [mainframe]])
Exemplo n.º 5
0
    def drawPanel(self):
        #super(PlugConsole).__init__(api)
        self.isSaveable = True
        welcome_message = '''
        This is ScopePy's Triangledot Python
        Interpreter. 
        
        To use ScopePy's Python Interface, use 
        Global Variables <API> <panel> <console> and <editor>
        For controling this panel.
        Type viewHelp(object) for graphical help
        '''
        self.stack = QStackedWidget()
        l = QVBoxLayout()
        l.addWidget(self.stack)
        w = QWidget()
        self.config = conf.load('PyEditor')
        if self.config == None:
            prompt = ">>>: "
        else:
            prompt = self.config['CONSOLE']['prompt'] + ' '
        globals()['API'] = self.API
        self.console = Console(prompt=prompt, startup_message=welcome_message)
        self.editor = PyEditor(self.console, self)
        ##        layout = QtGui.QVBoxLayout(self)
        ##        layout.addWidget(self.console)
        ##        layout.addWidget(self.editor)
        ##        w.setLayout(layout)
        #self.browser = Browser()
        lab = QLabel('')

        ef = sqt.frame(self)
        ef.position([[self.console], [lab], [self.editor]])
        self.editor.setWindowTitle = lab.setText
        self.position([[ef]])
        self.console.API = self.API
        self.console._locals["API"] = lockClass(self.API)
        self.console._locals["console"] = self.console
        self.console._locals["panel"] = self
        self.console._locals["editor"] = self.editor
        self.console._locals["viewHelp"] = self.help
        from pprint import pprint
        self.console._locals["pprint"] = pprint
        globals()['pprint'] = pprint

        self.setLayout(l)
        self.wd = {'main': w}
        self.stack.addWidget(w)
Exemplo n.º 6
0
    def drawPanel(self):
        #        try:
        #            ros = cl.passCss(os.join(os.path.expanduser('~'),'.ScopePy','openatstart.css'))
        #            nos = True
        #
        #        except:
        #            nos = False
        #
        #        if nos:
        #            rd = ros['scripts']
        #            for i in rd:
        #                try:
        #                    exec(open(i,'r').read(),globals(),{'API':self.API})
        #                except Exception as ex:
        #                    print('Error: %s' % ex)
        #
        self.addCommsAction('addScript', self.add)

        mainframe = sqt.frame(self)
        label1 = sqt.label(
            mainframe,
            '<h3><b> The Runner that runs python scripts:<br> A:add|R:Run|P:Run With Python Editor</b></h3>'
        )
        label = sqt.label(mainframe, 'Select script to run with Alt+&3')
        run = sqt.button(mainframe, 'Run!')
        add = sqt.button(mainframe, 'Add!')
        pyedit = sqt.button(mainframe, 'Run With Python Editor!')
        self.c = sqt.combobox(mainframe)
        self.c.widget.setMaximumWidth(250)
        self.c.widget.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
        css = self.getcss()
        if css != None:
            for i in css:
                self.c.addItem(i)
        run.bindClicked(self.run)
        pyedit.bindClicked(self.pyeditRun)
        run.widget.setShortcut(QKeySequence("R"))
        pyedit.widget.setShortcut(QKeySequence("P"))
        add.widget.setShortcut(QKeySequence("A"))
        add.bindClicked(self.adder)
        label.widget.setBuddy(self.c.widget)
        mainframe.position([[label1, sqt.empty()], [label, sqt.empty()],
                            [self.c, run], [sqt.empty(), add],
                            [sqt.empty(), pyedit]])
        self.position([[mainframe], [sqt.empty()], [sqt.empty()],
                       [sqt.empty()]])
Exemplo n.º 7
0
    def drawPanel(self):
        frame = sqt.frame(self)
        label = sqt.label(self, 'Turn Loging on Log on/off')
        self.slide = sqt.QSlider(sqt.Qt.Horizontal, self)
        self.slide.setMinimum(0)
        self.th = 0
        self.slide.setMaximum(1)
        if self.API._gui.onLog == True:
            self.slide.setValue(1)
        else:
            self.slide.setValue(0)
        self.connect(self.slide, sqt.SIGNAL("valueChanged(int)"),
                     self.setcolor)

        frame.position([[label], [self.slide]])

        a = DataStorage()
        a['Where'] = frame
        self.setupTabs(a)
Exemplo n.º 8
0
    def drawPanel(self):
        """
        Draw the GUI elements of the panel
        
        This is a Mandatory function. It will be called by ScopePy when
        the panel is added to a tab.
        
        """

        # ********************************************************
        #               Channel selector Layout
        # ********************************************************
        # TODO channel editor might need to be another panel

        # Channel operations buttons
        #=================================
        channelSelectorWidget = QWidget()
        channelSelectorWidget.setMaximumSize(QSize(275, 455))
        channelSelectorWidget.setMinimumSize(QSize(240, 300))
        channelSelectorWidget.setSizePolicy(QSizePolicy.Preferred,
                                            QSizePolicy.Preferred)

        addChannelButton = QPushButton("Add &Channel to plot  -->")

        removeChannelButton = QPushButton("Remo&ve Channel from plot  <--")
        newChannelButton = QPushButton("New Channel")
        editChannelButton = QPushButton("Edit Channel")
        deleteChannelButton = QPushButton("Delete Channel")
        addMathChannelButton = QPushButton("Add &Math Channel ...")
        dumpChannelButton = QPushButton("Dump Channel")

        selectAllChannelsButton = QPushButton("Select &All")
        unSelectAllChannelsButton = QPushButton("&Unselect All")

        # Connections
        # TODO : check over. Some of these may need to be implemented here
        self.connect(addChannelButton, SIGNAL("clicked()"),
                     self.API.addChannel2Panel)
        self.connect(addMathChannelButton, SIGNAL("clicked()"),
                     self.addMathChannel)
        self.connect(removeChannelButton, SIGNAL("clicked()"),
                     self.API.removeChannelFromPlot)
        self.connect(newChannelButton, SIGNAL("clicked()"),
                     self.createNewChannel)
        self.connect(editChannelButton, SIGNAL("clicked()"),
                     self.editChannel)  # ???
        self.connect(deleteChannelButton, SIGNAL("clicked()"),
                     self.deleteChannel)
        self.connect(selectAllChannelsButton, SIGNAL("clicked()"),
                     self.selectAllChannels)
        self.connect(unSelectAllChannelsButton, SIGNAL("clicked()"),
                     self.unSelectAllChannels)
        self.connect(dumpChannelButton, SIGNAL("clicked()"), self.dumpChannel)

        # Options for displaying channels
        # -------------------------------------

        # Tree model setup
        self.channelTreeModel = ch.ChannelTreeModel(
            self.API.dataStore.channel_dict)

        # Tree - more info
        self.channelTree = QTreeView()  #QTreeWidget()
        self.channelTree.setSelectionMode(QAbstractItemView.ExtendedSelection)
        self.channelTree.setSelectionBehavior(QTreeView.SelectItems)
        self.channelTree.setItemsExpandable(True)
        self.channelTree.setSizePolicy(
            QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding))
        self.channelTree.header().setStretchLastSection(False)
        self.channelTree.header().setResizeMode(QHeaderView.Stretch)

        # Model version setup
        self.channelTree.setModel(self.channelTreeModel)
        self.channelTreeDelegate = ch.channelTreeDelegate(self)
        self.channelTree.setItemDelegate(self.channelTreeDelegate)

        # labels
        # ====================
        channelSelectorTitle = QLabel("<h2><b>Channel Selector</b></h2>")
        #channelSelectorTitle.setBuddy(addChannelButton)
        channelListTitle = QLabel("Channel &List")
        #channelListTitle.setBuddy(self.channelList)
        channelListTitle.setBuddy(self.channelTree)

        # Layout
        # ============

        # Button frame
        buttonFrame = sqt.frame(self)

        buttonFrame.position([[newChannelButton, addChannelButton],
                              [editChannelButton, removeChannelButton],
                              [deleteChannelButton, addMathChannelButton],
                              [dumpChannelButton,
                               sqt.empty()]])

        #        channelSelectorLayout.addWidget(newChannelButton)
        #        channelSelectorLayout.addWidget(editChannelButton)
        #        channelSelectorLayout.addWidget(addChannelButton)
        #        channelSelectorLayout.addWidget(removeChannelButton)
        #        channelSelectorLayout.addWidget(deleteChannelButton)
        #        channelSelectorLayout.addWidget(addMathChannelButton)
        #        channelSelectorLayout.addWidget(dumpChannelButton)

        channelSelectorLayout = QVBoxLayout()
        channelSelectorLayout.addWidget(channelSelectorTitle)
        channelSelectorLayout.addWidget(buttonFrame)
        channelSelectorLayout.addWidget(channelListTitle)
        channelSelectorLayout.addWidget(self.channelTree)

        # Select/un select buttons
        channelSelectUnSelectLayout = QHBoxLayout()
        channelSelectUnSelectLayout.addWidget(selectAllChannelsButton)
        channelSelectUnSelectLayout.addWidget(unSelectAllChannelsButton)

        channelSelectorLayout.addLayout(channelSelectUnSelectLayout)

        #
        channelSelectorWidget.setLayout(channelSelectorLayout)

        # Channel editing layout
        # =============================
        channelEditWidget = QWidget()

        channelEditAddButton = QPushButton("Add Channel")
        channelEditCancelButton = QPushButton("Cancel")

        # Button connections
        self.connect(channelEditAddButton, SIGNAL("clicked()"),
                     self.channelEditAdd)
        self.connect(channelEditCancelButton, SIGNAL("clicked()"),
                     self.channelEditCancel)

        channelEditButtonLayout = QHBoxLayout()
        channelEditButtonLayout.addWidget(channelEditAddButton)
        channelEditButtonLayout.addWidget(channelEditCancelButton)

        # Channel name box
        channelEditLabel = QLabel("Channel Name")
        self.channelEditNameEntry = QLineEdit()

        # editing table
        self.channelEditTable = QTableWidget()
        self.channelEditTable.clear()
        self.channelEditTable.setSortingEnabled(False)
        self.channelEditTable.setRowCount(10)
        headers = ["x values", "y value"]
        self.channelEditTable.setColumnCount(len(headers))
        self.channelEditTable.setHorizontalHeaderLabels(headers)

        # Channel Edit layout
        channelEditLayout = QVBoxLayout()
        channelEditLayout.addWidget(channelEditLabel)
        channelEditLayout.addWidget(self.channelEditNameEntry)
        channelEditLayout.addWidget(self.channelEditTable)
        channelEditLayout.addLayout(channelEditButtonLayout)

        channelEditWidget.setLayout(channelEditLayout)

        # Channel crafter
        # ===========================================

        # Variables
        # --------------
        self.craftXdata = None
        self.craftYdata = None
        self.craftXname = None
        self.craftYname = None
        self.craftXsource = None
        self.craftYsource = None

        # Widgets
        # ------------
        self.channelName_txtEd = QLineEdit("New channel")
        channelNameLabel = QLabel("Chann&el name")
        channelNameLabel.setBuddy(self.channelName_txtEd)
        self.xdata_txtEd = QLineEdit("x data")
        self.ydata_txtEd = QLineEdit("y data")
        self.xdata_source = QLabel('x data source')
        self.ydata_source = QLabel('y data source')

        # Buttons
        # ----------
        switchXY_button = QPushButton("Switch X & Y")
        self.makeChannel_button = QPushButton("Ma&ke Channel")
        #self.makeChannel_button.setDisabled(True)

        # Connections
        self.connect(switchXY_button, SIGNAL("clicked()"), self.switchXY)
        self.connect(self.makeChannel_button, SIGNAL("clicked()"),
                     self.makeChannel)

        # Channel crafter layout
        # ----------------------
        craftFrame = QFrame()
        craftFrame.setFrameStyle(QFrame.Panel | QFrame.Raised)
        craftFrame.setLineWidth(3)

        craftLayout = QGridLayout()

        craftLayout.addWidget(QLabel("<h2><b>Channel Crafter</b></h2>"), 0, 1)

        craftLayout.addWidget(channelNameLabel, 1, 1)
        craftLayout.addWidget(self.channelName_txtEd, 1, 2)

        craftLayout.addWidget(QLabel("<b><em>source</em></b>"), 2, 1)
        craftLayout.addWidget(QLabel("<b><em>data</em></b>"), 2, 2)

        craftLayout.addWidget(QLabel("<b><em>x axis</em></b>"), 3, 0)
        craftLayout.addWidget(self.xdata_source, 3, 1)
        craftLayout.addWidget(self.xdata_txtEd, 3, 2)

        craftLayout.addWidget(QLabel("<b><em>y axis</em></b>"), 4, 0)
        craftLayout.addWidget(self.ydata_source, 4, 1)
        craftLayout.addWidget(self.ydata_txtEd, 4, 2)

        craftLayout.addWidget(switchXY_button, 5, 1)
        craftLayout.addWidget(self.makeChannel_button, 5, 2)

        craftFrame.setLayout(craftLayout)
        channelSelectorLayout.addWidget(craftFrame)

        # Add layout to master widget [Mandatory]
        # ========================================
        # mandatory
        self.setLayout(channelSelectorLayout)

        # Add toolbar button for test channels
        # =====================================
        testChannelsAction = self.API.createAction(
            "T&est channels",
            self.makeTestChannel,
            icon=QIcon.fromTheme("system-run"),
            tip="Create test channels for debugging")

        self.API.toolbar_manager.addButton('top', [testChannelsAction])

        # Setup signals to external sources
        # ====================================
        self.connect(self.API, SIGNAL("channel_added"),
                     self.updateChannelTreeModel)
        self.connect(self.API, SIGNAL("update_channel_selector"),
                     self.updateChannelSelector)

        # Add SignalComms actions
        # ============================
        self.addCommsAction('addXdata', self.addXdata)
        self.addCommsAction('addYdata', self.addYdata)
        self.addCommsAction('deleteAllChannels', self.deleteAllChannels)
Exemplo n.º 9
0
    def drawPanel(self):
        """
        Set the layout for the PlotScreen
        
        Plot + chunk selector
        
        """

        # Set this panel to be save-able in a session file
        # ======================================================
        # must implement the saveData() and restoreData() functions
        self.isSaveable = True

        # Widgets
        # ====================
        topBox = sqt.frame(self)
        topBoxSizePolicy = QSizePolicy(QSizePolicy.Preferred,
                                       QSizePolicy.Fixed)
        topBoxSizePolicy.horizontalStretch = 1
        topBoxSizePolicy.verticalStretch = 1
        topBox.setSizePolicy(topBoxSizePolicy)

        self.addChannelList = sqt.combobox(topBox)
        addChannelLabel = QLabel("Add Cha&nnel")
        addChannelLabel.setBuddy(self.addChannelList.widget)
        self.addChannelButton = QPushButton("Add [A]")
        self.addChannelButton.setShortcut(QKeySequence('A'))

        self.deleteChannelList = sqt.combobox(topBox)
        deleteChannelLabel = QLabel("Dele&te Channel")
        deleteChannelLabel.setBuddy(self.deleteChannelList.widget)
        self.deleteChannelButton = QPushButton("Delete [D]")
        self.deleteChannelButton.setShortcut(QKeySequence('D'))

        self.plot = graphs.GraphWidget(self.preferences)
        plotSizePolicy = QSizePolicy(QSizePolicy.Preferred,
                                     QSizePolicy.Preferred)
        plotSizePolicy.horizontalStretch = 3
        plotSizePolicy.verticalStretch = 3
        self.plot.setSizePolicy(plotSizePolicy)
        self.plot.setStyleSheet(self.API.getDefaultPlotThemeCss())

        self.chunkToolbar = self.chunkSelector()

        self.plot_theme = sqt.combobox(topBox)
        plot_themes = [
            self.API.plot_themes[key]['name']
            for key in self.API.plot_themes.keys()
        ]
        plot_themes.sort()
        self.plot_theme.addItems(plot_themes)
        self.plot_theme.bindChanged(self.localThemeChanged)
        themeLabel = QLabel('Set Theme')

        # Set default theme
        default_theme = self.API.getDefaultPlotThemeName()
        self.plot_theme.currentText = default_theme
        #themeLabel.setBuddy(self.plot_theme)

        # Layout
        # =================

        topBox.position([[
            addChannelLabel, self.addChannelList, self.addChannelButton,
            themeLabel
        ],
                         [
                             deleteChannelLabel, self.deleteChannelList,
                             self.deleteChannelButton, self.plot_theme
                         ]])

        cc = {
            'addChannel': self.addChannel,
            'autoscale': self.autowrapper,
            'channelsOnPlot': self.channelsOnPlot,
            'dumpChannelData': self.dumpChannelData,
            'setTheme': self.setTheme,
            'addHorizMarker': lambda a: self.addHorizMarker(),
            'addVertMarker': lambda a: self.addVertMarker(),
            'updatePlot': lambda a: self.updatePlots()
        }

        self.console = sqt.MiniConsole(commands=cc)
        layout = QVBoxLayout()
        layout.addWidget(topBox)
        layout.addWidget(self.plot)
        layout.addWidget(self.chunkToolbar)
        layout.addWidget(self.console)

        self.setLayout(layout)

        # Connections
        # =====================
        self.connect(self.addChannelButton, SIGNAL("clicked()"),
                     self.addChannelFromButton)
        self.connect(self.deleteChannelButton, SIGNAL("clicked()"),
                     self.deleteChannelFromButton)

        # Comms connections
        # ======================
        self.addCommsAction('addChannel', self.addChannel)
        self.addCommsAction('deleteChannel', self.deleteChannel)

        # Initialisation
        # =========================
        self.updateChannelList()
Exemplo n.º 10
0
    def drawPanel(self):
        """
        Draw the GUI elements of the panel
        
        This is a Mandatory function. It will be called by ScopePy when
        the panel is added to a tab.
        
        """

        # Panel layout code goes here
        # =============================

        # Panel widgets
        # ================================

        # Make the channels for holding the data
        # -------------------------------------------

        channel_colours = {
            'ADC0': "#0489B1",
            'ADC1': '#DF7401',
            'ADC2': "#0489B1",
            'ADC3': '#DF7401'
        }

        self.adc_channels = {}

        for ch in channel_colours:
            linestyle = plotLineStyle(lineColour=channel_colours[ch],
                                      marker='o',
                                      markerSize=2)
            self.adc_channels[ch] = ScopePyChannel(ch, linestyle)
            self.adc_channels[ch].rollover = ROLLOVER

        # Graph display
        # -----------------

        self.graph_x = GraphWidget(self.preferences)
        #self.graph_x.horiz_size = 700
        self.graph_x.xlabel = 'Sample'
        self.graph_x.ylabel = 'ADC Count [LSB]'
        self.graph_x.xmin = 0
        self.graph_x.xmax = ROLLOVER
        self.graph_x.ymin = 0.0
        self.graph_x.ymax = 32.0

        for channel in self.adc_channels:
            self.graph_x.addChannel(self.adc_channels[channel],
                                    chunkMode='rollover')

        # Buttons
        # ------------
        # Run/Stop
        # Single shot
        # clear
        # IP address (Text edit)
        # Connect

        # Run/Stop button
        self.button_run_stop = sqt.ToggleButton(self, "Run")
        self.button_run_stop.setButtonTextForState('Stop', True)
        self.button_run_stop.setButtonTextForState('Run', False)
        self.button_run_stop.bindStateChanged(self.run_stop)

        # Single shot button
        self.button_single_shot = sqt.button(self, 'Single shot')
        self.button_single_shot.bindClicked(self.single_shot)

        # clear button
        self.button_clear = sqt.button(self, 'Clear')
        self.button_clear.bindClicked(self.clear)

        # Connect button
        self.button_connect = sqt.button(self, 'Connect')
        self.button_connect.bindClicked(self.connect_card)

        # IP address
        IP_label = QLabel('IP Address')
        self.IP_address_text = sqt.entry(self)
        self.IP_address_text.setText(DEFAULT_IP_ADDRESS)
        self.IP_address_text.widget.setMaxLength(15)
        self.IP_address_text.widget.setMinimumWidth(self.API.charWidth_px * 20)
        self.IP_address_text.widget.setSizePolicy(QSizePolicy.Fixed,
                                                  QSizePolicy.Fixed)

        spacer = sqt.empty()

        # Connections
        # ================
        # Plot updates
        for channel in self.adc_channels:
            self.connect(self.adc_channels[channel],
                         SIGNAL("updateChannelPlot"),
                         self.graph_x.updateChannel)

        # Timer for when the panel is in 'Run' mode
        self.timer = QTimer()
        QObject.connect(self.timer, SIGNAL('timeout()'), self.run)

        # Layout
        # =======================
        button_frame = sqt.frame(self)
        button_frame.position([[
            self.button_run_stop, self.button_single_shot, self.button_clear,
            spacer, IP_label, self.IP_address_text, self.button_connect
        ]])

        plot_frame = sqt.frame(self)
        plot_frame.position([[self.graph_x]])

        # Add to main layout
        self.position([[button_frame], [plot_frame]])

        # Panel variables
        # ================
        self.sample_count = 0

        self.running = False
Exemplo n.º 11
0
    def drawPanel(self):
        """
        Draw the GUI elements of the panel
        
        This is a Mandatory function. It will be called by ScopePy when
        the panel is added to a tab.
        
        """
        # Internal variables
        # =============================
        self.groupNameText = 'Group 1:'

        # Panel layout code goes here
        # =============================

        # Source info
        # ---------------------
        sourceLabel = QLabel('Data source')
        self.sourceLink = QLabel("No source")
        self.sourceLink.setMaximumWidth(self.API.charHeight_px * 80)

        # Column selector buttons
        # -----------------------------
        setXButton = QPushButton("Set X column [X]")
        setXButton.setShortcut(QKeySequence('X'))
        self.xLabel = QLabel(NOT_SELECTED)

        setYButton = QPushButton("Set Y column [Y]")
        setYButton.setShortcut(QKeySequence('Y'))
        self.yLabel = QLabel(NOT_SELECTED)

        self.columnSelector = QLineEdit()
        self.columnSelector.setMaximumWidth(self.API.charHeight_px * 80)
        columnSelectorLabel = QLabel('Column selec&tor')
        columnSelectorLabel.setBuddy(self.columnSelector)

        self.connect(setXButton, SIGNAL("clicked()"), self.setXcolumn)
        self.connect(setYButton, SIGNAL("clicked()"), self.setYcolumn)
        self.connect(self.columnSelector, SIGNAL("returnPressed()"),
                     self.selectColumnFromSelector)

        # Table editor widget
        # --------------------------
        self.table = TE.TableEditorWidget()

        # Top bar layout
        # ---------------------------
        topBar = sqt.frame(self)
        topBar.position([[
            sourceLabel, self.sourceLink,
            sqt.empty(), setXButton, setYButton
        ],
                         [
                             columnSelectorLabel, self.columnSelector,
                             sqt.empty(), self.xLabel, self.yLabel
                         ]])

        # Master layout
        panelLayout = QVBoxLayout()

        # Add to layout
        panelLayout.addWidget(topBar)
        panelLayout.addWidget(self.table)

        # Add layout to master widget [Mandatory]
        # ========================================
        # mandatory
        self.setLayout(panelLayout)

        # Check preferences
        # =====================
        if self.preferences is None:
            print("Test Panel: has no preferences")
        else:
            print("Test Panel: Preferences are here")

        # Setup ScopePy comms signals
        # ================================
        self.addCommsAction('addSource', self.addSource)
        self.addCommsAction('makeChannel', self.makeChannel)