Last active
August 23, 2024 23:29
-
-
Save gottadiveintopython/c59044b578aaac4eb8b4193716d8421b to your computer and use it in GitHub Desktop.
Listing all icons available on KivyMD. You can easily see the name of an icon by pressing it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ''' | |
| pip install kivy kivymd | |
| ''' | |
| from kivy.lang import Builder | |
| from kivy.properties import StringProperty | |
| from kivymd.app import MDApp | |
| from kivymd.uix.label import MDLabel | |
| from kivymd.uix.snackbar.snackbar import MDSnackbar | |
| KV_CODE = ''' | |
| #:import md_icons kivymd.icon_definitions.md_icons | |
| #:set FONT_SIZE 64 | |
| RecycleView: | |
| viewclass: 'Item' | |
| data: | |
| [{ | |
| 'font_style': 'Icon', | |
| 'text': value, | |
| 'icon_name': key, | |
| 'halign': 'center', | |
| 'font_size': FONT_SIZE, | |
| } for key, value in md_icons.items()] | |
| RecycleGridLayout: | |
| cols: root.width // FONT_SIZE | |
| size_hint_y: None | |
| height: self.minimum_height | |
| default_size: FONT_SIZE, FONT_SIZE | |
| default_size_hint: None, None | |
| ''' | |
| class Item(MDLabel): | |
| icon_name = StringProperty() | |
| def on_touch_down(self, touch): | |
| if self.collide_point(*touch.opos): | |
| MDSnackbar(MDLabel(text=self.icon_name), duration=0.5).open() | |
| class ListingAllIconsApp(MDApp): | |
| def build(self): | |
| return Builder.load_string(KV_CODE) | |
| if __name__ == '__main__': | |
| ListingAllIconsApp().run() |
Author
I'll fix it later, 謝謝你!
I'll fix it later, 謝謝你!
Thank you for the awesome tool btw.
show() is not available with snackbar anymore, currently is open(). Anyway thanks for great tool
Author
@LiamFrance Fixed. Thanks.
Hi, this is a useful piece of code !
To make it work with more recent kivy :
from kivymd.uix.snackbar.snackbar import MDSnackbar
and
MDSnackbar(MDLabel(text=self.icon_name), duration=0.5).open()
Author
@brrrrice Thanks.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Kivymd seen some updates, inorder for this to work, please do the below:
Small changes to import
from kivymd.uix.label import MDLabel
from kivymd.uix.snackbar import Snackbar
Add this to import:
from kivymd.app import MDApp
change line 39 - 40 to below:
class ListAllIconsApp(MDApp):