示例#1
0
    def __init__(self, container, lambda_factory, content, mac,
                 handle_update_set):

        Tkinter.Frame.__init__(self, container)

        # text
        self.textElem = dustGuiLib.Text(self, width=6, height=1)
        self.textElem.insert(1.0, '')
        self.textElem.grid(row=0, column=0)

        # get button
        self.getButton = dustGuiLib.Button(
            self,
            command=lambda_factory(content['cb_get'], (mac, )),
            text="get",
        )
        self.getButton.grid(row=0, column=1)

        # set button
        self.setButton = dustGuiLib.Button(
            self,
            command=lambda_factory(handle_update_set,
                                   (mac, self.textElem, content['min'],
                                    content['max'], content['cb_set'])),
            text="set",
        )
        self.setButton.grid(row=0, column=2)
    def __init__(self,
                 parentElem,
                 guiLock,
                 inStartCaptureBPCB,
                 inStartCAutoBPCB,
                 inSaveBPCB,
                 frameName="Image Frame",
                 row=0,
                 column=0):
        # record params
        self.startCaptureBPCB = inStartCaptureBPCB
        self.startCAutoBPCB = inStartCAutoBPCB
        self.saveBPCB = inSaveBPCB

        # init parent
        dustFrame.dustFrame.__init__(self, parentElem, guiLock, frameName, row,
                                     column)

        self.captureButton = dustGuiLib.Button(self.container,
                                               text='Capture',
                                               command=self.startCaptureBPCB)

        self.startStopAutoButton = dustGuiLib.Button(
            self.container, text='Start Auto', command=self.startCAutoBPCB)

        self.saveButton = dustGuiLib.Button(self.container,
                                            text='Save image',
                                            command=self.saveBPCB)
        self._add(self.saveButton, 0, 0)
        self._add(self.captureButton, 1, 1)
        self._add(self.startStopAutoButton, 1, 2)

        self.isAutomatic = False

        # row 1: canvas
        self.imgCanvas = Tkinter.Canvas(self.container, width=320, height=240)

        #Simulate In-memory
        f = open("geek_inside.jpg", "rb")
        jpgdata = f.read()
        f.close()

        ##Draw from in-memory data
        file_jpgdata = StringIO(jpgdata)

        self.img = Image.open(file_jpgdata)

        self.photo = ImageTk.PhotoImage(self.img)

        self.item = self.imgCanvas.create_image(0,
                                                0,
                                                anchor=NW,
                                                image=self.photo)

        self._add(self.imgCanvas, 0, 1, columnspan=2)
示例#3
0
    def __init__(self, container, lambda_factory, content, mac,
                 handle_setThreeVal_set):

        # initialize parent class
        Tkinter.Frame.__init__(self, container)

        # text 1
        self.textElem1 = dustGuiLib.Text(self, width=6, height=1)
        self.textElem1.insert(1.0, '')
        self.textElem1.grid(row=0, column=0)

        # text 2
        self.textElem2 = dustGuiLib.Text(self, width=6, height=1)
        self.textElem2.insert(1.0, '')
        self.textElem2.grid(row=0, column=1)

        # text 3
        self.textElem3 = dustGuiLib.Text(self, width=6, height=1)
        self.textElem3.insert(1.0, '')
        self.textElem3.grid(row=0, column=2)

        # set button
        self.setButton = dustGuiLib.Button(
            self,
            command=lambda_factory(
                handle_setThreeVal_set,
                (mac, self.textElem1, self.textElem2, self.textElem3,
                 content['min2'], content['max2'], content['min3'],
                 content['max3'], content['cb_set'])),
            text="set",
        )
        self.setButton.grid(row=0, column=3)
示例#4
0
 def __init__(self,parentElem,guiLock,setCb,frameName="Form",row=0,column=0):
     
     # validate params
     assert callable(setCb)
     
     # store params
     self.setCb      = setCb
     
     # init parent
     dustFrame.dustFrame.__init__(self,parentElem,guiLock,frameName,row,column)
     
     # row 0: form
     self.formFrame = Tkinter.Frame(
         self.container,
         borderwidth=0,
         bg=dustStyle.COLOR_BG,
     )
     self.formFrame.grid(row=0,column=0,sticky=Tkinter.W)
     
     self.formText = dustGuiLib.Text(
         self.formFrame,
         font=dustStyle.FONT_BODY,
         width=50,
         height=1,
         returnAction=self._buttonCb,
     )
     self.formText.insert(1.0,"")
     self._add(self.formText,0,0)
     
     self.formButton = dustGuiLib.Button(
         self.formFrame,
         text='set',
         command=self._buttonCb,
     )
     self._add(self.formButton,0,1)
