Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def show_easter_dialog(self):
content = MDLabel(font_style='Body1',
theme_text_color='Secondary',
text="Congrats! You found this easter egg!\n\n"
"Thanks for trying out CoPilot! :)",
valign='top')
content.bind(size=content.setter('text_size'))
self.dialog = MDDialog(title="Easter Egg!",
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()
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 create_dialog_content_helper(cls, title, content):
"""
Creates a dialog from given title and content.
Adds it to the dialogs track list.
"""
# TODO
dialog = MDDialog(
title=title,
content=content,
size_hint=(.8, None),
height=dp(250),
auto_dismiss=False)
dialog.bind(on_dismiss=cls.on_dialog_dismiss)
with cls.__lock:
cls.dialogs.append(dialog)
return dialog
def show_dialog(self, title, message, qrdata=None, cb=None):
if qrdata:
dialog_height = 300
content = QRCodeWidget(data=qrdata,
size=(dp(150), dp(150)),
size_hint=(None, None))
else:
dialog_height = 200
content = MDLabel(font_style='Body1',
theme_text_color='Secondary',
text=message,
size_hint_y=None,
valign='top')
content.bind(texture_size=content.setter('size'))
self.dialog = MDDialog(title=title,
content=content,
size_hint=(.8, None),
height=dp(dialog_height),
auto_dismiss=False)
self.dialog.add_action_button(
"Dismiss", action=cb if cb else lambda *x: self.dialog.dismiss())
self.dialog.open()
def __init__(self, **kwargs):
super(MDDialog, self).__init__(**kwargs)
self.bind(_action_buttons=self._update_action_buttons,
auto_dismiss=lambda *x: setattr(self.shadow, 'on_release',
self.shadow.dismiss if self.auto_dismiss else None))
def show_version_dialog(self):
content = MDLabel(font_style='Body1',
theme_text_color='Secondary',
text="Created by Joel Zeller\n\n"
"Please send any bugs to joelzeller25@hotmail.com",
valign='top')
content.bind(size=content.setter('text_size'))
self.dialog = MDDialog(title="CoPilot "+version,
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 __init__(self, **kwargs):
super(CaptchaPopup, self).__init__(**kwargs)
self.add_action_button("Try Again", action=lambda *x: self.try_again())
self.add_action_button("Continue",
action=lambda *x: self.non_restricted())
def try_again(self):
self.action = "try_again"
self.dismiss()
def non_restricted(self):
self.action = "front_screen"
self.dismiss()
class SearchPopup(MDDialog):
search_suggestions = ListProperty([])
search_buttons = ListProperty([])
def __init__(self, **kwargs):
super(SearchPopup, self).__init__(**kwargs)
self.add_action_button("Search", action=lambda *x: self.savesearch())
def savesearch(self):
db = App.get_running_app().db
already_exists = db.query(Search).filter_by(searchterm=self.ids.searcharea.text).first()
front_screen = App.get_running_app().root.ids.sadpanda_screen_manager.get_screen("front_screen")
front_screen.do_search(self.ids.searcharea.text)
if already_exists:
self.dismiss()
else:
newsearch = Search(searchterm=self.ids.searcharea.text)
db.add(newsearch)
def create_alias_dialog(cls, account):
"""
Creates the update alias dialog.
"""
title = "Update your alias"
content = cls(account)
dialog = MDDialog(
title=title,
content=content,
size_hint=(.8, None),
height=dp(250),
auto_dismiss=False)
# workaround for MDDialog container size (too small by default)
dialog.ids.container.size_hint_y = 1
return dialog
def show_indev_dialog(self):
content = MDLabel(font_style='Body1',
theme_text_color='Secondary',
text="This feature is currently in development.\n\n"
"Thanks for trying out CoPilot! :)",
valign='top')
content.bind(size=content.setter('text_size'))
self.dialog = MDDialog(title="Coming soon!",
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()