Python Forum
How to retreive the grid location of an Entry widget
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to retreive the grid location of an Entry widget
#5
Thank you Larz60,
I tried using the grid_info method and it is still returning row 4 column 1 no matter which entry widget I am entering values.


from tkinter import *
from tkinter import ttk

def set_input(frame,self):
    row = self.grid_info()["row"]
    col = self.grid_info()["column"]
    print("row "+str(row)+", column "+str(col))
    return(True)

mw = Tk()
# 999x999 is size of window, 999+999 is the location of the window
mw.geometry('600x200+400+200')
mw.title("test program")

frame1 = Frame(mw)
frame1.pack(side=TOP)
framebot = Frame(mw)
framebot.pack(side=BOTTOM,fill=X)

field_labels = ["field1","field2","field3"]
values = []
for i in range(0,5):
       values.append([])
       j = 0
       values[i].append(Entry(frame1,validate="focusout",validatecommand=lambda:set_input(frame1,values[i][j])))
       values[i][j].grid(row=i,  column= j)
       j += 1
       values[i].append(ttk.Combobox(frame1,values=field_labels,validate="focusout",validatecommand=lambda:set_input(frame1,values[i][j])))
       values[i][j].grid(row=i,  column= j)

btn = Button(framebot,text='Exit',font=("Times",16),command=mw.quit).pack(side="left")

mw.mainloop()
Reply


Messages In This Thread
RE: How to retreive the grid location of an Entry widget - by kenwatts275 - Apr-24-2020, 06:59 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  ValueError: could not convert string to float: '' fron Entry Widget russellm44 5 988 Mar-06-2024, 08:42 PM
Last Post: russellm44
  [Tkinter] entry widget DPaul 5 1,665 Jul-28-2023, 02:31 PM
Last Post: deanhystad
  Tkinter Exit Code based on Entry Widget Nu2Python 6 3,156 Oct-21-2021, 03:01 PM
Last Post: Nu2Python
  auto-generate code for Entry box location snakes 1 1,961 May-07-2021, 08:30 PM
Last Post: Yoriz
  method to add entries in multi columns entry frames in self widget sudeshna24 2 2,351 Feb-19-2021, 05:24 PM
Last Post: BashBedlam
  Entry Widget issue PA3040 16 7,102 Jan-20-2021, 02:21 PM
Last Post: pitterbrayn
  [Tkinter] password with Entry widget TAREKYANGUI 9 6,219 Sep-24-2020, 05:27 PM
Last Post: TAREKYANGUI
  [Tkinter] Get the last entry in my text widget Pedroski55 3 6,550 Jul-13-2020, 10:34 PM
Last Post: Pedroski55
  Grid data entry problem kenwatts275 3 2,341 Mar-22-2020, 03:13 PM
Last Post: kenwatts275
  POPUP on widget Entry taratata2020 4 3,854 Mar-10-2020, 05:04 PM
Last Post: taratata2020

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020