示例#5
0
    def _addRowInternal(self, contents, coltypes, mac=None):

        assert (len(contents) == len(coltypes))

        self.guiElems.append([])
        for (content, type) in zip(contents, coltypes):

            if type == self.LABEL:
                temp = dustGuiLib.Label(self.container,
                                        text=str(content),
                                        border=1,
                                        bg=dustStyle.COLOR_BG,
                                        relief=Tkinter.RIDGE,
                                        borderwidth=1,
                                        padx=3,
                                        pady=3)

            elif type == self.ACTION:
                temp = dustGuiLib.Button(self.container)
                temp.configure(text=content['text'])
                temp.configure(
                    command=self._lambda_factory(content['callback'], (mac,
                                                                       temp)))

            elif type == self.SETONEVAL:
                if 'defaultVal' in content:
                    defaultVal = content['defaultVal']
                else:
                    defaultVal = ''
                temp = SetOneValFrame(self.container, self._lambda_factory,
                                      content, mac, self._handle_setOneVal_set,
                                      defaultVal)

            elif type == self.GETSETONEVAL:
                temp = GetSetOneValFrame(self.container, self._lambda_factory,
                                         content, mac,
                                         self._handle_getSetOneVal_set)

            elif type == self.SETTHREEVAL:
                temp = SetThreeValFrame(self.container, self._lambda_factory,
                                        content, mac,
                                        self._handle_setThreeVal_set)

            else:
                raise SystemError("column type {0} unsupported".format(type))

            self._add(temp,
                      len(self.guiElems) - 1,
                      len(self.guiElems[-1]),
                      sticky=Tkinter.W + Tkinter.E)
            self.guiElems[-1].append(temp)
示例#6
0
    def __init__(self,
                 parentElem,
                 guiLock,
                 frameName="progress",
                 row=0,
                 column=0):

        # record variables

        # init parent
        dustFrame.dustFrame.__init__(self, parentElem, guiLock, frameName, row,
                                     column)

        # text field with yscrollbar

        yscrollbar = Tkinter.Scrollbar(self.container)
        yscrollbar.grid(row=0, column=1, sticky=Tkinter.N + Tkinter.S)

        self.textField = Tkinter.Text(
            self.container,
            font=dustStyle.FONT_BODY,
            bg=dustStyle.COLOR_BG,
            width=120,
            height=20,
            state='disabled',
            yscrollcommand=yscrollbar.set,
        )
        yscrollbar.config(command=self.textField.yview)

        self.textField.tag_config(self.SEVERITY_NOERROR,
                                  background=dustStyle.COLOR_NOERROR)
        self.textField.tag_config(self.SEVERITY_WARNING,
                                  background=dustStyle.COLOR_WARNING)
        self.textField.tag_config(self.SEVERITY_ERROR,
                                  background=dustStyle.COLOR_ERROR)

        self._add(self.textField, 0, 0)

        # clear button
        temp = dustGuiLib.Button(
            self.container,
            text='Clear',
            command=self.clear,
        )
        self._add(
            elem=temp,
            row=1,
            column=0,
            sticky=Tkinter.E,
        )
示例#7
0
    def __init__(self,
                 parentElem,
                 guiLock,
                 cbApiLoaded,
                 frameName="api",
                 row=0,
                 column=0,
                 deviceType=None):

        # store params
        self.cbApiLoaded = cbApiLoaded
        self.deviceType = deviceType

        # init parent
        dustFrame.dustFrame.__init__(self, parentElem, guiLock, frameName, row,
                                     column)

        temp = dustGuiLib.Label(self.container, text="network type:")
        self._add(temp, 0, 0)

        self.networkTypeString = Tkinter.StringVar(self.container)
        self.networkTypeString.set(self.WHART)
        self.networkTypeMenu = dustGuiLib.OptionMenu(self.container,
                                                     self.networkTypeString,
                                                     self.WHART, self.IP)
        self._add(self.networkTypeMenu, 0, 1)

        temp = dustGuiLib.Label(self.container, text="device type:")
        self._add(temp, 0, 2)

        self.deviceTypeString = Tkinter.StringVar(self)
        if deviceType:
            self.deviceTypeString.set(deviceType)
        else:
            self.deviceTypeString.set(self.MANAGER)
        self.deviceTypeMenu = dustGuiLib.OptionMenu(self.container,
                                                    self.deviceTypeString,
                                                    self.MANAGER, self.MOTE)
        self._add(self.deviceTypeMenu, 0, 3)
        if self.deviceType:
            self.deviceTypeMenu.config(state=Tkinter.DISABLED)

        self.loadButton = dustGuiLib.Button(self.container,
                                            text="load",
                                            command=self._loadApi)
        self._add(self.loadButton, 0, 4)
