application and component templates

84 views
Skip to first unread message

Tomek CEDRO

unread,
Aug 12, 2022, 10:21:08 PM8/12/22
to kivy-...@googlegroups.com
Hello world :-)

I would like my application to have switchable templates at runtime,
that is components colors maybe even their images etc.

Should I use Python code with separate template modules that would
declare components for KV files, or use KV language and use Dynamic
Classes (I know that Templates class is obsolete).

Which approach would be faster?

Are there any examples on best practice on how to change a UI template
at runtime?

Any hints appreciated :-)
Tomek

--
CeDeROM, SQ7MHZ, http://www.tomek.cedro.info

Tomek CEDRO

unread,
Aug 12, 2022, 10:34:51 PM8/12/22
to kivy-...@googlegroups.com
I think using KV and Dynamic Classes would be more convenient?

But how can I import conditionally a KV file with a template defines
based on a program settings?

Lets say I have two templates 'white' and 'dark', I guess I need to
create 'white.kv' and 'dark.kv' files with different definitions.

Lets say I am using kivy configuration to store a theme selection.

How can I import 'white.kv' when 'white' theme is selected and
'dark.kv' when 'dark' theme is selected?

Tomek CEDRO

unread,
Aug 13, 2022, 7:45:27 AM8/13/22
to kivy-...@googlegroups.com
Okay, so I did a Screen Design in KV and Theme Management in Python,
so far so good :-)

Screens Design in KV because it is trivial to read/write and a lot
faster to (re)design!

Theme Management in Python to save memory and time. I have only a list
of themes exported from my top `themes` module. Only single theme (not
all themes / modules) is then loaded by name at runtime that is then
attached to `app.theme` so it is then available in KV. Whenever theme
change occurs, only `app.theme` is updated that propagates to all
components in KV.

Working with Python and Kivy is a real pleasue, its clean, elegant,
and made the way it is supposed to be done :-) I cannot believe I have
wasted so much time for JS frameworks o_O

KIVY ROX! =)

Elliot Garbus

unread,
Aug 13, 2022, 8:39:23 AM8/13/22
to kivy-...@googlegroups.com

Glad to see you have things working. 

 

KIvyMD is a project that builds on top of kivy and provides an implementation of Googles Material Design, using kivy.  It provides a theming capability.  You might be interested is reviewing the KivyMD theme implementation.

https://kivymd.readthedocs.io/en/latest/themes/theming/

https://github.com/kivymd/KivyMD/blob/master/kivymd/theming.py

 

Just for reference, some kivy resources:

The kv for kivy’s widgets: https://github.com/kivy/kivy/blob/master/kivy/data/style.kv

Kivy default theme images in a single .png for use with an atlas: https://github.com/kivy/kivy/blob/master/kivy/data/images/defaulttheme-0.png

Kivy default theme inages in separate .png files: https://github.com/kivy/kivy/tree/master/kivy/tools/theming/defaulttheme

--

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.

To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAFYkXj%3Dv6R76epwj2S8YtPV1sm23P97_f9K2x1ZHBh7J%2BepGzg%40mail.gmail.com.

 

Tomek CEDRO

unread,
Aug 13, 2022, 9:38:14 AM8/13/22
to kivy-...@googlegroups.com
On Sat, Aug 13, 2022 at 2:39 PM Elliot Garbus wrote:
>
> Glad to see you have things working.
>
> KIvyMD is a project that builds on top of kivy and provides an implementation of Googles Material Design, using kivy. It provides a theming capability. You might be interested is reviewing the KivyMD theme implementation.
>
> https://kivymd.readthedocs.io/en/latest/themes/theming/
>
> https://github.com/kivymd/KivyMD/blob/master/kivymd/theming.py
>
> Just for reference, some kivy resources:
>
> The kv for kivy’s widgets: https://github.com/kivy/kivy/blob/master/kivy/data/style.kv
>
> Kivy default theme images in a single .png for use with an atlas: https://github.com/kivy/kivy/blob/master/kivy/data/images/defaulttheme-0.png
>
> Kivy default theme inages in separate .png files: https://github.com/kivy/kivy/tree/master/kivy/tools/theming/defaulttheme

Whoah! Thank You Elliot!! This KivyMD is exactly what I need.. results
are beautiful :-)

Do you know the memory and time burden of that library?

Will it increase noticeably resulting program size and slow it down?

Are there any benchmarks available?

Are there any known big problems with running on Android / iOS ?

Thanks!! :-)
Tomek

Elliot Garbus

unread,
Aug 13, 2022, 9:43:51 AM8/13/22
to kivy-...@googlegroups.com

KivyMD is really just customizing kivy.  I would not expect any significant impact in performance or size.

It has been used by many on mobile platforms.

--

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.

Tomek CEDRO

unread,
Aug 13, 2022, 9:52:10 AM8/13/22
to kivy-...@googlegroups.com
On Sat, Aug 13, 2022 at 3:43 PM Elliot Garbus wrote:
>
> KivyMD is really just customizing kivy. I would not expect any significant impact in performance or size.
>
> It has been used by many on mobile platforms.

So far so good, only good options show up :-)

TANK U SIR! =)
Reply all
Reply to author
Forward
0 new messages