Example #1
0
    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))
Example #2
0
def conf_pop(dis,but1,action1):
	content = MDLabel(font_style='Body1',theme_text_color='Secondary',text=dis,size_hint_y=None,valign='top')
	content.bind(texture_size=content.setter('size'))
	dialog0 = MDDialog(content=content,size_hint=(.8, None),height=dp(200),auto_dismiss=True)
	dialog0.add_action_button(but1,action= action1)
	dialog0.add_action_button("cancel",action=lambda *x: dialog0.dismiss())
	return dialog0
Example #3
0
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
Example #4
0
def error_pop(matter):
	content = MDLabel(font_style='Body1',theme_text_color='Secondary',text=matter,size_hint_y=None,valign='top')
	content.bind(texture_size=content.setter('size'))
	dialog2 = MDDialog(title="Error",content=content,size_hint=(.8, None),height=dp(200),auto_dismiss=False)
	dialog2.add_action_button("Dismiss",action=lambda *x:dialog2.dismiss())
	dialog2.open()
#This PC\Lenovo K8 Plus\SanDisk SD card\Android\data\org.coursera.android\files\Download
Example #5
0
    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()
Example #6
0
    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")
Example #7
0
    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()
Example #8
0
    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()
Example #9
0
def dialog(font_style='Body1',
           theme_text_color='Secondary',
           title='Title',
           text='Text',
           valign='top',
           dismiss=True,
           buttons=None,
           ref_callback=None,
           height=dp(200)):
    '''Вывод диалоговых окон.'''

    if buttons is None:
        buttons = []

    content = MDLabel(font_style=font_style,
                      theme_text_color=theme_text_color,
                      text=text,
                      valign=valign,
                      markup=True)
    content.bind(size=content.setter('text_size'))
    if ref_callback:
        content.bind(on_ref_press=ref_callback)

    dialog = MDDialog(title=title,
                      content=content,
                      size_hint=(.8, None),
                      height=height,
                      auto_dismiss=dismiss)

    for list_button in buttons:
        text_button, action_button = list_button
        dialog.add_action_button(text_button, action=action_button)
    dialog.open()

    return dialog
Example #10
0
    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()
Example #11
0
 def create_dialog_helper(cls, title, body):
     """
     Creates a dialog from given title and body.
     Adds it to the dialogs track list.
     """
     content = MDLabel(font_style='Body1',
                       theme_text_color='Secondary',
                       text=body,
                       size_hint_y=None,
                       valign='top')
     content.bind(texture_size=content.setter('size'))
     dialog = cls.create_dialog_content_helper(title, content)
     return dialog
Example #12
0
    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 show_warning(self,title,body):
        content = MDLabel(font_style='Body1',
                          theme_text_color='Secondary',
                          text=body,
                          size_hint_y=None,
                          valign='top')
        content.bind(texture_size=content.setter('size'))
        self.dialog = MDDialog(title=title,
                               content=content,
                               size_hint=(.8, .2),
                               height=dp(100),
                               auto_dismiss=False)

        self.dialog.add_action_button("Dismiss", action=lambda *x: self.dialog.dismiss())
        self.dialog.open()