示例#8
0
    def __init__(self,
                 parentElem,
                 guiLock,
                 startPressedCb,
                 stopPressedCb,
                 frameName="LED ping",
                 row=0,
                 column=0):

        # record params
        self.startPressedCb = startPressedCb
        self.stopPressedCb = stopPressedCb

        # init parent
        dustFrame.dustFrame.__init__(self, parentElem, guiLock, frameName, row,
                                     column)

        # row 0: mac
        self.macText = dustGuiLib.Text(self.container,
                                       font=dustStyle.FONT_BODY,
                                       width=25,
                                       height=1)
        self.macText.insert(1.0, "00170d000038")
        self._add(self.macText, 0, 0)

        self.startStopButton = dustGuiLib.Button(
            self.container, text='start', command=self._startStopButtonPressed)
        self.disableButton()
        self._add(self.startStopButton, 0, 1)

        # row 1: canvas
        self.ledCanvas = Tkinter.Canvas(self.container, width=200, height=200)
        self._add(self.ledCanvas, 1, 0, columnspan=2)

        # row 2: rtt label
        self.rttLabel = Tkinter.Label(self.container)
        self._add(self.rttLabel, 2, 0, columnspan=2)
示例#9
0
    def __init__(self,
                 parentElem,
                 guiLock,
                 selected_cb,
                 allowMultipleFiles=True,
                 frameName="browse",
                 row=0,
                 column=0):

        # record variables
        self.selected_cb = selected_cb
        self.allowMultipleFiles = allowMultipleFiles

        # init parent
        dustFrame.dustFrame.__init__(self, parentElem, guiLock, frameName, row,
                                     column)

        #====

        # browse button
        self.browseButton = dustGuiLib.Button(self.container,
                                              text='browse',
                                              command=self._browse)
        self._add(self.browseButton, 0, 0)
