By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,069 Members | 1,249 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,069 IT Pros & Developers. It's quick & easy.

KivyMd bottom sheet. ( I would like to know how to display a different screen when I

P: 1
I would like you to help me to complete one of my class projects. I would like to know how to display a different screen when I click on one of the Items. Thanks for helping me. My code is there :



Expand|Select|Wrap|Line Numbers
  1. from kivy.lang import Builder
  2. from kivymd.toast import toast
  3. from kivymd.uix.bottomsheet import MDListBottomSheet
  4. from kivymd.app import MDApp
  5. KV = '''
  6. Screen:
  7.     MDToolbar:
  8.         title: "Example BottomSheet"
  9.         pos_hint: {"top": 1}
  10.         elevation: 10
  11.     MDRaisedButton:
  12.         text: "Open list bottom sheet"
  13.         on_release: app.show_example_list_bottom_sheet()
  14.         pos_hint: {"center_x": .5, "center_y": .5}
  15. '''
  16.  
  17. Items = "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"
  18. class Example(MDApp):
  19.     def build(self):
  20.         return Builder.load_string(KV)
  21.     def callback_for_menu_items(self, *args):
  22.         toast(args[0])
  23.     def show_example_list_bottom_sheet(self):
  24.         bottom_sheet_menu = MDListBottomSheet()
  25.         for i in Items:
  26.             bottom_sheet_menu.add_item(
  27.                 f" {i}",
  28.                 lambda x, y=i: self.callback_for_menu_items(
  29.                     f" {y}"
  30.                 ),
  31.             )
  32.         bottom_sheet_menu.open()
  33.  
  34. Example().run()


Thank you very much for helping me.
Jun 3 '20 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.