Exemple #1
0
 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)
Exemple #2
0
    def __init__(self, **kwargs):
        Clock.schedule_interval(self._update_color, 5)
        self._msg_lbl = MDLabel(font_style='Caption',
                                theme_text_color='Error',
                                halign='left',
                                valign='middle',
                                text=self.message)

        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 = list(self.theme_cls.primary_color)
        self.base_line_color_focus = list(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(message=self._set_msg,
                  hint_text=self._set_hint,
                  _hint_lbl_font_size=self._hint_lbl.setter('font_size'),
                  message_mode=self._set_mode)
        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')
Exemple #3
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
Exemple #4
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))
Exemple #5
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
Exemple #6
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()
Exemple #7
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")
Exemple #8
0
    def __init__(self, **kwargs):
        super(LeftPane, self).__init__(**kwargs)
        self.cols = 1
        self.rows = 4
        self.row_force_default = True
        self.row_default_height = 40

        self.size_hint = (500, 0.3)

        self.spacing = (0, 10)

        Title = MDLabel()
        Title.text = "Quick Inch <--> MM Converter"

        self.InchInput = MDTextField()
        self.InchInput.hint_text = "Inches"
        self.InchInput.multiline = False
        self.InchInput.on_text_validate = self.convert

        self.MMInput = MDTextField()
        self.MMInput.hint_text = "Millimeters"
        self.MMInput.multiline = False
        self.MMInput.on_text_validate = self.convert

        ConvButton = MDRaisedButton()
        ConvButton.text = "   <--- CONVERT -->   "
        ConvButton.on_press = self.convert

        self.add_widget(Title)
        self.add_widget(self.InchInput)
        self.add_widget(self.MMInput)
        self.add_widget(ConvButton)
Exemple #9
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()
Exemple #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()
Exemple #11
0
 def generate_menu(self, *args):
     self.ids.menu_list.clear_widgets()
     info_list_lines = []
     adding_interval = 0
     for job in self.menu_jobs:
         job.cancel()
     for item in self.current_menu:
         adding_interval += .1
         item_type = item[0]
         item_description = item[1]
         item_ending = item[2]
         item_origin = item[3]
         item_port = item[4]
         base_menu_item = TwoLineIconListItem()
         icon_widget = IconLeftWidget()
         if item_type == "1":
             icon_widget.icon = "folder"
         elif item_type == "0":
             icon_widget.icon = "file"
         elif item_type == "I":
             icon_widget.icon = "image"
         else:
             log.info("Item Type: {}".format(item_type))
             icon_widget.icon = "firefox"
         if not item_type == "i":
             base_menu_item.text = item_description
             base_menu_item.selector = item_ending
             base_menu_item.url = item_origin
             base_menu_item.port = item_port
             base_menu_item.item_type = item_type
             base_menu_item.add_widget(icon_widget)
             base_menu_item.bind(on_release=self.pressed_item)
             if info_list_lines > 0:
                 info_card = MDCard(size_hint_x=.8,
                                    size_hint_y=None,
                                    height=dp(35) * len(info_list_lines))
                 info_text = ""
                 for line in info_list_lines:
                     info_text += add_refs(line) + "\n"
                 info_list_lines = []
                 info_label = MDLabel(pos_hint={
                     "center_x": .5,
                     "center_y": .5
                 },
                                      text=info_text,
                                      halign="center",
                                      size_hint_y=None,
                                      markup=True)
                 info_label.height = info_label.texture_size[1]
                 info_label.font_style = "Body1"
                 #info_recycleview.add_widget(info_label)
                 info_layout = FloatLayout()
                 info_layout.add_widget(info_label)
                 #info_card.height = info_l
                 info_card.add_widget(info_layout)
                 self.add_menu_widget(info_card)
             self.add_menu_widget(base_menu_item)
         if item_type == "i":
             info_list_lines.append(item_description)
Exemple #12
0
 def get_text_page(self):
     text_card = MDCard(size_hint=(0.5, 0.9),
                        pos_hint={'center_x': 0.25, 'center_y': 0.55})
     text_label = MDLabel(disabled=True, pos_hint={'center_x': 0.5, 'center_y': 0.5},
                          halign='center', valign='top', theme_color='Secondary',
                          font_style='Body1', size_hint_y=None)
     text_label.text = self.current_story.get_story_text()
     text_card.add_widget(text_label)
     return text_card