示例#10
0
 def _handleCommand(self,level):
     '''
     \brief Generic handler when item is selected from drop-down list of (sub)commands.
     
     \param level 0 indicates a command was selected. 1 indicates a subcommand was selected.
     '''
     
     # clear the old guiElems
     self._clearGuiElems(level)
     if self.fieldsFrame:
         self.fieldsFrame.grid_forget()
         self.fieldsFrame = None
     
     c = {
         'commandName'         : None,
         'fieldNames'          : [],
         'fieldNamesGui'       : [],
         'fieldFormats'        : [],
         'fieldFormatsGui'     : [],
         'fieldLengths'        : [],
         'fieldOptions'        : [],
         'fieldValuesGui'      : [],
         'fieldValuesString'   : [],
         'fieldValuesRaw'      : [],
         'fieldValues'         : [],
         'commandORbuttonGui'  : None,
     }
     
     # read the command name just selected
     with self.guiLock:
         if   level==0: 
             c['commandName'] = self.commandToSend.get()
         elif level==1:
             c['commandName'] = self.subcommandToSend.get()
     
     fullCmd = [elem['commandName'] for elem in self.guiElems]
     fullCmd.append(c['commandName'])
     
     # call the selected callback
     self.selectedCb(fullCmd)
     
     # add elements for fields
     try:
         c['fieldNames']   =  self.apiDef.getRequestFieldNames(fullCmd)
         c['fieldFormats'] = [
             self.apiDef.getRequestFieldFormat(fullCmd,fieldName)
             for fieldName in c['fieldNames']
         ]
         c['fieldLengths'] = [
             self.apiDef.getRequestFieldLength(fullCmd,fieldName)
             for fieldName in c['fieldNames']
         ]
         c['fieldOptions'] = [
             self.apiDef.getRequestFieldOptions(fullCmd,fieldName)
             for fieldName in c['fieldNames']
         ]
     except CommandError as err:
         traceback.print_exc()
         return
         
     # create a frame for all fields and add GUI elements
     with self.guiLock:
         self.fieldsFrame = Tkinter.Frame(
             self.container,
             borderwidth=10,
             bg=dustStyle.COLOR_BG,
         )
         self._add(
             self.fieldsFrame,
             level*2+2,
             column=0,
         )
     
     headerColor = self._getHeaderColor()
     
     with self.guiLock:
         for i in range(len(c['fieldNames'])):
             if c['fieldNames'][i] in ApiDefinition.ApiDefinition.RESERVED:
                 continue
                 
             # calculate width of text entry
             if c['fieldLengths'][i]:
                 if   c['fieldFormats'][i] in [ApiDefinition.FieldFormats.STRING]:
                     textEntryWidth = c['fieldLengths'][i]+2
                 elif c['fieldFormats'][i] in [ApiDefinition.FieldFormats.HEXDATA]:
                     textEntryWidth = c['fieldLengths'][i]*2+2
                 else:
                     textEntryWidth = dustStyle.TEXTFIELD_ENTRY_LENGTH_DEFAULT
                 autoResize = False
             else:
                 textEntryWidth = dustStyle.TEXTFIELD_ENTRY_LENGTH_DEFAULT
                 autoResize = True
             
             if textEntryWidth>dustStyle.TEXTFIELD_ENTRY_LENGTH_MAX:
                 textEntryWidth = dustStyle.TEXTFIELD_ENTRY_LENGTH_MAX
                 
             # display row 0: name
             c['fieldNamesGui'] += [
                 dustGuiLib.Label(
                     self.fieldsFrame,
                     text           = c['fieldNames'][i],
                     bg             = dustStyle.COLOR_BG,
                     relief         = Tkinter.RIDGE,
                     borderwidth    = 1,
                     background     = headerColor,
                     padx           = 3,
                     pady           = 3,
                 )
             ]
             c['fieldNamesGui'][-1].grid(
                 row                = 0,
                 column             = i,
                 sticky             = Tkinter.W+Tkinter.E,
             )
             
             # display row 1: value
             if c['fieldOptions'][i].optionDescs or c['fieldFormats'][i]=='bool':
                 if c['fieldOptions'][i].optionDescs:
                     optionValues = c['fieldOptions'][i].optionDescs
                 else:
                     optionValues = ['True','False']
                 c['fieldValuesString'] += [Tkinter.StringVar()]
                 c['fieldValuesGui']    += [
                     dustGuiLib.OptionMenu(
                         self.fieldsFrame,
                         c['fieldValuesString'][-1],
                         *optionValues
                     )
                 ]
             else:
                 c['fieldValuesString'] += [None]
                 c['fieldValuesGui']    += [
                     dustGuiLib.Text(
                         self.fieldsFrame,
                         font       = dustStyle.FONT_BODY,
                         width      = textEntryWidth,
                         height     = 1,
                         padx       = 3,
                         pady       = 3,
                         autoResize = autoResize,
                     )
                 ]
             c['fieldValuesGui'][-1].grid(
                 row      = 1,
                 column   = i,
                 sticky   = Tkinter.W+Tkinter.E,
             )
             
             # display row 2: format and length
             fieldFormatsString = ApiDefinition.ApiDefinition.fieldFormatToString(
                 c['fieldLengths'][i],
                 c['fieldFormats'][i]
             )
             c['fieldFormatsGui']  += [
                 dustGuiLib.Label(
                     self.fieldsFrame,
                     text           = fieldFormatsString,
                     bg             = dustStyle.COLOR_BG,
                     relief         = Tkinter.RIDGE,
                     borderwidth    = 1,
                     padx           = 3,
                     pady           = 3,
                 )
             ]
             c['fieldFormatsGui'][-1].grid(
                 row      = 2,
                 column   = i,
                 sticky   = Tkinter.W+Tkinter.E,
             )
     
     # subcommands
     with self.guiLock:
         tempOptions = None
         if self.apiDef.hasSubcommands(ApiDefinition.ApiDefinition.COMMAND,
                                  fullCmd)==True:
             tempOptions = self.apiDef.getNames(ApiDefinition.ApiDefinition.COMMAND,
                                           fullCmd)
             tempOptions.sort()
             c['commandORbuttonGui'] = dustGuiLib.OptionMenu(self.container,
                                                             self.subcommandToSend,
                                                             *tempOptions)
         else:
             c['commandORbuttonGui'] = dustGuiLib.Button(self.container,
                                                         command=self._handleSend,
                                                         text="send",)
         self._add(c['commandORbuttonGui'],level*2+2+1,0)
     
     # add to guiElems
     self.guiElems.append(c)
     
     # display the first alphabetical subcommand in subcommand option menu
     if tempOptions:
         self.subcommandToSend.set(tempOptions[0])
