How to start an App with the window Maximized

6,446 views
Skip to first unread message

happ...@gmail.com

unread,
Feb 17, 2013, 2:33:42 PM2/17/13
to kivy-...@googlegroups.com
Hi everyone,

Can I ask help with this please? I'm figuring out a way to start the screen maximized in a desktop. I'm thinking that the user might get tired of always having to press the maximum window button. One of the solutions in code that I've found is:

from kivy.config import Config
Config.set('graphics', 'width', '1920')
Config.set('graphics', 'height', '1080')

However, this assumes you know the resolution, and even for lower resolution screens the app fills the screen. However with this, if the user clicks the maximize button on a screen with a smaller resolution than 1920x1080 the display will be too large.

Is there a way around this? Maybe:

1. A way in kivy to set the window to maximize? I can't find any, help!
2. In python get the current monitor's resolution? (this can be done by wxpython i think [http://stackoverflow.com/questions/3129322/how-do-i-get-monitor-resolution-in-python])

Thank you very much for any help!

Bernard


Akshay Arora

unread,
Feb 18, 2013, 1:47:46 AM2/18/13
to kivy-...@googlegroups.com
http://kivy.org/docs/api-kivy.config.html#available-configuration-tokens scroll down to  ->graphics ->fullscreen.

Best Regards



--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

happ...@gmail.com

unread,
Feb 18, 2013, 4:35:43 AM2/18/13
to kivy-...@googlegroups.com
Thanks! It works for a fullscreen view, is it possible though if I just want it maximized? I.e. the close, minimize, maximize buttons are still there?

Niko Skrypnik

unread,
Apr 25, 2013, 6:04:30 AM4/25/13
to kivy-...@googlegroups.com
I faced same problem. This works for me:

try: # this is only for pygame window if pygame is avaliable
    import pygame
    pygame.display.init()
    info = pygame.display.Info()
    width, height = info.current_w, info.current_h
    import ipdb; ipdb.set_trace()
    Config.set('graphics', 'width', str(width))
    Config.set('graphics', 'height', str(height))
except:
    pass

But it's very tricky. I hope that there are some more proper way to do it.

понедельник, 18 февраля 2013 г., 11:35:43 UTC+2 пользователь happybeej написал:

Niko Skrypnik

unread,
Apr 25, 2013, 6:05:19 AM4/25/13
to kivy-...@googlegroups.com
Oops, of course using ipdb is not necessary :-)

четверг, 25 апреля 2013 г., 13:04:30 UTC+3 пользователь Niko Skrypnik написал:

Akshay Arora

unread,
Apr 25, 2013, 8:20:21 AM4/25/13
to kivy-...@googlegroups.com
from kivy.app import App
from kivy.config import Config

Config.set('graphics', 'width', str(width))
Config.set('graphics', 'height', str(height))
# doing this before anything else makes sure the window width/height is set
import rest ...

Best Regards

Aaron M. Bond

unread,
Feb 28, 2020, 11:13:42 PM2/28/20
to Kivy users support
For anyone else landing here, the new proper way to to do this is to use the Config setting graphics.window_state.

Per the documentation (https://kivy.org/doc/stable/api-kivy.config.html), any top level application settings should be set before other imports (this breaks PEP 8, so you may see some lint issues, depending on your editor or linter).

At the top of your file containing your __main__function, add this:

from kivy.config import COnfig
Config.set('graphics', 'window_state', 'maximized')
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.

Bekhruz Otaev

unread,
Jun 17, 2021, 8:48:55 PM6/17/21
to Kivy users support
Love this response. Thank you very much. 

A small problem arose when kivy starts window minimized, it consoles out error when you close the screen:
 Traceback (most recent call last):
   File "C:\Users\behru\Desktop\hitaimen2\main_app\main.py", line 501, in <module>        
     mainApp.run()
   File "C:\Users\behru\Desktop\hitaimen2\main_app\.env\lib\site-packages\kivy\app.py", line 950, in run
     runTouchApp()
   File "C:\Users\behru\Desktop\hitaimen2\main_app\.env\lib\site-packages\kivy\base.py", line 584, in runTouchApp
     stopTouchApp()
   File "C:\Users\behru\Desktop\hitaimen2\main_app\.env\lib\site-packages\kivy\base.py", line 625, in stopTouchApp
     EventLoop.close()
   File "C:\Users\behru\Desktop\hitaimen2\main_app\.env\lib\site-packages\kivy\base.py", line 186, in close
     self.stop()
   File "C:\Users\behru\Desktop\hitaimen2\main_app\.env\lib\site-packages\kivy\base.py", line 198, in stop
     provider.stop()
   File "C:\Users\behru\Desktop\hitaimen2\main_app\.env\lib\site-packages\kivy\input\providers\wm_pen.py", line 114, in stop
     SetWindowLong_WndProc_wrapper(self.hwnd, self.old_windProc)
   File "C:\Users\behru\Desktop\hitaimen2\main_app\.env\lib\site-packages\kivy\input\providers\wm_common.py", line 112, in _closure
     oldAddr = func(hWnd, GWL_WNDPROC, cast(wndProc, c_void_p).value)
 ctypes.ArgumentError: argument 3: <class 'TypeError'>: wrong type

Does anyone know why?


Bekhruz Otaev

unread,
Jun 17, 2021, 9:18:43 PM6/17/21
to Kivy users support
Here is the relevant question on stackoverflow: https://stackoverflow.com/q/68028136/13772586

Elliot Garbus

unread,
Jun 17, 2021, 11:46:13 PM6/17/21
to kivy-...@googlegroups.com

Looks like you found a bug.

ElliotG

unread,
Jun 18, 2021, 9:03:03 AM6/18/21
to Kivy users support
Here is a workaround.  I noticed if the Window is allowed to open in its default size, and is then minimized.  There is no error.  This example minimizes the WIndow after it is opened.  You could add a second or 2 and display some info, like a splash screen - and then minimize the window. 

from kivy.app import App
from kivy.uix.button import Button
from kivy.core.window import Window
from kivy.clock import Clock


class TestApp(App):
    def build(self):
        return Button(text='Hello World')

    def on_start(self):
        Clock.schedule_once(self.win_min, 0)  # increase time to create a splash screen effect...

    def win_min(self, dt):
        Window.minimize()


TestApp().run()

Reply all
Reply to author
Forward
0 new messages