Exemple #13
0
 def Del_Stud_DB(self, text):
     self.te = ''
     self.chkref = {}
     self.Selected_Students = []
     db = mysql.connector.connect(host='localhost',
                                  user='******',
                                  passwd='P@$$W0RD')
     my = db.cursor()
     my.execute('use Voice_Comparer')
     sql = 'select * from student where StudentId = %s or name = %s or Branch = %s or class = %s or sec = %s or year = %s'
     print(type(text))
     val = (
         text,
         text,
         text,
         text,
         text,
         text,
     )
     my.execute(
         sql,
         val,
     )
     res = my.fetchall()
     print(len(res))
     inner = ScrollView(size_hint=(1, 1),
                        pos_hint={
                            'center_x': 0,
                            'center_y': .5
                        })
     grid = GridLayout(cols=1, spacing=10, size_hint_y=None, padding=dp(10))
     grid.bind(minimum_height=grid.setter('height'))
     if len(res) > 0:
         for row in res:
             string = str(row[0]) + ' ' + row[1] + ' ' + row[2] + ' ' + row[
                 3] + ' ' + row[4] + ' ' + str(row[5])
             print(string)
             b = BoxLayout(orientation='horizontal', size_hint=(1, None))
             checkbox = MDCheckbox()
             checkbox.bind(active=self.Checking)
             self.chkref[checkbox] = row[0]
             label = MDLabel(text=string)
             b.add_widget(label)
             b.add_widget(checkbox)
             grid.add_widget(b)
         inner.add_widget(grid)
     else:
         inner.add_widget(MDLabel(text='There is no Students Here!!!'))
         pass
     popup = Popup(title='Select Files',
                   size_hint=(1, .8),
                   content=inner,
                   auto_dismiss=True)
     popup.open()
Exemple #14
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
Exemple #15
0
    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()
Exemple #16
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()
Exemple #18
0
    def __init__(self, type, title, body, idx, parent_shape):
        """

        :param type: card type, 'left' or 'right'
        :param title: text in title
        :param body: text in body
        :param idx: idx of message card, to set position
        :param parent_shape: parent widget shape in [width, height], to compute position
        """
        print("MessageCard's parent's shape: {}".format(parent_shape))
        print('Color: {}'.format(get_color_from_hex(colors['Blue']['200'])))
        if type == 'left':
            self.message_card = MDCard(
                size_hint=(None, None),
                size=(dp(160), dp(90)),
                left=dp(60),
                top=dp(parent_shape[1] - 10 - 100 * idx),
                md_bg_color=get_color_from_hex(colors['Blue']['200']),
                background_palette='DeepPurple',
                background_hue='A400',
                border_radius=dp(10))
        elif type == 'right':
            self.message_card = MDCard(
                size_hint=(None, None),
                size=(dp(160), dp(90)),
                right=dp(parent_shape[0] - 80),
                top=dp(parent_shape[1] - 10 - 100 * idx),
                md_bg_color=get_color_from_hex(colors['Green']['200']),
                border_radius=dp(10))
        else:
            raise Exception, 'Card Type Error'

        msgbox = BoxLayout(orientation='vertical', padding=dp(8))
        msgbox.add_widget(MDLabel(text=body, theme_text_color='Primary'))
        self.message_card.add_widget(msgbox)
    def _update_content(self, collection_snapshot):
        """Fetch my posted deliveries"""
        self.content = self.ids.content
        delivery_requests = []
        for doc in collection_snapshot:
            data = doc.to_dict()
            data['uid'] = doc.id
            data['status'] = Status(data['status'])
            if data['status'] == Status.CANCELLED_BY_OWNER:
                continue

            delivery_requests.append(DeliveryRequest(**data))

        # Fill delivery list
        self.ids.my_requests.clear_widgets()
        no_content = True
        for req in delivery_requests:
            no_content = False
            self.ids.my_requests.add_widget(
                MyPostedRequest(req, self._transition_to_detail_view))

        if self.no_content_label is not None:
            self.ids.content.remove_widget(self.no_content_label)

        # Add no content label if no content is shown
        if no_content:
            self.no_content_label = MDLabel(
                id="no_content_label",
                text="""You currently do not have any posted packages.\n
                Request deliveries with the package button down below.             """,
                size_hint_y=9,
                halign="center",
                font_style='Subtitle1')
            self.ids.content.add_widget(self.no_content_label)