示例#11
0
    def __init__(self,
                 parentElem,
                 guiLock,
                 frameName="sensor",
                 row=0,
                 column=0):

        # record params

        # local variables
        self.connector = None
        self.payloadCounter = 0

        # init parent
        dustFrame.dustFrame.__init__(self, parentElem, guiLock, frameName, row,
                                     column)

        #row 0: slide
        self.slide = Tkinter.Scale(self.container,
                                   from_=0,
                                   to=0xffff,
                                   orient=Tkinter.HORIZONTAL)
        self._add(self.slide, 0, 0, columnspan=3)

        #row 1: label
        temp = dustGuiLib.Label(self.container,
                                text='destination IPv6 address')
        self._add(temp, 1, 0)
        temp.configure(font=dustStyle.FONT_HEADER)

        temp = dustGuiLib.Label(self.container, text='dest. UDP port')
        self._add(temp, 1, 1)
        temp.configure(font=dustStyle.FONT_HEADER)

        #row 2: send to manager
        temp = dustGuiLib.Label(self.container, text=WELL_KNOWN_ADDR_MANAGER)
        self._add(temp, 2, 0)

        self.mgrPortText = dustGuiLib.Text(self.container, width=6, height=1)
        self.mgrPortText.insert(1.0, DEFAULT_DEST_PORT)
        self._add(self.mgrPortText, 2, 1)

        self.mgrButton = dustGuiLib.Button(self.container,
                                           text='send to manager',
                                           state=Tkinter.DISABLED,
                                           command=self._sendMgr)
        self._add(self.mgrButton, 2, 2)

        #row 3: send to host
        self.hostAddrText = dustGuiLib.Text(self.container, width=35, height=1)
        self.hostAddrText.insert(1.0, DEFAULT_HOST_ADDR)
        self._add(self.hostAddrText, 3, 0)

        self.hostPortText = dustGuiLib.Text(self.container, width=6, height=1)
        self.hostPortText.insert(1.0, DEFAULT_DEST_PORT)
        self._add(self.hostPortText, 3, 1)

        self.hostButton = dustGuiLib.Button(self.container,
                                            text='send to host',
                                            state=Tkinter.DISABLED,
                                            command=self._sendHost)
        self._add(self.hostButton, 3, 2)

        #row 4: status
        self.statusLabel = dustGuiLib.Label(self.container)
        self._add(self.statusLabel, 4, 0, columnspan=3)
    def __init__(self,
                 parentElem,
                 guiLock,
                 selectedMoteChangedCB,
                 displayMoteButtonCB,
                 refreshButtonCB,
                 clearMotesButtonCB,
                 frameName="Configuration",
                 row=0,
                 column=1):

        # record params
        self.selectedMoteChangedCB = selectedMoteChangedCB
        self.displayMoteButtonCB = displayMoteButtonCB
        self.refreshButtonCB = refreshButtonCB
        self.clearMotesButtonCB = clearMotesButtonCB

        # local variables
        self.selectedMote = Tkinter.StringVar()
        self.selectedMote.trace("w", self._selectedMoteChangedCB_internal)

        # initialize parent
        dustFrame.dustFrame.__init__(self, parentElem, guiLock, frameName, row,
                                     column)

        # motes
        temp = dustGuiLib.Label(self.container,
                                anchor=Tkinter.NW,
                                justify=Tkinter.LEFT,
                                text='Select mote:')
        self._add(temp, 0, 0)
        self.motes = dustGuiLib.OptionMenu(self.container, self.selectedMote,
                                           *[''])
        self._add(self.motes, 0, 1)

        # display mote button
        self.displayMoteButton = dustGuiLib.Button(
            self.container,
            text='Display Mote',
            command=self.displayMoteButtonCB,
        )
        self._add(self.displayMoteButton, 0, 2)

        # refresh button
        self.refreshButton = dustGuiLib.Button(self.container,
                                               text='Update Mote List',
                                               command=self.refreshButtonCB)
        self._add(self.refreshButton, 1, 2)

        #clear mote buttons
        self.clearMotesButton = dustGuiLib.Button(
            self.container,
            text='Clear Motes',
            command=self.clearMotesButtonCB,
        )
        self._add(self.clearMotesButton, 2, 2)

        # action label
        self.actionLabel = dustGuiLib.Label(
            self.container,
            anchor=Tkinter.CENTER,
            justify=Tkinter.LEFT,
            text='',
        )
        self._add(self.actionLabel, 1, 1)
 def __init__(self,parentElem,guiLock,
         selectedMoteChangedCB,
         refreshButtonCB,
         getConfigurationCB,
         setConfigurationCB,
         frameName="Configuration",row=0,column=1):
     
     # record params
     self.selectedMoteChangedCB     = selectedMoteChangedCB
     self.refreshButtonCB           = refreshButtonCB
     self.getConfigurationCB        = getConfigurationCB
     self.setConfigurationCB        = setConfigurationCB
     
     # local variables
     self.selectedMote         = Tkinter.StringVar()
     self.selectedMote.trace("w",self._selectedMoteChangedCB_internal)
     
     # initialize parent
     dustFrame.dustFrame.__init__(self,
         parentElem,
         guiLock,
         frameName,
         row,column
     )
     
     # report period
     temp                      = dustGuiLib.Label(self.container,
         anchor                = Tkinter.NW,
         justify               = Tkinter.LEFT,
         text                  = 'Report Period (ms):',
     )
     self._add(temp,0,0)
     self.reportPeriod         = dustGuiLib.Text(self.container,
         font                  = dustStyle.FONT_BODY,
         width                 = 25,
         height                = 1,
     )
     self._add(self.reportPeriod,0,1)
     
     # bridge settling time
     temp                      = dustGuiLib.Label(self.container,
         anchor                = Tkinter.NW,
         justify               = Tkinter.LEFT,
         text                  = 'Bridge Settling Time (ms):',
     )
     self._add(temp,1,0)
     self.bridgeSettlingTime   = dustGuiLib.Text(self.container,
         font                  = dustStyle.FONT_BODY,
         width                 = 25,
         height                = 1,
     )
     self._add(self.bridgeSettlingTime,1,1)
     
     # LDO on time
     temp                      = dustGuiLib.Label(self.container,
         anchor                = Tkinter.NW,
         justify               = Tkinter.LEFT,
         text                  = 'LDO on time (ms):',
     )
     self._add(temp,2,0)
     self.ldoOnTime            = dustGuiLib.Text(
         self.container,
         font                  = dustStyle.FONT_BODY,
         width                 = 25,
         height                = 1,
     )
     self._add(self.ldoOnTime,2,1)
     
     # motes
     temp                      = dustGuiLib.Label(self.container,
         anchor                = Tkinter.NW,
         justify               = Tkinter.LEFT,
         text                  = 'Select mote:')
     self._add(temp,3,0)
     self.motes                = dustGuiLib.OptionMenu(
         self.container,
         self.selectedMote,
         *['']
     )
     self._add(self.motes,3,1)
     
     # refresh button
     self.refreshButton        = dustGuiLib.Button(self.container,
         text                  = 'refresh',
         command               = self.refreshButtonCB
     )
     self._add(self.refreshButton,3,2)
     
     # action label
     self.actionLabel          = dustGuiLib.Label(self.container,
         anchor                = Tkinter.CENTER,
         justify               = Tkinter.LEFT,
         text                  = '',
     )
     self._add(self.actionLabel,4,1)
     
     # get configuration button
     self.getConfigurationButton = dustGuiLib.Button(self.container,
         text                  = 'get configuration',
         command               = self.getConfigurationCB,
     )
     self._add(self.getConfigurationButton,4,2)
     
     # set configuration button
     self.setConfigurationButton = dustGuiLib.Button(self.container,
         text                  = 'set configuration',
         command               = self._setConfigurationCB_internal,
     )
     self._add(self.setConfigurationButton,5,2)
    def __init__(self,parentElem,guiLock,connectCb,frameName="connection",row=0,column=0):
        
        # record variables
        self.connectCb    = connectCb
        
        # init parent
        dustFrame.dustFrame.__init__(self,parentElem,guiLock,frameName,row,column)
        
        # row 0: serial port
        self.serialFrame = Tkinter.Frame(self.container,
                                borderwidth=0,
                                bg=dustStyle.COLOR_BG)
        
        temp = dustGuiLib.Label(self.serialFrame,
                             font=dustStyle.FONT_BODY,
                             bg=dustStyle.COLOR_BG,
                             text="through serial port:")
        self._add(temp,0,0,columnspan=3)
        
        temp = dustGuiLib.Label(self.serialFrame,
                             font=dustStyle.FONT_BODY,
                             bg=dustStyle.COLOR_BG,
                             text="port name:")
        self._add(temp,1,0)
        
        self.serialPortText = dustGuiLib.Text(self.serialFrame,
                                              font=dustStyle.FONT_BODY,
                                              width=25,
                                              height=1,
                                              returnAction=self._connectSerial)
        self.serialPortText.insert(1.0,"")
        self._add(self.serialPortText,1,1)
        
        self.serialButton = dustGuiLib.Button(self.serialFrame,
                                              text='connect',
                                              command=self._connectSerial)
        self._add(self.serialButton,1,2)

        # row 2: serialMux
        self.serialMuxFrame = Tkinter.Frame(self.container,
                                borderwidth=0,
                                bg=dustStyle.COLOR_BG)
        
        temp = dustGuiLib.Label(self.serialMuxFrame,
                             font=dustStyle.FONT_BODY,
                             text="through serialMux:",
                             bg=dustStyle.COLOR_BG)
        self._add(temp,0,0,columnspan=5)
        
        temp = dustGuiLib.Label(self.serialMuxFrame,
                             font=dustStyle.FONT_BODY,
                             bg=dustStyle.COLOR_BG,
                             text="host:")
        self._add(temp,1,0)
        
        self.serialMuxHostText = dustGuiLib.Text(self.serialMuxFrame,
                                        font=dustStyle.FONT_BODY,
                                        width=15,
                                        height=1,
                                        returnAction=self._connectSerialMux)
        self.serialMuxHostText.insert(1.0,"127.0.0.1")
        self._add(self.serialMuxHostText,1,1)
        
        temp = dustGuiLib.Label(self.serialMuxFrame,
                             font=dustStyle.FONT_BODY,
                             bg=dustStyle.COLOR_BG,
                             text="port:")
        self._add(temp,1,2)
        
        self.serialMuxPortText = dustGuiLib.Text(self.serialMuxFrame,
                                        font=dustStyle.FONT_BODY,
                                        width=5,
                                        height=1,
                                        returnAction=self._connectSerialMux)
        self.serialMuxPortText.insert(1.0,"9900")
        self._add(self.serialMuxPortText,1,3)
        
        self.serialMuxButton = dustGuiLib.Button(self.serialMuxFrame,
                                                 text='connect',
                                                 command=self._connectSerialMux)
        self._add(self.serialMuxButton,1,4)

        # row 3: xml
        self.xmlFrame = Tkinter.Frame(self.container,borderwidth=0,bg=dustStyle.COLOR_BG)
        temp = dustGuiLib.Label(self.xmlFrame,
                             font=dustStyle.FONT_BODY,
                             bg=dustStyle.COLOR_BG,
                             text="through XML-RPC:")
        self._add(temp,0,0,columnspan=5)
        
        temp = dustGuiLib.Label(self.xmlFrame,
                             font=dustStyle.FONT_BODY,
                             bg=dustStyle.COLOR_BG,
                             text="host:")
        self._add(temp,1,0)
        
        self.xmlHostText = dustGuiLib.Text(self.xmlFrame,
                            font=dustStyle.FONT_BODY,
                            width=15,
                            height=1,
                            returnAction=self._connectXml)
        self.xmlHostText.insert(1.0,"")
        self._add(self.xmlHostText,1,1)
        
        temp = dustGuiLib.Label(self.xmlFrame,
                            font=dustStyle.FONT_BODY,
                            bg=dustStyle.COLOR_BG,
                            text="port:")
        self._add(temp,1,2)
        
        self.xmlPortText = dustGuiLib.Text(self.xmlFrame,
                                        font=dustStyle.FONT_BODY,
                                        width=5,
                                        height=1,
                                        returnAction=self._connectXml)
        self.xmlPortText.insert(1.0,"4445")
        self._add(self.xmlPortText,1,3)
        
        self.xmlButton = dustGuiLib.Button(self.xmlFrame,
                                           text='connect',
                                           command=self._connectXml)
        self._add(self.xmlButton,1,4)
        
        # row 4: text
        self.tipLabel = dustGuiLib.Label(self.container,borderwidth=0,bg=dustStyle.COLOR_BG)
        self.guiLock.acquire()
        self.tipLabel.grid(row=4,column=0,sticky=Tkinter.W)
        self.guiLock.release()