Example #14
0
 def error_dialog(self, txt):
     """Muestra un dialogo de error en caso de no poder conectarse."""
     content = MDLabel(font_style='Body1',
                       theme_text_color='Secondary',
                       text=txt,
                       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=dp(200),
                            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 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 user_verify_error(self, req, result):
        self.root.ids.spinner_verify.active = False
        content = MDLabel(font_style='Body1',
                          theme_text_color='Secondary',
                          text='Invalid or empty code',
                          size_hint_y=None,
                          valign='top')
        content.bind(texture_size=content.setter('size'))
        self.dialog = MDDialog(title="Please enter the code sent to your email correctly",
                               content=content,
                               size_hint=(.8, None),
                               height=dp(200),
                               auto_dismiss=False)

        self.dialog.add_action_button("Try Again",
                                      action=lambda *x: self.dialog.dismiss())
        self.dialog.open()
    def user_register_error(self, req, result):
        self.root.ids.spinner_register.active = False
        content = MDLabel(font_style='Body1',
                          theme_text_color='Secondary',
                          text='Check details entered again',
                          size_hint_y=None,
                          valign='top')
        content.bind(texture_size=content.setter('size'))
        self.dialog = MDDialog(title="Registration Failed",
                               content=content,
                               size_hint=(.8, None),
                               height=dp(200),
                               auto_dismiss=False)

        self.dialog.add_action_button("Try Again",
                                      action=lambda *x: self.dialog.dismiss())
        self.dialog.open()
Example #19
0
    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!",
                          size_hint_y=None,
                          valign='top')
        content.bind(texture_size=content.setter('size'))
        self.dialog = MDDialog(title="This is a 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()
Example #20
0
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
Example #21
0
    def nextdraw(self):
        global deck
        global List

        if (len(deck) > 0):
            (List, deck, drawncards) = draw4(deck)
            self.root.ids.gbr1.source = str(drawncards[0].FN)
            self.root.ids.gbr2.source = str(drawncards[1].FN)
            self.root.ids.gbr3.source = str(drawncards[2].FN)
            self.root.ids.gbr4.source = str(drawncards[3].FN)

            anim1 = Animation(x=50, y=400, t='linear', duration=1)
            anim2 = Animation(x=400, y=400, t='linear', duration=1)
            anim3 = Animation(x=750, y=400, t='linear', duration=1)
            anim4 = Animation(x=1100, y=400, t='linear', duration=1)
            anim1.start(self.root.ids.gbr1)
            anim2.start(self.root.ids.gbr2)
            anim3.start(self.root.ids.gbr3)
            anim4.start(self.root.ids.gbr4)

            reset3 = Animation(opacity=0)
            reset3.start(self.root.ids.label3)
            reset3.start(self.root.ids.hasil)
            reset3.start(self.root.ids.label4)
            reset3.start(self.root.ids.poin)
            reset3.start(self.root.ids.label5)
            reset3.start(self.root.ids.totalpoin)

            self.root.current = 'Screen2'
        else:
            content = MDLabel(font_style='Body1',
                              theme_text_color='Secondary',
                              text="There's no card left. The game is over!\n"
                              "Please start a new game or exit the game.",
                              size_hint_y=None,
                              valign='top')
            content.bind(texture_size=content.setter('size'))
            self.dialog = MDDialog(title="GAME OVER",
                                   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()
Example #22
0
    def refresh_list(self):
        #обновление списка задач
        try:
            res = GetResult('getDisposalList', {'readed': 0}, [
                'Number', 'Theme', 'ShortTask', 'Sender_id', 'Receiver_id',
                'Task', 'isExecute'
            ])

            for i in res:
                # текст задачи
                if i[2] != '':
                    disposal_text = i[2]
                else:
                    disposal_text = 'ПУСТО'
                # иконка выполнения
                if i[6] == '0':
                    icon_text = 'clock'
                else:
                    icon_text = 'calendar-check'

                # номер + тема задачи
                theme_text = (i[0] + ' ' + i[1])
                if len(theme_text) > 30:
                    theme_text = theme_text[:27] + '...'

                item = DisposalItem(text=theme_text,
                                    secondary_text=disposal_text,
                                    icon_text=icon_text,
                                    data=i)
                self.add_widget(item)
        except:
            #сообщение об ошибке
            content = MDLabel(font_style='Body1',
                              text='Не подключения, проверьте настройки!',
                              size_hint_y=None,
                              valign='top')
            content.bind(texture_size=content.setter('size'))
            self.dialog = MDDialog(title="Внимание",
                                   content=content,
                                   size_hint=(.8, None),
                                   height=dp(200))

            self.dialog.add_action_button(
                "ОК", action=lambda *x: self.dialog.dismiss())
            self.dialog.open()
Example #23
0
 def showDialogToReset(self):
     print("reset data")
     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!",
                       size_hint_y=None,
                       valign='top')
     content.bind(texture_size=content.setter('size'))
     self.dialog = MDDialog(title="Are you sure?",
                            content=content,
                            size_hint=(.8, None),
                            auto_dismiss=False)
     self.dialog.add_action_button("Yes",
                                   action=lambda *x: self.resetData())
     self.dialog.add_action_button("No",
                                   action=lambda *x: self.dialog.dismiss())
     self.dialog.open()
    def update_course(self):
        content = MDLabel(font_style='Body1',
                          theme_text_color='Hint',
                          text="更新课表将导致自定义课程丢失,是否继续",
                          size_hint_y=None,
                          valign='top')
        content.bind(texture_size=content.setter('size'))
        self.dialog = MDDialog(title="更新课表",
                               content=content,
                               size_hint=(.8, None),
                               height=dp(160),
                               auto_dismiss=False)

        self.dialog.add_action_button("取消",
                                      action=lambda *x: self.dialog.dismiss())
        self.dialog.add_action_button("确定",
                                      action=lambda *x: self.dialog.dismiss())
        self.dialog.open()
    def user_login_error(self, *args):
        self.root.ids.scr_mngr.current = 'user_login'
        self.root.ids.spinner_login.active = False
        content = MDLabel(font_style='Body1',
                          theme_text_color='Secondary',
                          text='Unable to login with provided credentials',
                          size_hint_y=None,
                          valign='top')
        content.bind(texture_size=content.setter('size'))
        self.dialog = MDDialog(title="Please check email and password",
                               content=content,
                               size_hint=(.8, None),
                               height=dp(200),
                               auto_dismiss=False)

        self.dialog.add_action_button("Try Again",
                                      action=lambda *x: self.dialog.dismiss())
        self.dialog.open()
Example #26
0
    def loading_box(self):
        content = MDLabel(
            font_style='Body1',
            theme_text_color='Secondary',
            text=
            "Please wait while we are fetching your instagram, Hang tight!!!",
            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=True)

        # self.dialog.add_action_button("Dismiss",
        #                               action=lambda *x: self.dialog.dismiss())
        self.dialog.open()
        return
Example #27
0
 def create_dialog(title, body):
     """
     Creates a dialog from given title and body.
     Adds it to the dialogs track list.
     """
     content = MDLabel(font_style='Body1',
                       theme_text_color='Secondary',
                       text=body,
                       size_hint_y=None,
                       valign='top')
     content.bind(texture_size=content.setter('size'))
     dialog = MDDialog(title=title,
                       content=content,
                       size_hint=(.8, None),
                       height=dp(200),
                       auto_dismiss=False)
     dialog.add_action_button("Dismiss", action=lambda *x: dialog.dismiss())
     dialog.bind(on_dismiss=Controller.on_dialog_dismiss)
     Controller.dialogs.append(dialog)
     return dialog
Example #28
0
    def loginSuccessDialog(self):
        global auth_user_name
        content = MDLabel(
            font_style='Body1',
            theme_text_color='Secondary',
            text="Welcome " + auth_user_name +
            "\n This is the home-screen, if you are not aware of the options given here"
            "\nPlease refer documentation!",
            size_hint_y=None,
            valign='top')
        content.bind(texture_size=content.setter('size'))
        self.dialog = MDDialog(title="Login Success!",
                               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()
Example #29
0
    def delete_page(self):
        content = MDLabel(font_style='Body1',
                          theme_text_color='Secondary',
                          text="Удалить страницу {}".format(
                              self.root.ids.details_page_name.text),
                          size_hint_y=None,
                          valign='top')
        content.bind(texture_size=content.setter('size'))
        self.dialog = MDDialog(title="Удаление страницы",
                               content=content,
                               size_hint=(.8, None),
                               height=dp(200),
                               auto_dismiss=False)

        self.dialog.add_action_button("Нет",
                                      action=lambda *x: self.dialog.dismiss())
        self.dialog.add_action_button(
            "Да",
            action=lambda *x: self.confirm_delete_dialog(self.root.ids.
                                                         details_page_id.text))
        self.dialog.open()
Example #30
0
 def show_error_token(self):
     global otrh_kost
     self = otrh_kost
     if self.root.ids.RogueBotUserToken.text == '':
         text = 'Вы не указали токен'
     else:
         text = 'Вы указали неправильный токен'
     content = MDLabel(font_style='Body1',
                       theme_text_color='Secondary',
                       text=text,
                       size_hint_y=None,
                       valign='top')
     content.bind(texture_size=content.setter('size'))
     self.dialog = MDDialog(title="Неправильный токен",
                            content=content,
                            size_hint=(.8, None),
                            height=dp(200),
                            auto_dismiss=False)
     self.dialog.add_action_button("Вернуться",
                                   action=lambda *x: self.dialog.dismiss())
     self.dialog.open()
Example #31
0
    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)
Example #32
0
File: main.py Project: pl77/cypher
    def show_dialog(self, title, desc):
        '''
        Muestra el dialog de extensiones y About
        Condicion necesaria para About: title y desc deben ser iguales

        Parametros:
        title: titulo del dialog; nombre de la extension o 'About Cypher'
        desc: descripcion de la extension; en el caso de About debe ser igual a title
        '''
        text_about = (
            "A simple file viewer.\n"
            "More than 200 formats supported, multiplatform and free (for ever)\n\n"
            "Version: 0.1\n"
            "twitter.com/favcau\n"
            "[email protected]\n\n"
            "Powered by Python + Kivy/KivyMD")

        # title: 'About Cypher' - desc: 'About Cypher'
        if title == desc:
            text_desc = text_about
        else:
            text_desc = desc

        content = MDLabel(font_style='Body1',
                          theme_text_color='Secondary',
                          text=text_desc,
                          size_hint_y=None,
                          valign='top',
                          markup=True)
        content.bind(texture_size=content.setter('size'))
        self.dialog = MDDialog(title=title,
                               content=content,
                               size_hint=(.8, None),
                               height=dp(400),
                               auto_dismiss=False)

        self.dialog.add_action_button("Done",
                                      action=lambda *x: self.dialog.dismiss())
        self.dialog.open()
Example #33
0
class SingleLineTextField(ThemableBehavior, TextInput):
    error_message = StringProperty('')

    line_color_normal = ListProperty([])
    line_color_focus = ListProperty([])

    error_color = ListProperty([])

    error = BooleanProperty(False)

    _hint_txt_color = ListProperty()
    _hint_lbl = ObjectProperty()
    _hint_lbl_font_size = NumericProperty(sp(16))
    _hint_y = NumericProperty(dp(10))
    _msg_label = ObjectProperty()
    _line_width = NumericProperty(0)
    _hint_txt = StringProperty('')

    def __init__(self, **kwargs):
        self._msg_label = MDLabel(font_style='Caption',
                                  theme_text_color='Error',
                                  halign='left',
                                  valign='middle')

        self._hint_lbl = MDLabel(font_style='Subhead',
                                 halign='left',
                                 valign='middle')
        super(SingleLineTextField, self).__init__(**kwargs)
        self.line_color_normal = self.theme_cls.divider_color
        self.line_color_focus = self.theme_cls.primary_color
        self.error_color = self.theme_cls.error_color
        self._hint_txt_color = self.theme_cls.disabled_hint_text_color
        self.hint_text_color = (1, 1, 1, 0)
        self.cursor_color = self.theme_cls.primary_color

        self.bind(error_message=self._set_msg,
                  hint_text=self._set_hint,
                  _hint_lbl_font_size=self._hint_lbl.setter('font_size'))

    def on_hint_text_color(self, instance, color):
        self._hint_txt_color = self.theme_cls.disabled_hint_text_color
        self.hint_text_color = (1, 1, 1, 0)

    def on_width(self, instance, width):
        self.anim = Animation(_line_width=width, duration=.2, t='out_quad')
        self._msg_label.width = self.width
        self._hint_lbl.width = self.width

    def on_pos(self, *args):
        self.hint_anim_in = Animation(_hint_y=dp(34),
                                      _hint_lbl_font_size=sp(12), duration=.2,
                                      t='out_quad')
        self.hint_anim_out = Animation(_hint_y=dp(10),
                                       _hint_lbl_font_size=sp(16),
                                       duration=.2,
                                       t='out_quad')

    def on_focus(self, *args):
        if self.focus:
            Animation.cancel_all(self, '_line_width', '_hint_y',
                                 '_hint_lbl_font_size')
            if len(self.text) == 0:
                self.hint_anim_in.start(self)
            if not self.error:
                self.anim.start(self)
        else:
            Animation.cancel_all(self, '_line_width', '_hint_y',
                                 '_hint_lbl_font_size')
            if len(self.text) == 0:
                self.hint_anim_out.start(self)
            if not self.error:
                self._line_width = 0

    def _set_hint(self, instance, text):
        self._hint_lbl.text = text

    def _set_msg(self, instance, text):
        self._msg_label.text = text