Exemple #20
0
    def build_interface(self):
        # Change notch color and image
        self.notch_color = self.theme_cls.primary_color
        self.notch_source = ""

        # Buid the calendar widget
        if self.date_picker:
            # The user picked a new date and needs to update the calendar
            self.root.ids.main_layout.remove_widget(self.date_picker)
            self.root.ids.main_layout.remove_widget(self.bottom_label)

        self.date_picker = MDDatePicker(elevation=0)
        self.root.ids.main_layout.add_widget(self.date_picker)

        # Build the scrolling suggestion field
        day = calendar.day_name[date.today().weekday()]  # 'Wednesday'
        colored_label = self.date_picker.ids.label_full_date

        self.bottom_label = MDLabel(
            text=day + "'s suggested activity: " +
            self.workout_suggestions[date.today().weekday()],
            text_color=colored_label.text_color,
            theme_text_color='Custom',
            halign='center')
        colored_label.bind(text_color=self.reset_bottom_text_color)
        self.root.ids.main_layout.add_widget(self.bottom_label)
Exemple #21
0
    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()
Exemple #22
0
    def _get_contacts_group(self, contacts_group):
        '''Возвращает объект MDLabel - "Контактов нет",
        если контакты в группе отсутствуют или объект со списком
        добавленных в группу контактов.'''

        if not contacts_group.__len__():
            return MDLabel(text=self.data.string_lang_not_contacts,
                           font_style='Headline',
                           halign='center',
                           theme_text_color='Custom',
                           text_color=self.data.text_color)
        else:
            for contact_name in contacts_group:
                info_contacts = {
                    contact_name: self.info_contacts[contact_name]
                }
                if not self._contacts_list_in_group:
                    contacts_list = ContactsList()
                    self._contacts_list_in_group = Lists(
                        dict_items=info_contacts,
                        flag='three_list_custom_icon',
                        right_icons=self.data.right_icons[:1],
                        events_callback=self._event_contact_item)
                    contacts_list.add_widget(self._contacts_list_in_group)
                else:
                    self._contacts_list_in_group.three_list_custom_icon(
                        info_contacts)
            self._contacts_list_in_group = None

            return contacts_list
Exemple #23
0
 def Compare_DB(self, StudId, File):
     db = mysql.connector.connect(host='localhost',
                                  user='******',
                                  passwd='P@$$W0RD')
     my = db.cursor()
     my.execute('use Voice_Comparer')
     sql = 'select * from Student_Data_By_Path where StudentId = %s'
     val = (StudId, )
     my.execute(
         sql,
         val,
     )
     res = my.fetchall()
     if len(res) > 0:
         self.Compare_Res(StudId, File)
     else:
         print('Please Enter the Student ID correctly...')
         inner = ScrollView(size_hint=(1, 1),
                            pos_hint={
                                'center_x': 0,
                                'center_y': .5
                            })
         inner.add_widget(MDLabel(text='There is No Files here!!!'))
         popup = Popup(title='Select Files',
                       size_hint=(.8, .8),
                       content=inner,
                       auto_dismiss=True)
     pass
Exemple #24
0
    def fetchVideo(self, url):
        box_vertical = self.ids.b1
        self.yt = YouTube(url)
        self.yt.register_on_complete_callback(self.downloadComplete)
        self.yt.register_on_progress_callback(self.showProgressBar)

        v_strms = self.yt.streams.filter(progressive=True).all()
        a_strms = self.yt.streams.filter(only_audio=True).first()
        self.selected = self.yt.streams.first()

        v_strms.append(a_strms)
        self.streams = v_strms

        for index, eachStream in enumerate(self.streams):
            box_horizontal = BoxLayout(orientation='horizontal')
            checkbox = MDCheckbox(id=str(index), group='test', size_hint_x=.2)
            checkbox.bind(active=self.cb_clicked)
            video_details = 'Format: ' + str(
                eachStream.mime_type) + ', Resolution: ' + str(
                    eachStream.resolution)
            label = MDLabel(text=video_details,
                            font_style='Body1',
                            theme_text_color='Primary',
                            size_hint_x=.8,
                            width='56dp')
            box_horizontal.add_widget(checkbox)
            box_horizontal.add_widget(label)
            box_vertical.add_widget(box_horizontal)

        self.ids.spinner.active = False
