

#Tkinter winfo screen width update
My_w.geometry(d) # update the new width and heightī1=tk.Button(my_w,text='zoom ++ ',command=lambda:my_resize('increase'))ī2=tk.Button(my_w,text='zoom - ',command=lambda:my_resize('decrease'))ī3=tk.Button(my_w,text='Full Screen',command=lambda:my_w. #my_w.maxsize(320,220) # (maximum ) width, ( maximum) height #my_w.minsize(280, 180) # (minimum ) Width, ( minimum ) height My_w.geometry(v_dim) # Size of the window In the script below some lines are commented to remove the restrictions. We have to update the data to integer by using int() while using any other type of variable.ĭ=str(int(width/2))+"x"+str(int(height/2)) My_w.maxsize(320,220) # (maximum ) width, ( maximum) height My_w.minsize(280, 180) # (minimum ) Width, ( minimum ) height These are the end limits for our height width for expansion and contraction of the window. We can restrict the height and width of the window by using minsize() and maxsize(). The first half of the geometry string is the windows width and height excluding the. We used the click event of button to call a function my_resize() and inside it change the width and height of parent window. You set the windows dimensions and the location with the geometry method. Python3 from tkinter import from tkinter. We can place buttons in our window to zoom in or zoom out the parent window. winfoscreenheight () // Returns screen height in pixels winfoscreenmmheight () // Returns screen height in mm winfoscreenwidth () // Returns screen width in pixels winfoscreenmmwidth () // Returns screen width in mm Code 1: Getting height and width in pixels. We can increase or decrease the width, height from inside the window by managing the geometry() option. Values for this option are normal ( default value ), iconic, withdrawn, or zoomed my_w.state('zoomed') Zooming the parent window
#Tkinter winfo screen width full
We can only allow horizontally resizing the window.īy managing the state method we can maximize the window to full screen. The natural size is the minimal size needed to display the widget's contents, including padding, borders, etc. Return the 'natural' height (width) for self. Try using 'winforeqheight (), winforeqwidth ()'. My_w.resizable(width=0,height=0) # size change Not allowed Previous message: Tkinter-discuss winfowidth problem. By default width and height values are 1 ( True ). We can prevent this by using resizable() option. By holding and dragging the edges we can resize the window.

There is a button at the top bar for the user to resize the parent window. Our parent window is referred as my_w in all our examples below. Tkinter window geometry to manage height width and zoom out using state and resizable() option
