Python Forum

Full Version: Python 3.5 tk fullscreen
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
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()
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.