Home > Back-end >  Why are my winfo_screenmmwidth() and winfo_screenmmheight() are getting some weird numbers? Tkinter
Why are my winfo_screenmmwidth() and winfo_screenmmheight() are getting some weird numbers? Tkinter

Time:07-23

Why are ramy winfo_screenmmwidth() and winfo_screenmmheight() are getting some weird numbers?

I had to multiply my width by 3.78 and height by 3.779 This is my code:

from tkinter import *
from PIL import ImageTk,Image


root = Tk()
root.title("My Program")

# Designate the height and width of our app
app_width = 500
app_height = 500

screen_width = root.winfo_screenmmwidth()
screen_height = root.winfo_screenmmheight()


dpi = root.winfo_fpixels('1i')

real_width = int(screen_width * 3.78)
real_height = int(screen_height * 3.779)

root.geometry(f"{app_width}x{app_height} {1000} {200}")

mylbl = Label(root,text=f"{real_width}x{real_height}")
mylbl.pack()





root.mainloop()

When I don't do the weird multiplication thing, I get 508x286 instead of 1920x1080

What is causing that?

CodePudding user response:

In order to it to work, you have to change

winfo_screenmmwidth()

into:

winfo_screenwidth()

and the same thing for the height. Otherwise, it measures that in millimeters.

P.S.: ty to the people in the comments

  • Related