I'm creating a second gui when I click a button and am then destroying my original gui.
I would like to create this new gui in the same position as the original gui.
Is there a function that will let me get the geometry or position of the original gui before I destroy it?
Call the geometry method of any root or toplevel window. It will return a string of the form "widthxheight+x+y".
Related
I'm trying to open a treeview window by clicking a button but it isn't working
[Code](https://i.stack.imgur.com/TorXR.png)
Move next_cmd() function inside buyerprop() function.
CleanMyMacX image
As you can see, some of the buttons are outside of the window, and the window's title isn't visible. I am wondering if this is possible to do in python tkinter, and if so, how to do it.
Thanks!
I'm just getting started with tkinter, so the answer to this question may be rather obvious to those with more experience... My Python program defines a root window in the main code, which includes several label widgets:
for i in range(0,20):
line.append(ttk.Label(mainframe, text=""))
line[i].grid(column=1, row=i, sticky=W)
It also has a few menu items, one of which launches a graphical subprogram that operates in its own (pygame) window. I would like to modify the labels in the main window based on events in the subprogram, which I try using:
line[i].configure(text=s)
Problem is, these new label values don't show up until the subprogram completes and control returns to the main window. Is there a way around this?
I have a tkinter GUI that, when opened, is an empty widget with a menu bar on top. Clicking on the options on the menu causes for text boxes, more buttons and more menus to appear in the widget. My problem is that everything overlaps.
I need an easy way to delete everything that is currently there, like a "clear window" option.
I've tried packing everything into a frame and then destroying a frame but, for some reason, it's not working.
Any suggestions?
Ideally, I would make something that checks to see if there is anything (button, text box, menu) in a designated space, and it would delete it all before creating the new widget attributes.
The Problem I was having was fixed by creating a new frame within each function and having the code destroy any previously existing frames with Frame.destroy().
My second problem, where widgets within my frame were not, appearing was being caused by how Tkinter frames automatically resize to fit the original widgets. Therefore, when I added widgets to the frame, the frame remained the size of the first widget and didn't show the new buttons. I used frame.pack_propagate(0) to force the frame to remain the specified size.
I am aiming to change the a part of the Tkinter screen when a button is clicked. Do I have to destroy the screen then redraw it (to create the illusion that only a part is being changed?) Or can I keep the button there and somehow only change one part (like the graphics.) Thanks!
No, you do not have to destroy the screen and redraw it. You can easily insert widgets into the current window when a button is clicked. There's nothing special about being run from a button click -- the code is the same as your initialization code.