Exemple #25
0
def card(content, title=None, background_color=None, size=(.7, .5)):
    '''Вывод диалоговых окон с кастомным контентом.'''

    if not background_color:
        background_color = [1.0, 0, 0, 1]

    card = MDCard(size_hint=(1, 1),
                  padding=5)  #, background_color=background_color)

    if title:
        box = BoxLayout(orientation='vertical', padding=dp(8))
        box.add_widget(
            MDLabel(text=title,
                    theme_text_color='Secondary',
                    font_style="Title",
                    size_hint_y=None,
                    height=dp(36)))
        box.add_widget(MDSeparator(height=dp(1)))
        box.add_widget(content)
        card.add_widget(box)
    else:
        card.add_widget(content)

    dialog = ModalView(size_hint=size, background_color=[0, 0, 0, .2])
    dialog.add_widget(card)
    dialog.open()

    return dialog
Exemple #26
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()
Exemple #27
0
    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()
Exemple #28
0
 def on_press(self):
     print("yead", self.text)
     content = MDLabel(text=self.text)
     ReadPopup(title=self.text,
               size_hint=(0.8, 0.2),
               content=content,
               background="./assets/rss_back.png").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()
Exemple #30
0
    def _update_content(self, collection_snapshot):
        """Fetch all deliveries the current owner has accepted"""
        delivery_requests = []
        for doc in collection_snapshot:
            data = doc.to_dict()
            data['uid'] = doc.id
            data['status'] = Status(data['status'])
            delivery_requests.append(DeliveryRequest(**data))

        # Fill delivery list
        self.ids.my_deliveries.clear_widgets()
        no_content = True
        for req in delivery_requests:
            if req.status == Status.DELIVERED:
                continue

            no_content = False
            self.ids.my_deliveries.add_widget(
                ListItem(req, self._transition_to_detail_view))

        if self.no_content_label is not None:
            self.ids.content.remove_widget(self.no_content_label)

        # Add no content label if no content is shown
        if no_content:
            self.no_content_label = MDLabel(
                id="no_content_label",
                text="""You currently do not have any packages to deliver.\n
                Accept deliveries by searching for them.                  """,
                size_hint_y=9,
                halign="center",
                font_style='Subtitle1')
            self.ids.content.add_widget(self.no_content_label)

        self.content = self.ids.content
Exemple #31
0
    def __init__(self, **kwargs):

        GridLayout.__init__(self, **kwargs)
        Thread.__init__(self)

        self.cols = 1
        self.tool = ntoolbar(title='KivDL')
        self.add_widget(self.tool)
        self.body = GridLayout(cols=1, padding=(0, 20))
        self.add_widget(self.body)
        self.tex = MDTextField(pos_hint={'center_y': 0.9}, size_hint_x=0.8)
        self.tex.hint_text = " Enter URL to download"

        self.fetch_button = MDRaisedButton(text='Fetch',
                                           pos_hint={
                                               'center_y': 0,
                                               'right': 0.95
                                           },
                                           size_hint_x=0.1)
        self.fetch_button.bind(on_press=self.addcard)
        self.urlget = GridLayout(cols=2, size_hint_y=0.2)
        self.urlget.add_widget(self.tex)
        self.urlget.add_widget(self.fetch_button)
        self.body.add_widget(self.urlget)

        self.cardholder = ScrollView(do_scroll_x=False, size_hint_x=0.8)
        self.cardlist = MDList(padding=(10, 20))
        self.cardlist.spacing = (10, 20)
        self.cardholder.add_widget(self.cardlist)

        self.body.add_widget(self.cardholder)
        self.spacer = MDLabel(size_hint_y=0.2)
        self.cardlist.add_widget(self.spacer)
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
Exemple #33
0
    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'))
Exemple #34
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