Disable Window Resizing

4,482 views
Skip to first unread message

Syn

unread,
Nov 11, 2012, 7:27:34 PM11/11/12
to kivy-...@googlegroups.com
Is there a way in Kivy to stop the ability to resize the window? I do not believe this feature has been implemented as I cannot find any documentation however I am checking just to be certain.

Gabriel Pettier

unread,
Nov 11, 2012, 7:29:44 PM11/11/12
to kivy-...@googlegroups.com
http://kivy.org/docs/api-kivy.config.html
resizable: (0, 1)

in the graphics section, may be what you want.
> --
>
>


Syn

unread,
Nov 11, 2012, 7:44:41 PM11/11/12
to kivy-...@googlegroups.com
Ah, Yes thanks,

This is the code I am using
from kivy.config import Config
Config.set('graphics','resizable',0)

Even with this code, the window will still be resizable 
However it is interesting that, the window becomes non-resizable after I resize it the first time.

Do you know how this can be fixed? It looks like I may have to 'force' a resize somehow.

Gabriel Pettier

unread,
Nov 11, 2012, 7:49:48 PM11/11/12
to kivy-...@googlegroups.com

If you set the config like this it's too late, the window have been created already, you need to use the config file, or look how the code does it.

--
 
 

skeezix

unread,
Nov 11, 2012, 9:38:52 PM11/11/12
to kivy-...@googlegroups.com
On Sun, 11 Nov 2012, Syn wrote:

# Ah, Yes thanks,
#
# This is the code I am using
# from kivy.config import Config
# Config.set('graphics','resizable',0)
#
# Even with this code, the window will still be resizable 
# However it is interesting that, the window becomes non-resizable after I resize it the first time.
#
# Do you know how this can be fixed? It looks like I may have to 'force' a resize somehow.

This is one of those 'gotchas' for Kivy; the whole 'config' class
is rendered useless from the application side due to how it works.

Perhaps we can add the below clip to the documentation, since I'm
sure it trips up a lot of people (ie: a number of things trip you up when
you first join kivy-land :)

- user-wide config file (not per-app) is not what you would expect
- config settings that are taken from the file and Config.set...
doesn't work.. gotcha!
- command line processing is also neutered, with no Kivy-friendly
way to extend it .. Kivy expects to manage args, and only the ones it
wants. (In a cross platform toolkit, this is pretty strange.. it shows the
tablet-centric origins of the framework.)

.. but you can work around all this, easily.

(we should patch Kivy really.. add a few flags to let command line
override config settings, and command line extensions for apps.. not hard
really.)

- first, you can take command line arguments; just remove them
from argv[] before kivy sees them, or it will complain and bail out; or
reset them if you're done..

- second, as soon as kivy gets pulled in at all, it'll eat up that
config file, rather than later; so you need to override it right away,
before anything else, before your kivy-app starts

This works:

sys.argv = [ sys.argv[0] ] # so we can have command line
import kivy
kivy.require('1.4.0')

# override config values, no easy way to do it :/
kivy.config.Config.set ( 'graphics', 'width', state.window_width )
kivy.config.Config.set ( 'graphics', 'height', state.window_height )

from kivy.app import App
.. etc ..

jeff

--
If everyone would put barbecue sauce on their food, there would be no war.

Gabriel Pettier

unread,
Nov 12, 2012, 4:42:22 AM11/12/12
to kivy-...@googlegroups.com
Sorry, i was wrong, you can do
from kivy.config import Config
do the changes in config and then import the rest of kivy, it should
work.

Le lun. 12 nov. 2012 01:49:48 CET, Gabriel Pettier a écrit :
> If you set the config like this it's too late, the window have been
> created already, you need to use the config file, or look how the code
> does it.
>
> Le 12 nov. 2012 01:44, "Syn" <lostpu...@hotmail.com
> <mailto:lostpu...@hotmail.com>> a écrit :

Syn

unread,
Nov 12, 2012, 7:04:38 AM11/12/12
to kivy-...@googlegroups.com
Nice, Thanks, Works very well.

erm...@gmail.com

unread,
Jul 15, 2016, 8:20:16 PM7/15/16
to Kivy users support
In my personal case, i just added the resizable order before the size properties:

Config.set('graphics','resizable', True)
Window.size = (300, 600)
Window.size = (300, 600)

The nice part, is that without it sometimes did worked, sometimes don't but now it works always.

ky...@prouty.io

unread,
May 16, 2017, 6:49:00 PM5/16/17
to kivy-...@googlegroups.com

This is how I did it with Kivy 1.10.0

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


from kivy.app import App
...
...


class MyApp(App):
   
def build(self):
       
Window.size = (1280,1024)

Reply all
Reply to author
Forward
0 new messages