Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tkinter guide?
#11
Hi! I saw you wanted to resize the tkinter gui window to full screen so I came here to help.
It's very simple, it only takes one line!
First you need to see how wide and tall your computer is. Ex: 1000x900
Then you put it into a function, here is the code.
Let's use the example I just said(1000x900)
The code would be: win.geometry("1000x900")
Hope this helps! If you need more understanding on tkinter or you would like more help on anything, contact me! Have a good day Wink
Reply
#12
That is not a good way to make a full screen window. A better way is to use .attribute()
window.attributes('-fullscreen',True)
Or if you want to use geometry, use "winfo_screenwidth" and "winfo_screenheight" to get the screen dimensions.
width= window.winfo_screenwidth() 
height= window.winfo_screenheight()
window.geometry(f'{width}x{height}')
The problem with hardcoding a number is it will not work on different resolution monitors.
Reply
#13
you can get current screen info for all monitors
you must install screeninfo if not already installed: pip install screeninfo
then run:
import screeninfo


for n, monitor in enumerate(screeninfo.get_monitors()):
    print(monitor)
    print(f"\nMonitor {n}:")
    print(f"    width pixels: {monitor.width}")
    print(f"    height pixels: {monitor.height}")
    print(f"    width mm: {monitor.width_mm}")
    print(f"    height mm: {monitor.height_mm}")
    print(f"    monitor name: {monitor.name}")
Typical output
Output:
Monitor 0: width pixels: 1920 height pixels: 1080 width mm: 598 height mm: 336 monitor name: DVI-I-1
Reply
#14
Then what would be the point of using it as a function?
Reply
#15
Quote:Then what would be the point of using it as a function?
Not sure what you are responding to. If it is my post about why you can't make a window full screen by setting geometry, the reason why is hard coding numbers like 1000x900 only make the window full screen if the display size is 1000x900. If your display is smaller, part of the window will be hidden. If the display is larger, the window will not fill the screen.

.geometry() will work, but you should ask Python for the screen dimensions if you want your window to fill the screen regardless of what computer you are using.
Reply
#16
you can get the screen size by using the method I show in post # 13.
Then use that in your geometry statement which is safe to use, as it code will adjust for the display being used.
Reply
#17
if you still want to know how to open a window in full screen:

wm.attributes("-fullscreen",1)

This site looks good for total Tkinter beginners:
https://mycodenotein.netlify.app/src/tkinter
It is in plain language for normal people.

You could also take a look at my Tk Assistant program
if you want, it might help:
https://stevepython.wordpress.com/2021/0...ant-v4-01/
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Guide Tinker tranduc 1 1,964 May-06-2020, 08:51 AM
Last Post: pyzyx3qwerty
  a GUI beginner guide Skaperen 8 4,628 Aug-12-2018, 08:31 PM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020