def show_about_dialog(self): """ Shows the About dialog box""" content = MDLabel( font_style='Body1', markup=True, theme_text_color='Secondary', text="Find Anything is developed by Lawrence Ephrim.\n\n" "You can find me at:\n" "-Facebook:\n" " [color=#31C8EB][u][ref=https://www.facebook.com/profile.php?id=100004673359024]https://www.facebook.com/profile.php?id=100004673359024\n[/ref][/u][/color]" "-Telegram:\n" " [color=#31C8EB][u][ref=t.me/ephrimlawrence]t.me/ephrimlawrence\n[/ref][/u][/color]" "-Email:\n" " [color=#31C8EB][u][email protected]\n\n[/u][/color]" "© Copyright All Rights Reserved", size_hint_y=None, valign='top') content.bind(texture_size=content.setter('size')) content.bind(on_ref_press=self.open_link) self.dialog = MDDialog(title="About", content=content, size_hint=(.8, None), height=self.root.height - dp( (self.root.height / 3)), auto_dismiss=False) self.dialog.add_action_button("Dismiss", action=lambda *x: self.dialog.dismiss()) self.dialog.open()
def database_creations(self): self.conn = sqlite3.connect('SCHOOL.db') self.c = self.conn.cursor() # creating student self.c.execute('''CREATE TABLE STUDENTS( STUDENT_ID INT NOT NULL, STUDENT_NAME VARCHAR (250), STUDENT_COURSE VARCHAR (250), STUDENT_CLASS_NAME VARCHAR (250), PRIMARY KEY (STUDENT_ID));''') self.conn.commit() content = MDLabel(font_style='Body1', theme_text_color='Secondary', text="T" "PERFECT TABLE CREATED!", size_hint_y=None, valign='top') content.bind(texture_size=content.setter('size')) self.dialog = MDDialog(title="SUCCESSFUL", content=content, size_hint=(.8, None), height=dp(200), auto_dismiss=False) self.dialog.add_action_button("Dismiss", action=lambda *x: self.dialog.dismiss()) self.dialog.open() print("committed")
def show_example_long_dialog(self): content = MDLabel(font_style='Body1', theme_text_color='Secondary', text="Lorem ipsum dolor sit amet, consectetur " "adipiscing elit, sed do eiusmod tempor " "incididunt ut labore et dolore magna aliqua. " "Ut enim ad minim veniam, quis nostrud " "exercitation ullamco laboris nisi ut aliquip " "ex ea commodo consequat. Duis aute irure " "dolor in reprehenderit in voluptate velit " "esse cillum dolore eu fugiat nulla pariatur. " "Excepteur sint occaecat cupidatat non " "proident, sunt in culpa qui officia deserunt " "mollit anim id est laborum.", size_hint_y=None, valign='top') content.bind(texture_size=content.setter('size')) self.dialog = MDDialog(title="This is a long test dialog", content=content, size_hint=(.8, None), height=dp(200), auto_dismiss=False) self.dialog.add_action_button("Dismiss", action=lambda *x: self.dialog.dismiss()) self.dialog.open()
def on_noticed(self, user, channel, action): user = user.split('!')[0] if user == 'ChanServ': content = MDLabel(font_style='Body1', theme_text_color='Secondary', text=action, size_hint_y=None, valign='top') content.bind(texture_size=content.setter('size')) self.dialog = MDDialog(title="Notice: {}".format(user), content=content, size_hint=(.8, None), height=dp(200), auto_dismiss=False) self.dialog.add_action_button( "Dismiss", action=lambda *x: self.dialog.dismiss()) self.dialog.open() else: self.msg_list.add_widget( MultiLineListItem( text="[b][color=F44336]" + user + "[/color][/b] " + action, font_style='Subhead', )) self.msg_list.parent.scroll_to(self.msg_list.children[0]) Logger.info("IRC NOTICED: <%s> %s %s" % (user, channel, action))
def search(self, b_name, direction='left'): self.b_name = b_name url = api + b_name.replace(' ', '+') + maxres + nextpage + str( self.page) try: j = urllib.request.urlopen(url).read() result = json.loads(j) self.result = result['items'] except urllib.error.URLError: print('Connect to internet') MDDialog(title='No Internet', content=MDLabel( text='Please connect to the internet and try again', font_style='Subhead', theme_text_color='Primary'), size_hint=(0.5, 0.3)).open() except KeyError: MDDialog(title='Search unsuccessful', content=MDLabel( text='The book you searched does not seem to appear.', font_style='Subhead', theme_text_color='Primary'), size_hint=(0.5, 0.3)).open() else: self.transition.direction = direction self.current = 'loading' self.current = 'screen2' time.sleep(2)
def change_data(self): con = sqlite3.connect(self.mainwid.DB_PATH) cursor = con.cursor() d1 = self.ids.dono.text d2 = self.ids.marca.text d3 = self.ids.defeito.text d4 = self.ids.preco.text d5 = self.ids.data_in.text d6 = self.ids.data_out.text a1 = (d1, d2, d3, d4, d5, d6) s1 = 'UPDATE products SET' s2 = 'Dono="%s", Marca="%s", Defeito="%s", Preco=%s, Data_in="%s", Data_out="%s"' % a1 s3 = 'WHERE ID=%s' % self.data_id try: cursor.execute(s1 + ' ' + s2 + ' ' + s3) con.commit() con.close() self.mainwid.transition.direction = 'right' self.mainwid.goto_list_item() self.show_snackbar() except Exception as e: dialog = MDDialog( title='Oops', size_hint=(.8, .4), text='Certifique-se que os dados fornecidos estao corretos', events_callback=self.close_dialog) dialog.open() con.close()
def info_dialog(self): content = MDList() label = MDLabel(font_style='Subhead', theme_text_color='Secondary', text="\n" + str(self.audio_file), valign='center', halign="center") label.bind(texture_size=label.setter('size')) image = SmartTile(allow_stretch=True, keep_ratio=True, box_color=[0, 0, 0, 0], size_hint_y=None, height=300) image._img_widget.texture = self.ids.avatar.texture content.add_widget(image) content.add_widget(label) self.dialog = MDDialog(title=self.audio_file.name, content=content, size_hint=(.8, 0.75), auto_dismiss=False) self.dialog.add_action_button("Dismiss", action=lambda *x: self.dialog.dismiss()) self.dialog.open()
def open_set_score_dialog(self, player): class PlayerButton(MDRaisedButton): player = NumericProperty(-1) def score_btn_clicked(instance): self._set_score(int(instance.text)) self._open_dialog.dismiss() content = BoxLayout(orientation='vertical', size_hint=(None, None)) #labels #header = MDLabel(font_style='Body1', # text='Please select a value', # size_hint=(1.0, 0.2), # valign='top') #content.add_widget(header) #content.add_widget(NavigationDrawerDivider()) btn_grid = GridLayout(cols=4, spacing=dp(20)) #create score buttons for val in range(-10, 6): btn = PlayerButton(text=str(val), player=player) btn.bind(on_release=score_btn_clicked) btn_grid.add_widget(btn) content.add_widget(btn_grid) #create dialog self._open_dialog = MDDialog( title='Force player {} score'.format(player), content=content, size_hint=(.6, .6), auto_dismiss=True) self._open_dialog.open()
def delete_user(self): # print(self) # print(self.users_list.adapter.selection[0]) # print(type(self.users_list.adapter.selection[0])) # print(self.users_list.adapter.selection[0].text) self.user_delete = self.users_list.adapter.selection[0].text self.user_name_delete = self.user_delete.split('.')[0] self.content = content = MDLabel(font_style='Subhead', theme_text_color='Secondary', text="All data associated with " + self.user_name_delete + " has been removed successfully!", size_hint_y=None, valign='top') self.dialog = MDDialog(title="Conform user delete operation", content=self.content, size_hint=(.8, None), height=dp(200), auto_dismiss=False) self.dialog.add_action_button("Dismiss", action=lambda *x: self.dialog.dismiss()) self.dialog.open() print("########################") print(self.ids) self.detail_view.clearwids() self.ids.detail_user.clear_widgets() os.remove(imagesDir + self.user_delete) # print("delete called") self.users_list.adapter.data = [] self.setUserDirInfo() self.detail_view.redraw()
def edit_data(self, id): name = self.data_object.get_categories().get(id)['name'] b = GridLayout(size_hint=(None, None), height='200px', width="400px", cols=2) name_wid = DialogTextInput(name) b.add_widget( MDLabel(id='Name', text="Name", size_hint_x=None, width="90px")) b.add_widget(name_wid) self.dialog = MDDialog(title="Update Category", content=b, size_hint=(None, None), height="500px", width="500px", auto_dismiss=False) self.dialog.add_action_button( "Save", action=lambda *x: self.save_edited_data(id, name_wid.text)) self.dialog.add_action_button("Cancel", action=lambda *x: self.dialog.dismiss()) self.dialog.open() self.pagination_next() self.call_load()
def insert_data(self): con = sqlite3.connect(self.mainwid.DB_PATH) cursor = con.cursor() d1 = self.ids.dono.text d2 = self.ids.marca.text d3 = self.ids.defeito.text d4 = self.ids.preco.text d5 = self.ids.data_in.text d6 = self.ids.data_out.text a1 = (d1, d2, d3, d4, d5, d6) s1 = 'INSERT INTO products(Dono, Marca, Defeito, Preco, Data_in, Data_out)' s2 = 'VALUES("%s", "%s", "%s", %s, "%s", "%s")' % a1 try: cursor.execute(s1 + ' ' + s2) con.commit() con.close() self.mainwid.transition.direction = 'right' self.mainwid.goto_list_item() self.show_snackbar() except Exception as e: dialog = MDDialog( title='Oops', size_hint=(.8, .4), text='Certifique-se que os dados fornecidos estao corretos', events_callback=self.close_dialog) dialog.open() con.close()
def add_user(self): con = sqlite3.connect(self.mainwid.DB_PATH) cursor = con.cursor() d1 = self.ids.usr_field.text d2 = self.ids.email_field.text d3 = self.ids.pwd_field.text d4 = self.ids.calendar_field.text a1 = (d1, d2, d3, d4) s1 = 'INSERT INTO user(Usuario, Email, Senha, Data)' s2 = 'VALUES("%s", "%s", "%s", %s)' % a1 try: cursor.execute(s1 + ' ' + s2) con.commit() con.close() self.mainwid.transition.direction = 'right' self.mainwid.goto_start() self.dialogs() except Exception as e: dialog = MDDialog( title='Oops', size_hint=(.8, .4), text='Certifique-se que os dados fornecidos estao corretos', events_callback=self.close_dialog) dialog.open() con.close()
def dialog(font_style='Body1', theme_text_color='Secondary', title='Title', text='Text', valign='top', dismiss=True, buttons=None, use_check=False, text_check='', height=300, size_hint=(.85, None), ref_callback=None, check_callback=None): '''Вывод диалоговых окон.''' if buttons is None: buttons = [] text_dialog = MDLabel( font_style=font_style, theme_text_color=theme_text_color, text=text, valign=valign, markup=True, size_hint_y=None ) dialog = MDDialog( title=title, content=text_dialog, size_hint=size_hint, auto_dismiss=dismiss, height=dp(height) ) text_dialog.bind(texture_size=text_dialog.setter('size')) if ref_callback: text_dialog.bind(on_ref_press=ref_callback) if use_check: selection = Selection(text=text_check) if check_callback: selection.callback = check_callback dialog.children[0].children[1].add_widget(selection) for list_button in buttons: text_button, action_button = list_button dialog.add_action_button(text_button, action=action_button) dialog.open() return dialog
def read_qr(self): """Abre la camara para leer un codigo de QR""" self.content = Widget() if platform == 'android': self.detector = ZbarQrcodeDetector() self.detector.bind(symbols=self.connect_qr) self.content.add_widget(self.detector) #~ self.dialog = MDDialog(title="Enfoque el codigo QR",content=self.content, size_hint=(.8, None),height=dp(500),auto_dismiss=False) #~ self.dialog.add_action_button("Cerrar", action= lambda x: self.close_dialog()) #~ self.dialog.open() self.detector.start() else: if self.cam == None: self.cam = Camera(resolution=(640, 480), size=(400, 400), play=True) #~ self.add_widget(self.cam) else: self.cam.play = True self.content.size_hint = None, None self.content.height = dp(400) self.content.add_widget(self.cam) self.check_qr = Clock.schedule_interval(self.detect_qr, 1) self.dialog = MDDialog(title="Enfoque el codigo QR", content=self.content, size_hint=(.8, None), height=dp(500), auto_dismiss=False) self.dialog.add_action_button("Cerrar", action=lambda x: self.close_dialog()) self.dialog.open()
def on_release(self): if not self.info.get('speaker'): return print(" i am here on release") box = BoxLayout(height=dp(500), orientation='vertical', spacing=dp(10), size_hint_y=None) # adding avatar widget if self.info['speaker'].get('avatar'): image = AsyncImage(source=self.info['speaker']['avatar'], allow_stretch=True) box.add_widget(image) # adding place widget if self.info.get('place'): place = MDRaisedButton(text=self.info['place'], elevation_normal=2, opposite_colors=True, pos_hint={'center_x': .5, 'center_y': .4}) box.add_widget(place) # adding description widget label = MDLabel(font_style='Body1', theme_text_color='Primary', text=self._parse_text(), size_hint_y=None) label.bind(texture_size=label.setter('size')) box.add_widget(label) self.dialog = MDDialog(title=self.info['speaker']['name'], content=box, size_hint=(1, None), height=dp(500), auto_dismiss=False) self.dialog.add_action_button('Close', action=lambda *x: self.dialog.dismiss()) self.dialog.open()
class PopList(TwoLineListItem): def __init__(self,**kwargs): super(PopList,self).__init__(**kwargs) def on_touch_down(self, touch): if self.collide_point(*touch.pos): self.pressed = touch.pos print(str(self.text)) content = MDLabel(font_style='Body1', theme_text_color='Secondary', text="{}".format(self.secondary_text), size_hint_y=None, valign='top') content.bind(texture_size=content.setter('size')) self.dialog = MDDialog(title="{}".format(self.text), content=content, size_hint=(.9, None), height=dp(300), auto_dismiss=False) self.dialog.add_action_button("Dismiss", action=lambda *x: self.dialog.dismiss()) self.dialog.open() super(PopList, self).on_touch_down(touch)
def anime_confirmation(self, anime_list): Global.ANIME_CONFIRM_LIST = [] for anime in anime_list: Global.ANIME_CONFIRM_LIST.append(anime.name) ml = MDList() for anime in anime_list: item = OneLineRightIconListItem(text=anime.name) item.on_release = functools.partial(self.show_desc, anime) remove_button = RemoveButton(name=anime.name, icon='server-remove') item.add_widget(remove_button) ml.add_widget(item) self.dialog = MDDialog( title=str(len(anime_list)) + " Results! This is what we found for you. Click to open browser for more info!", content=ml, size_hint=(.8, None), height=dp(650), auto_dismiss=False) self.dialog.add_action_button("Cancel", action=lambda *x: self.dialog.dismiss()) self.dialog.add_action_button( "Confirm and + to watchlist", action=lambda *x: self.add_anime_to_db(self.dialog, anime_list)) self.dialog.open()
def edit_data(self, id): brandname = str(self.data_in_page.get(id)['brandname']) genericname = str(self.data_in_page.get(id)['genericname']) quantityperunit = str(self.data_in_page.get(id)['quantityperunit']) unitprice = str(self.data_in_page.get(id)['unitprice']) category_id = str(self.data_in_page.get(id)['category_id']) expiry_date = str(self.data_in_page.get(id)['expiry_date']) status = str(self.data_in_page.get(id)['status']) b = GridLayout(size_hint=(None, None), height='200px', width="400px", cols=2) brandname_wid = DialogTextInput(brandname) genericname_wid = DialogTextInput(genericname) quantityperunit_wid = DialogTextInput(quantityperunit) unitprice_wid = DialogTextInput(unitprice) category_id_wid = DialogTextInput(category_id) expiry_date_wid = DialogTextInput(expiry_date) status_wid = DialogTextInput(status) b.add_widget(MDLabel(text="Brand Name", size_hint_x=None, width="90px")) b.add_widget(brandname_wid) b.add_widget( MDLabel(text="Generic Name", size_hint_x=None, width="90px")) b.add_widget(genericname_wid) b.add_widget( MDLabel(text="Quantity Per Unit", size_hint_x=None, width="90px")) b.add_widget(quantityperunit_wid) b.add_widget(MDLabel(text="Unit Price", size_hint_x=None, width="90px")) b.add_widget(unitprice_wid) b.add_widget( MDLabel(text="Category ID", size_hint_x=None, width="90px")) b.add_widget(category_id_wid) b.add_widget( MDLabel(text="Expiry Date", size_hint_x=None, width="90px")) b.add_widget(expiry_date_wid) b.add_widget(MDLabel(text="Status", size_hint_x=None, width="90px")) b.add_widget(status_wid) self.dialog = MDDialog(title="Update Vocuher", content=b, size_hint=(None, None), height="500px", width="500px", auto_dismiss=False) self.dialog.add_action_button( "Save", action=lambda *x: self.save_edited_data( id, brandname_wid.text, genericname_wid.text, quantityperunit_wid.text, unitprice_wid.text, category_id_wid. text, expiry_date_wid.text, status_wid.text)) self.dialog.add_action_button("Cancel", action=lambda *x: self.dialog.dismiss()) self.dialog.open() self.pagination_next() self.call_load()
def connect(self): dialog = MDDialog( title='Connexion', size_hint=(.8, .3), text_button_ok='Yes', text="Votre navigateur va s'ouvrir pour autoriser la connexion", text_button_cancel='Cancel', events_callback=self.getToken) dialog.open()
def show_example_ok_cancel_dialog(self): if not self.ok_cancel_dialog: from kivymd.dialog import MDDialog self.ok_cancel_dialog = MDDialog( title='Title', size_hint=(.8, .4), text_button_ok='Ok', text="This is Ok Cancel dialog", text_button_cancel='Cancel', events_callback=self.callback_for_menu_items) self.ok_cancel_dialog.open()
def show_dialog(self, *args): button = MDFlatButton(text='OK') self.dialog = MDDialog(size_hint=(0.5, 0.4), auto_dismiss=False, pos_hint={"center_x": 0.5}, title="Material to be returned", content=button) button.bind(on_press=self.dialog.dismiss) self.dialog.open()
class CalculatorApp(App): theme_cls = ThemeManager() theme_cls.theme_style = 'Dark' nav_drawer = ObjectProperty() def build(self): self.content_widgets = Content() return self.content_widgets def get_value(self, text): self.value = text calculator = ComplexCalculator() result,initial_expression = calculator.calculate(text) if(result == False): self.error_dialog() else: expression_show = ' '.join([str(elem) for elem in initial_expression ]) self.success_dialog(result,expression_show) def success_dialog(self,result,expression_show): content = MDLabel(font_style='Body1', theme_text_color='Secondary', text="Expresion ingresada: "+str(expression_show), size_hint_y=None, valign='top') content.bind(texture_size=content.setter('size')) self.dialog = MDDialog(title="Resultado: "+str(result), content=content, size_hint=(.8, None), height=100, auto_dismiss=False) self.dialog.add_action_button("Cerrar", action=lambda *x: self.dialog.dismiss()) self.dialog.open() def error_dialog(self): content = MDLabel(font_style='Body1', theme_text_color='Secondary', text="Error al ingresar la expresión", size_hint_y=None, valign='top') content.bind(texture_size=content.setter('size')) self.dialog = MDDialog(title="Error", content=content, size_hint=(.8, None), height=100, auto_dismiss=False) self.dialog.add_action_button("Cerrar", action=lambda *x: self.dialog.dismiss()) self.dialog.open()
def show_dialog(self): my_dialog = MDDialog( title='About the App', text= 'This app is for level advisers only, it enables communication between student and their respective level coodinators', size_hint=[.8, .4], auto_dismiss=False, events_callback=self.my_callback, text_button_ok='I understand') my_dialog.open()
def show_dialoghelp(self): my_dialog = MDDialog( title='What is this ?', text= 'To send a message, you have to provide the receivers username, you can also send to multiple users by seperating their usernames with a comma (,)', size_hint=[.8, .4], auto_dismiss=False, events_callback=self.my_callback, text_button_ok='Ok perfect !') my_dialog.open()
def showAddUserdialog(self): content = AddUserContent() self.dialog = MDDialog(title="Add Friend/Coach", content=content, size_hint=(.8, None), height=dp(200), auto_dismiss=False) self.dialog.add_action_button("Dismiss", action=lambda *x: self.dialog.dismiss()) self.dialog.open()
def ok(self): try: self.ok1() except Exception: self.alert_dialog = MDDialog( title="WARNING!", size_hint=(0.8, 0.4), text_button_ok="Ok", text="check inputs", events_callback=self.remove_pop, ) self.alert_dialog.open()
def show_example_alert_dialog(self): if not self.alert_dialog: from kivymd.dialog import MDDialog self.alert_dialog = MDDialog( title="Title", size_hint=(0.8, 0.4), text_button_ok="Ok", text="This is Alert dialog", events_callback=self.callback_for_menu_items, ) self.alert_dialog.open()
def bind_dialog(self, bind_type): # bind_type: 0-->信息门户, 1-->教务系统 self.content = MDTextField() self.content.hint_text = "密码" # content.password = True self.dialog = MDDialog(title="绑定信息门户" if bind_type == 0 else "绑定教务系统", content=self.content, size_hint=(.8, None), height=dp(200), auto_dismiss=True) self.dialog.add_action_button("绑定", action=lambda *x: self.bind_infoport() if bind_type == 0 else self.bind_edusys()) self.dialog.add_action_button("取消", action=lambda *x: self.dialog.dismiss()) self.dialog.open()
def bind_email_dialog(self): self.content = MDTextField() self.content.hint_text = "邮箱" # content.password = True self.dialog = MDDialog(title="修改邮箱", content=self.content, size_hint=(.8, None), height=dp(200), auto_dismiss=True) self.dialog.add_action_button("确定", action=lambda *x: self.bind_email()) self.dialog.add_action_button("取消", action=lambda *x: self.dialog.dismiss()) self.dialog.open()
class Patron(ToolbarScreen): def __init__(self, **opt): super(Patron, self).__init__(**opt) def show_dialog(self, *args): button = MDFlatButton(text='OK') self.dialog = MDDialog(size_hint=(0.5, 0.4), auto_dismiss=False, pos_hint={"center_x": 0.5}, title="Material to be returned", content=button) button.bind(on_press=self.dialog.dismiss) self.dialog.open()
def edit_data(self, id): import_id = str( self.data_object.get_import_details().get(id)['import_id']) product_id = str( self.data_object.get_import_details().get(id)['product_id']) quantity = str( self.data_object.get_import_details().get(id)['quantity']) unitprice = str( self.data_object.get_import_details().get(id)['unitprice']) b = GridLayout(size_hint=(None, None), height='200px', width="400px", cols=2) imp_id = DialogTextInput(import_id) prod_id = DialogTextInput(product_id) qty = DialogTextInput(quantity) uprice = DialogTextInput(unitprice) b.add_widget( MDLabel(id='destination', text="Import ID", size_hint_x=None, width="90px")) b.add_widget(imp_id) b.add_widget(MDLabel(text="Product ID", size_hint_x=None, width="90px")) b.add_widget(prod_id) b.add_widget( MDLabel(id='date', text="Quantity", size_hint_x=None, width="90px")) b.add_widget(qty) b.add_widget( MDLabel(id='date', text="Unit Price", size_hint_x=None, width="90px")) b.add_widget(uprice) self.dialog = MDDialog(title="Update Import", content=b, size_hint=(None, None), height="500px", width="500px", auto_dismiss=False) self.dialog.add_action_button( "Save", action=lambda *x: self.save_edited_data( id, imp_id.text, prod_id.text, qty.text, uprice.text)) self.dialog.add_action_button("Cancel", action=lambda *x: self.dialog.dismiss()) self.dialog.open()
class BodyScanApp(App): theme_cls = ThemeManager() nav_drawer = ObjectProperty() username = StringProperty("") rights = StringProperty("") def showAddUserdialog(self): content = AddUserContent() self.dialog = MDDialog(title="Add Friend/Coach", content=content, size_hint=(.8, None), height=dp(200), auto_dismiss=False) self.dialog.add_action_button("Dismiss", action=lambda *x: self.dialog.dismiss()) self.dialog.open() def build(self): self.nav_drawer = BodyScanNavDrawer() self.theme_cls.primary_palette = "Blue" self.theme_cls.primary_hue = "500"
class MyApp(App): theme_cls = ThemeManager() nav_drawer = ObjectProperty() def build(self): print('here we start') # self.theme_cls.theme_style = 'Dark' # self.show_example_dialog() # self.show_menu() return RootScreen() def test(self): print('here we go') def show_menu(self): self.nav_drawer = MyNavDrawer() self.nav_drawer.toggle() def show_example_dialog(self): content = MDLabel(font_style='Body1', theme_text_color='Secondary', text="This is a dialog with a title and some text. " "That's pretty awesome right!", valign='top') content.bind(size=content.setter('text_size')) self.dialog = MDDialog(title="This is a pretty dialog", content=content, size_hint=(.8, None), height=dp(200), auto_dismiss=False) self.dialog.add_action_button("Dismiss", action=lambda *x: self.dialog.dismiss()) self.dialog.open()
def show_example_dialog(self): content = MDLabel( font_style="Body1", theme_text_color="Secondary", text="This is a dialog with a title and some text. That's pretty awesome right!", valign="top", ) content.bind(size=content.setter("text_size")) self.dialog = MDDialog( title="This is a test dialog", content=content, size_hint=(0.8, None), height=dp(200), auto_dismiss=False ) self.dialog.add_action_button("Dismiss", action=lambda *x: self.dialog.dismiss()) self.dialog.open()
class KitchenSink(App): theme_cls = ThemeManager() menu_items = [ {"viewclass": "MDMenuItem", "text": "Example item"}, {"viewclass": "MDMenuItem", "text": "Example item"}, {"viewclass": "MDMenuItem", "text": "Example item"}, {"viewclass": "MDMenuItem", "text": "Example item"}, {"viewclass": "MDMenuItem", "text": "Example item"}, {"viewclass": "MDMenuItem", "text": "Example item"}, {"viewclass": "MDMenuItem", "text": "Example item"}, ] def build(self): main_widget = Builder.load_string(main_widget_kv) # self.theme_cls.theme_style = 'Dark' main_widget.ids.text_field.bind(on_text_validate=self.set_error_message, on_focus=self.set_error_message) return main_widget def show_example_snackbar(self, type): if type == "simple": Snackbar.make("This is a snackbar!") elif type == "button": Snackbar.make("This is a snackbar", button_text="with a button!", button_callback=lambda *args: 2) elif type == "verylong": Snackbar.make("This is a very very very very very very very long " "snackbar!", button_text="Hello world") def show_example_dialog(self): content = MDLabel( font_style="Body1", theme_text_color="Secondary", text="This is a dialog with a title and some text. That's pretty awesome right!", valign="top", ) content.bind(size=content.setter("text_size")) self.dialog = MDDialog( title="This is a test dialog", content=content, size_hint=(0.8, None), height=dp(200), auto_dismiss=False ) self.dialog.add_action_button("Dismiss", action=lambda *x: self.dialog.dismiss()) self.dialog.open() def theme_swap(self): self.theme_cls.theme_style = "Dark" if self.theme_cls.theme_style == "Light" else "Light" def show_example_bottom_sheet(self): bs = MDListBottomSheet() bs.add_item("Here's an item with text only", lambda x: x) bs.add_item("Here's an item with an icon", lambda x: x, icon="md-cast") bs.add_item("Here's another!", lambda x: x, icon="md-nfc") bs.open() def show_example_grid_bottom_sheet(self): bs = MDGridBottomSheet() bs.add_item("Facebook", lambda x: x, icon_src="./assets/facebook-box.png") bs.add_item("YouTube", lambda x: x, icon_src="./assets/youtube-play.png") bs.add_item("Twitter", lambda x: x, icon_src="./assets/twitter.png") bs.add_item("Da Cloud", lambda x: x, icon_src="./assets/cloud-upload.png") bs.add_item("Camera", lambda x: x, icon_src="./assets/camera.png") bs.open() def set_error_message(self, *args): if len(self.root.ids.text_field.text) == 0: self.root.ids.text_field.error = True self.root.ids.text_field.error_message = "Some text is required" else: self.root.ids.text_field.error = False def on_pause(self): return True def on_stop(self): pass