Unable to change the size of windowscreen after I changed my computer (in tkinter)

Viewed 22

Yesterday, I bought a new computer which is macOS Monterey version 12.5, and I transferred the code from the old computer to the new computer. However, now I can't change the size of the window screen on the new computer. It worked on the old computer. I really appreciate it if you can teach me some solutions to this.

Here is my code:

import sys
import pprint

sys.path.append("/opt/anaconda3/lib/python3.8/site-packages")



from pathlib import Path

from tkinter import Tk, Canvas, Entry, Text, Button, PhotoImage,Label


from multiprocessing import Process


OUTPUT_PATH = Path(__file__).parent
ASSETS_PATH = OUTPUT_PATH / Path("./assets")






window = Tk()

def relative_to_assets(path: str) -> Path:
    return ASSETS_PATH / Path(path)

window.geometry("703x981")
window.configure(bg = "#FFFFFF")



canvas = Canvas(
    window,
    bg = "#FFFFFF",
    height = 981,
    width = 703,
    bd = 0,
    highlightthickness = 0,
    relief = "ridge"
)




window.resizable(False, False)
window.mainloop()

enter image description here

I want to generate the windowscreen, size of ("703x981"), but I get this small window screen. This windowscreen didn't change its size even if I changed the value.

1 Answers

What is the display resolution of your Computer? It could be that your old computer's resolution is lower than the new one. The window appears smaller when you have a high resolution because the geometry method excepts the value in pixels. I guess you should double the values inside the geometry function.

If it doesn't work when changing the values, use window.winfo_width() and window.winfo_height() to check if geometry function actually worked.

I hope this answers your question.

Related