示例#15
0
    def __init__(self,
                 parentElem,
                 guiLock,
                 connectedCb,
                 frameName="br connection",
                 row=0,
                 column=0):

        # record variables
        self.connectedCb = connectedCb

        # init parent
        dustFrame.dustFrame.__init__(self, parentElem, guiLock, frameName, row,
                                     column)

        #====

        # connect button
        self.connectButton = dustGuiLib.Button(self.container,
                                               text='connect',
                                               command=self._connect)
        self._add(self.connectButton, 0, 0)

        #====

        self.connectionErrorLabel = dustGuiLib.Label(self.container, text='')
        self._add(self.connectionErrorLabel, 1, 0, columnspan=2)

        #====

        # connection
        temp = dustGuiLib.Label(self.container, text="connection:")
        self._add(temp, 2, 0)
        self.connectionLabel = dustGuiLib.Label(self.container, text='')
        self._add(self.connectionLabel, 2, 1)

        # status
        temp = dustGuiLib.Label(self.container, text="status:")
        self._add(temp, 3, 0)
        self.statusLabel = dustGuiLib.Label(self.container, text='')
        self._add(self.statusLabel, 3, 1)

        # prefix
        temp = dustGuiLib.Label(self.container, text="prefix:")
        self._add(temp, 4, 0)
        self.prefixLabel = dustGuiLib.Label(self.container, text='')
        self._add(self.prefixLabel, 4, 1)

        # statsTx
        temp = dustGuiLib.Label(self.container, text="transmitted to LBR:")
        self._add(temp, 5, 0)
        self.statsTxLabel = dustGuiLib.Label(self.container, text='')
        self._add(self.statsTxLabel, 5, 1)

        # statsRx
        temp = dustGuiLib.Label(self.container, text="received from LBR:")
        self._add(temp, 6, 0)
        self.statsRxLabel = dustGuiLib.Label(self.container, text='')
        self._add(self.statsRxLabel, 6, 1)

        # have GUI update
        self.after(UPDATEPERIOD, self._updateGui)
