Change Icon on a left_action_items

126 views
Skip to first unread message

Gibbsy FPV

unread,
May 16, 2022, 6:23:45 AM5/16/22
to Kivy users support
Hi All

Does anyone know if you are able to change left_action_items icons on kivymd toolbar with python. I looking to switch the icon between play and pause/stop when my function is run.

Thanks
Andrew

Elliot Garbus

unread,
May 16, 2022, 10:21:20 AM5/16/22
to kivy-...@googlegroups.com

Use an id to address the Toolbar widget, and change the value of the list.  Here is an example:

 

from kivy.lang import Builder
from kivymd.app import MDApp

KV =
'''
MDBoxLayout:
    orientation: 'vertical'
    BoxLayout
        Button:
            text: 'Play'
            on_release:
                toolbar.left_action_items = [["play", lambda x: x]]
        Button:
            text: 'Pause'
            on_release:
                toolbar.left_action_items = [["pause", lambda x: x]]
       
    # Will always be at the bottom of the screen.
    MDBottomAppBar:

        MDToolbar:
            id: toolbar
            title: "Title"
            icon: "git"
            type: "bottom"
            left_action_items: [["stop", lambda x: x]]
           
'''


class Test(MDApp):
   
def build(self):
       
return Builder.load_string(KV)


Test().run()

--
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/5b7acf0d-2187-44d2-af8d-404b383c12efn%40googlegroups.com.

 

Reply all
Reply to author
Forward
0 new messages