0
I am developing a program in Python and use Tkinter to create a screen as below:
import tkinter as tk
def on_closing():
cpos = str(root.winfo_rootx()) + '+' + str(root.winfo_rooty())
# salvo o cpos em arquivo com as coordenadas
root.destroy()
if __name__ == '__main__':
root = tk.Tk()
root.title("teste")
cpos = '0+0'
#tratamentos para carregar o arquivo com as coordenadas
# larg x alt + x coord + y coord
root.geometry("250x500+"+cpos)
root.protocol("WM_DELETE_WINDOW", on_closing)
root.mainloop()
I can save, recover and use the saved position again. But this position always seems a difference of a few pixels, IE, I can never make the screen always open in the same place. I do not know if the problem is at the time to save the position or use again in .geometry. Any tips? Thank you!!
Hi Maciel, in your example the positioning of the screen will always be the same. What I need is to return to the last position of the screen on which the program was before it was closed. As I said, saving and restoring information is not the problem, but rather the return to. Geometry at position x and y. Always gets a few pixels apart. Thank you
– gcornelli