Python Forum
[Tkinter] Python 3.5 tk fullscreen
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Python 3.5 tk fullscreen
#1
Hi fellow pythons,
I am new here and have a small problem

I have created a program but want to run it on a different resolution screen.
I started working from 1024 x 700.
I have photos and buttons and text on the screen.
Designed with place (x = .., y = ..)

My windows start with the following:

root1 = Toplevel ()
           
root1.attributes ('- fullscreen', True)
root1.title ("start")
root1.overrideredirect (True)
root1.configure (background = "# B22222")
root1.configure (borderwidth = 6, relief = "ridge")

ws = root.winfo_screenwidth ()
hs = root.winfo_screenheight ()
And use this as with label and buttons

labelback = Label (root1, image = back) .place (x = ws / 2-512, y = hs / 5)
label language = Label (root1, text = (store.kjt), bd = 3, relief = "sunken", font = "impact 22", width = 30, height = 1, bg =    "#FFF9F2"). place (x = ws / 2-170, y = hs / 5-15)
Because the code is quite large and contains many pictures, I hope that it can also form an image of how I wrote it.
But at the screen 1920 x 1040 I get a big border around the background, there is a way to zoom in the entire image incl buttons and text. Without having to make a separate image for each type of resolution.
I have already searched for zoom but that does not work.
I also used subsample, so I have to make a separate version for each type of screen.
I have read quite a bit on the form but not what helps me unfortunately.
I hope that a few clever heads can help me with this

thanks
I'm not very good in English hopefully google translation has translated it right for me.
Reply
#2
on windows, you can use the following to set screen size:
full width and height, or a percentage of same:
tested on Linux, should be fine on windows
import tkinter as tk


class MyGui(tk.Frame):
    def __init__(self, parent=None):
        tk.Frame.__init__(self, parent)
        # Following sets width to 60% of full screen , eliminate the * .6 for full
        self.width = int(self.winfo_screenwidth() * .6)
        # Following sets height to 60% of full screen , eliminate the * .6 for full
        self.height = int(self.winfo_screenheight() * .6)
        self.configure(width=self.width, height=self.height)
        self.grid()


def main():
    root = tk.Tk()
    MyGui(parent=root)
    root.mainloop()


if __name__ == '__main__':
    main()
Reply
#3
To work with different monitor resolution under place manager, you have to use relx, rely, relwidth, relheight options instead of x, y, width, height. Also the root geometry() has to be set using the relative value as Larz60+ suggested in his reply.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to check if window is fullscreen or not delphinis 2 3,742 Aug-01-2020, 01:21 PM
Last Post: delphinis
  Background Image FullScreen oguzcan 5 8,448 Apr-26-2020, 10:13 PM
Last Post: Larz60+
  [pyglet] Why is screen blank when displaying a gif when setting fullscreen = True ? Huudzz 0 2,251 Oct-25-2019, 06:13 PM
Last Post: Huudzz
  [Tkinter] Multiple frames with tkinter - How to make them run on fullscreen mode eabs86 3 18,207 Sep-20-2018, 01:27 AM
Last Post: eabs86

Forum Jump:

User Panel Messages

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