0

I want to set my KivyMD application open as a maximized window and it should be opened in in the middle of the screen. And should not be possible to resize the window. I have written a code to disable resizing.

from kivy.config import Config
Config.set('graphics', 'resizable', 0)

But I haven't an idea to open the application as maximized window. So, how to do that? Please help me.

4

1 回答 1

2

A solution to this problem is to first get your screen size using the pyautogui module, and then set the window size to it, something like this:

import pyautogui 
# This module comes with Windows' standard Python package
# You might wanna install it manually if you are not using Windows

width, height = pyautogui.size()
Config.set('graphics', 'width', str(width))
Config.set('graphics', 'height', str(height))

Edit: So basically I was messing around trying to find an answer for another question, and then I figured out how to maximize the window while still having the titlebar, exactly what the author wanted:

from kivy.core.window import Window

Window.maximize()
于 2021-09-18T07:43:14.450 回答