I have written a program and want to make it executable usingpyinstaller
, but unfortunately, when starting the program, some window sizes are incorrect, because I set the window geometry like this:self.geometry('+{}+{}'.format(w, h))
In this example, the main thing is that the dimensions of the window are set automatically.
When I run the program through IDEL, everything is displayed correctly, but when I run the .exe file, the dimensions move out. For everything to be fine, I need to know the automatic sizes given to the window. How can this be implemented?
-
Answer # 1
-
Answer # 2
You can stretch an invisible widget to fill the screen and measure its dimensions using winfo_height and winfo_width. Here is an example for a button:
import tkinter as tk def func(): x= button_place.winfo_width() y= button_place.winfo_height() print(x, y) root= tk.Tk() root.geometry('600x500') button_place= tk.Button(root, text='', font='Times 15', command=func) button_place.place(w=600, h=500) root.mainloop()
But it's usually used to size widgets. To determine the screen, you just need
root.geometry()
. The first example was given just for additional information, you may need -
Answer # 3
Use the method
geometry()
classtkinter.Tk()
, example:import tkinter as tk root= tk.Tk() print(root.geometry())
Everything works, just add brackets after geometry, otherwise it gives nonsense
DGDays2022-01-23 10:45:14
- python : How to create a large text input field?
- python : How to keep the scale of buttons, text, etc in tkinter?
- python : Opening photo for background doesn't work
- Python Tkinter not seeing 'TimePL' instance of Label widget
- python : How to create a window in the game for example (dota2)
- python : Error with matrix multiplication. Numpy
- Can't uninstall/install Python
- python : Why does list.remove() incorrectly remove elements in a loop?
- Loading bar in Python 3.x
It's much simpler, use the wm_maxsize() method
welcome to This Club in Russian! please try to leave a little more detailed answers. You can add to your answer by clicking edit.
aleksandr barakin2022-01-22 21:17:49