示例#16
0
    def __init__(self,
                 parentElem,
                 guiLock,
                 frameName="Conversion",
                 topName='top',
                 toBottomCb=None,
                 bottomName='bottom',
                 toTopCb=None,
                 row=0,
                 column=0):

        if toBottomCb:
            assert callable(toBottomCb)
        if toTopCb:
            assert callable(toTopCb)

        # record variables
        self.topName = topName
        self.toBottomCb = toBottomCb
        self.bottomName = bottomName
        self.toTopCb = toTopCb

        # init parent
        dustFrame.dustFrame.__init__(self, parentElem, guiLock, frameName, row,
                                     column)

        #===== row 0: topName
        temp = dustGuiLib.Label(
            self.container,
            text=self.topName,
        )
        self._add(temp, 0, 0, columnspan=2)
        temp.configure(font=dustStyle.FONT_HEADER)

        #===== row 1: topField

        topscrollbar = Tkinter.Scrollbar(self.container)
        topscrollbar.grid(row=1, column=2, sticky=Tkinter.N + Tkinter.S)
        self.topField = Tkinter.Text(
            self.container,
            bg=dustStyle.COLOR_BG,
            width=100,
            height=10,
            yscrollcommand=topscrollbar.set,
        )
        topscrollbar.config(command=self.topField.yview)
        self._add(self.topField, 1, 0, columnspan=2)
        self.topField.configure(font=self.FONT_MONOSPACE)

        #===== row 2: buttons

        temp = dustGuiLib.Button(self.container,
                                 text='to {0}'.format(self.bottomName),
                                 command=self._toBottomButtonPressed)
        self._add(temp, 2, 0)

        temp = dustGuiLib.Button(self.container,
                                 text='to {0}'.format(self.topName),
                                 command=self._toTopButtonPressed)
        self._add(temp, 2, 1)

        #===== row 3: bottomName
        temp = dustGuiLib.Label(
            self.container,
            text=self.bottomName,
        )
        self._add(temp, 3, 0, columnspan=2)
        temp.configure(font=dustStyle.FONT_HEADER)

        #===== row 4: bottomField

        bottomscrollbar = Tkinter.Scrollbar(self.container)
        bottomscrollbar.grid(row=4, column=2, sticky=Tkinter.N + Tkinter.S)
        self.bottomField = Tkinter.Text(
            self.container,
            bg=dustStyle.COLOR_BG,
            width=100,
            height=10,
            yscrollcommand=bottomscrollbar.set,
        )
        bottomscrollbar.config(command=self.bottomField.yview)
        self._add(self.bottomField, 4, 0, columnspan=2)
        self.bottomField.configure(font=self.FONT_MONOSPACE)