Python Forum
[Tkinter] identify window
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] identify window
#1
Hi, i am in a spot of trouble trying to do this:
I want to create a number of (tkinter) windows dynamically and simultaneously (between 2 and 10).
Each window has a button, when pressed, destroys the window.
The purpose is a selection process, because the windows will show images of things the user must choose between.

In pinciple this is not so difficult, just repeat 10 times win1 ... win10:
win1 = Tk()
win1.title('image x')
geo = '1000x1000+0+0'
win1.geometry(geo)
Button(win1, text='Select', command =  WIN1).pack(side = BOTTOM) -> the "def WIN1:" has code win1.destroy and do some other stuff.
................
But in python country, you would want to do this more compact, in a loop !, like so:
winList = ['winA', 'winB', 'winC', 'winD', 'winE', 'winF', 'winG', 'winH', 'winI', 'winJ']
for item in winList:
    item = Tk()
    geo = '1000x1000+0+0'
    item.geometry(geo)
    Button(item, text = 'Delete',command= lambda: WIN(item)).pack(side = BOTTOM)
Here lies the problem, because i'm having trouble in the command parameter to point to one def clause, whilst identifying the window to delete.
Help?
Paul
Reply


Messages In This Thread
identify window - by DPaul - Feb-16-2019, 08:46 AM
RE: identify window - by Larz60+ - Feb-16-2019, 05:19 PM
RE: identify window - by woooee - Feb-16-2019, 07:14 PM
RE: identify window - by DPaul - Feb-17-2019, 07:44 AM
RE: identify window - by Larz60+ - Feb-17-2019, 04:53 PM
RE: identify window - by DPaul - Feb-18-2019, 07:15 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Interaction between Matplotlib window, Python prompt and TKinter window NorbertMoussy 3 545 Mar-17-2024, 09:37 AM
Last Post: deanhystad
  tkinter window and turtle window error 1885 3 6,753 Nov-02-2019, 12:18 PM
Last Post: 1885
  update a variable in parent window after closing its toplevel window gray 5 9,131 Mar-20-2017, 10:35 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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