Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 [Tkinter] Setting Binding to Entry created with a loop?
I'm not even really sure what to google to find what I'm looking for. So I haven't been able to find what I'm looking for.

So, I'm creating a series of Entry widgets using a loop.

    def efs_widgets(self):
        elems = ['Cu',
        row_count = 4
        for i in range(len(elems)):
            self.tb = "efs_" + elems[i] + "_Box"
            self.tb = Entry(self.frame2, width=18, bg="#E6EAEC")

            if (i%2)==0:
                self.tb.grid(row=row_count, column=1, padx=1, pady=5)                
                self.tb.grid(row=row_count, column=4, padx=1, pady=5)
                row_count = row_count+1

Then when I try to set a binding to the entry widget I get an error saying that there is no attribute

    def efs_form(self):
        def chb_click(event):
            self.avg_string = ""
            self.in_avg = ""
            if self.chb_var == 1:
                self.chb_var = 0
                self.avg_string = "NOT included in the Average."
                self.chb_var = 1
                self.avg_string = "Included in the Average."
                self.in_avg = "X"

        self.db_conn = sqlite3.connect('EFS_Samples.db')
        self.c = self.db_conn.cursor()
        self.chb_var = 1
        self.next_box = True
        # Create Database Table
        self.c.execute(""" CREATE TABLE IF NOT EXISTS efs(
            _Timestamp text,
            Arrival_Time text,
            Sample_Time text,
            analyst text,
            cro text,
            cu text,
            fe text,
            s text,
            si text,
            ca text,
            al text,
            mag text,
            avg text        
        self.c.execute("SELECT * FROM efs")
        self.prev_sams = self.c.fetchmany(20) 
        self.efs_prev_lb.delete(0, END)
        self.efs_analyst_lb.delete(0, END)
        self.efs_cu_lb.delete(0, END)
        self.efs_avg_lb.delete(0, END)
        for sam in self.prev_sams:
            self.efs_prev_lb.insert(0, sam[2])
            self.efs_analyst_lb.insert(0, sam[3])
            self.efs_cu_lb.insert(0, sam[5])
            self.efs_avg_lb.insert(0, sam[12])
        self.efs_Cu_Box = ""
        self.efs_arr_Time.bind("<FocusIn>", self.focus_in)
        self.efs_sam_Time.bind("<FocusIn>", self.focus_in)
        self.efs_analyst.bind("<<ComboboxSelected>>", self.focus_in)
        self.efs_cro.bind("<<ComboboxSelected>>", self.focus_in)
        self.efs_Cu_Box.bind("<FocusIn>", self.focus_in)
        self.efs_Fe_Box.bind("<FocusIn>", self.focus_in)
        self.efs_S_Box.Bind("<FocusIn>", self.focus_in)
        self.efs_SiO2_Box.Bind("<FocusIn>", self.focus_in)
        self.efs_CaO_Box.Bind("<FocusIn>", self.focus_in)
        self.efs_Al2O3_Box.Bind("<FocusIn>", self.focus_in)
        self.efs_Fe3O4_Box.Bind("<FocusIn>", self.focus_in)
        self.efs_avg_chb.bind("<Button-1>", chb_click)
Can I get some help how I can approach this? Thanks. It would be much appreciated.
Quote:I get an error saying that there is no attribute
Please always post the error traceback, complete and unaltered, it contains valuable information that shows what led up to the error.

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  [Tkinter] Binding Entry box to <Button-3> created in for loop iconit 5 260 Apr-22-2020, 05:47 AM
Last Post: iconit
  TkInter Binding Buttons ifigazsi 5 227 Apr-06-2020, 08:30 AM
Last Post: ifigazsi
  Making text clickable with binding DT2000 10 523 Apr-02-2020, 10:11 PM
Last Post: DT2000
  Problem with setting variable within a Entry validatecommand kenwatts275 1 186 Mar-31-2020, 01:53 AM
Last Post: deanhystad
  Transfer Toplevel window entry to root window entry with TKinter HBH 0 1,093 Jan-23-2020, 09:00 PM
Last Post: HBH
  Binding functions in Qt Designerr Mocap 12 1,128 Aug-22-2019, 03:38 PM
Last Post: Denni
  Binding functions to Menus in tkinter?? Mocap 1 477 Jul-23-2019, 01:37 AM
Last Post: Larz60+
  [Tkinter] how to get the entry information using Entry.get() ? SamyPyth 2 1,042 Mar-18-2019, 05:36 PM
Last Post: woooee
  [Kivy] Kivy property (in .kv) loses binding to a variable (in .py) j.crater 3 1,880 Aug-14-2018, 12:37 PM
Last Post: buran

Forum Jump:

Users browsing this thread: 1 Guest(s)