cfgWindow.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:serialplot 作者: crxguy52 项目源码 文件源码
def __init__(self, parent):
        ttk.Frame.__init__(self, parent)
        self.parent = parent
        self['padding'] = '4'

        self.TKvariables = {}

        #Read in the defaults
        for key in defaults:

            if key[0:5] == 'graph' or key.find('ylims') >= 0:
                self.TKvariables.update({key:[]})

                for val in range(len(defaults[key])):
                    self.TKvariables[key].append(tk.StringVar(value=defaults[key][val]))

            else:
                self.TKvariables.update({key:tk.StringVar(value=defaults[key])})      

        num_vars = int(self.TKvariables['datalength'].get())
        self.datalist = list(range(1,num_vars+1))

        #Create a combobox containing the available COM ports        
        comlst = self.get_comlst()
        self.COMbox = ttk.Labelframe(self, text='COM port to source data from')
        self.COMcombo = ttk.Combobox(self.COMbox,  width=60, values=comlst, \
            state='readonly', textvariable=self.TKvariables['COMport'],\
            postcommand=self.updateCOMbox )
        self.COMbox.grid(row = 0, column = 0, columnspan = 5)
        self.COMcombo.grid()

        #Create an "about" text box
        ABOUTframe = ttk.LabelFrame(self, text = 'What it does')
        ABOUTlabel = ttk.Label(ABOUTframe, text= \
            'Graphs data coming in over the serial port in a comma '
            'seperated variable string. Hover over each option to get ' 
            'a description of what the setting does', wraplength = 140)
        ABOUTframe.grid(row=1, column = 0, rowspan = 2, columnspan = 2, \
            sticky = 'nw, se', padx= 3, pady = 5)
        CreateToolTip(ABOUTlabel,\
        "The default values can be changed by opening defaults.py with a text "
        "editor and changing the values")
        ABOUTlabel.pack()        

        #Create a Graph! and About buttons
        GObut = ttk.Button(self, text='Go!', command=self.goButton)
        GObut.grid(row=6, column = 0, sticky = 'we')
        ABOUTbut = ttk.Button(self, text='About', command=self.aboutButton) 
        ABOUTbut.grid(row = 6, column = 1, sticky = 'we')

        #Create an instance of the class for the config panel
        notebook = ConfigNotebook(self, self)

        #Update the state of the graphs based on the defaults and grid
        notebook.updateGraphs()     
        notebook.grid(row=1, column=3, columnspan=2, rowspan=6, sticky = 'nsew', \
                padx = 5, pady = 5)

        #Bind the enter key to start the program
        self.parent.bind("<Return>", lambda event:self.goButton())
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号