G
G
GreenX52021-09-17 15:45:31
Python
GreenX5, 2021-09-17 15:45:31

Is it possible to set properties of a Tkinter Python window with a generator?

Set Tkinter window properties line by line

root=Tk(); 

root.title("Title"); 
root.geometry("300x250"); 

root.mainloop()


But wherever possible I want to shorten the code with generators. How can I write something like this?

[ root.x[1]([x[2]]) for x in  ]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
ScriptKiddo, 2021-09-17
@GreenX5

[getattr(root, attr)(value) for attr, value in [('title', 'Title'), ('geometry', '300x250') ]]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question