示例#1
0
文件: main.py 项目: salhi100/KivyMD
    def set_expansion_panel(self):
        from kivymd.uix.expansionpanel import MDExpansionPanel

        def callback(text):
            toast(f"{text} to {content.name_item}")

        content = ContentForAnimCard(callback=callback)

        for name_contact in self.names_contacts:
            self.data["Expansion Panel"]["object"].ids.anim_list.add_widget(
                MDExpansionPanel(
                    content=content,
                    icon="assets/kivy-logo-white-512.png",
                    title=name_contact,
                ))
    def build_local_panel(self):
        self.root.ids.result.clear_widgets(self.root.ids.result.children)

        options = self.bdd_get_chambres()
        if (len(options) != 0):
            for id, nom in options:
                content = Content()
                content.build_data(self.bdd_get_commandes(id))
                panel = MDExpansionPanel(icon="room.png",
                                         content=content,
                                         panel_cls=MDExpansionPanelOneLine(
                                             text=nom, ))
                self.root.ids.result.add_widget(panel)
        else:
            toast(" veuillez synchronizer ")
def introduction(self):
    dic = {'WSTĘP': IntroductionContent, "MATERIAłY OBRABIANE": MaterialsContent, 'KRAWĘDŹ SKRAWAJĄCA': EdgeContent,
           'MATERIAŁY NARZĘDZIOWE': ToolsMaterialsContent, 'ZUŻYCIE I KONSERWACJA': UsageContent}

    for i in dic:
        self.root.ids.machining_introduction_screen.ids.box.add_widget(
            MDExpansionPanel(
                icon="icons/education.png",
                content=dic[i](),
                panel_cls=MDExpansionPanelOneLine(
                    text=i,
                    font_style=theme_font_styles[9]

                )
            )
        )
示例#4
0
    def on_start(self):
        self.custom_dialogs = CustomDialogs()
        self.custom_pickers = CustomPickers()
        self.custom_tap_target_views = CustomTapTargetViews(app=self)

        # Set up the menus for the menu screen
        menu_items = [{"icon": "git", "text": f"Item {i}"} for i in range(5)]
        self.menu_1 = MDDropdownMenu(
            caller=self.root.ids.MD_menu_screen.ids.button_1,
            items=menu_items,
            width_mult=4,
            position='center')
        self.menu_2 = MDDropdownMenu(caller=self.root.ids.MD_menu_screen.ids.
                                     custom_toolbar.ids.button_2,
                                     items=menu_items,
                                     width_mult=4)

        # Set up the swipe cards for card screen
        for i in range(10):
            self.root.ids.MD_card_swipe_screen.ids.MD_card_swipe_demo.add_widget(
                SwipeToDeleteItem(text=f'Item {i}'))
            self.root.ids.MD_expansion_panel_screen.ids.box.add_widget(
                MDExpansionPanel(icon=r'kivymd/images/kivymd_logo.png',
                                 content=ExpansionPanelContent(),
                                 panel_cls=MDExpansionPanelThreeLine(
                                     text="Text",
                                     secondary_text="Secondary text",
                                     tertiary_text="Tertiary text",
                                 )))

        # Set up the tabs for tab screen
        tabs = ['Home', 'Search', 'Friends', 'History', 'Account', 'Settings']
        for tab in tabs:
            self.root.ids.MD_tabs_screen.ids.tabs_holder.add_widget(
                CustomTab(text=tab))

        # Update the current toolbar
        current_screen = self.root.ids.screen_manager.current
        toolbar = self.root.ids[current_screen].ids.toolbar
        toolbar.left_action_items = [[
            'menu', lambda x: self.root.ids.nav_drawer.set_state('toggle')
        ]]

        # If on ios, do this to display the ad banner
        if platform == 'ios':
            from pyobjus import autoclass
            self.banner_ad = autoclass('adSwitch').alloc().init()
示例#5
0
 def on_start(self):
     Clock.schedule_interval(self.update_news,
                             5)  # every 5 seconds, show the next story
     for category in self.card_file:
         panel = MDExpansionPanel(
             icon="scr2.png",
             content=Content(),
             panel_cls=MDExpansionPanelTwoLine(
                 text=category['Category'],
                 secondary_text="Tap to view Hospitals"))
         self.root.ids.scr_mngr.get_screen(
             'locsearch').ids.rlist.add_widget(panel)
         for rec in category['Record']:
             rw = RecordLine(text=rec['title'])
             print(rec['title'])
             self.root.ids.scr_mngr.get_screen(
                 'locsearch').ids.rlist.children[0].content.add_widget(rw)
示例#6
0
    def add_content(self, lang):
        '''Adds main content in the specified language to the HomeScreen'''
        self.home_content.clear_widgets()
        self.titles = languages[lang]['home_titles']
        self.texts = languages[lang]['home_texts']

        for tls, txs, ics in zip(self.titles, self.texts, self.icons):
            content = MDBoxLayout(adaptive_height=True,
                                  orientation='vertical',
                                  padding=[dp(25), dp(100)])
            content.add_widget(
                MDLabel(text=txs,
                        size_hint=(1, None),
                        height=dp(Window.height * .1),
                        theme_text_color='Secondary'))
            self.home_content.add_widget(
                MDExpansionPanel(icon='images/' + ics,
                                 content=content,
                                 panel_cls=MDExpansionPanelOneLine(text=tls)))
示例#7
0
    def menu_item_callback(self, instance, value):

        returned_list = search(value, parsed_date)
        self.root.ids.main_content.clear_widgets()
        for doggy in returned_list:
            cont = Content()
            cont.update(
                ItemDrawer(icon='images/id.png', text=f" Id - {doggy.id}"))
            cont.update(
                ItemDrawer(icon='images/tem3.png',
                           text=f" Temperament - {doggy.temperament}"))
            self.root.ids.main_content.add_widget(
                MDExpansionPanel(
                    icon=f"images/doggy2.png",
                    content=cont,
                    panel_cls=MDExpansionPanelThreeLine(
                        text=doggy.name,
                        secondary_text=f"Life span - {doggy.life_span}",
                        tertiary_text=f"Weight - {doggy.weight} kg",
                    )))
示例#8
0
文件: main.py 项目: joelzxcv/ver16
 def on_start(self):
     conn = sql.connect('USERINFO.db')
     cur = conn.cursor()
     cur.execute(""" 
                      SELECT fname, age, height, weight, heartrate, RESULT, DATE_TIME
                      FROM information INNER JOIN results
                      ON information.id = results.UID
                      """)
     output = cur.fetchall()
     self.row_data = output
     # for data in output:
     #     self.row_data = data
     self.column_data = [("Name", dp(35)), ("Age", dp(25)),
                         ("Height", dp(25)), ("Weight", dp(25)),
                         ("Heartrate", dp(25)), ("Result", dp(25)),
                         ("Date/Time", dp(35))]
     self.data_tables = MDDataTable(size_hint=(0.9, 0.6),
                                    use_pagination=True,
                                    column_data=self.column_data,
                                    row_data=self.row_data)
     self.root.ids.scr_mngr.get_screen('history').ids.dt_layout.add_widget(
         self.data_tables)
     Clock.schedule_interval(self.update_news,
                             5)  # every 5 seconds, show the next story
     for category in self.card_file:
         panel = MDExpansionPanel(
             icon="scr2.png",
             content=Content(),
             panel_cls=MDExpansionPanelTwoLine(
                 text=category['Category'],
                 secondary_text="Tap to view Hospitals"))
         self.root.ids.scr_mngr.get_screen(
             'locsearch').ids.rlist.add_widget(panel)
         for rec in category['Record']:
             rw = RecordLine(text=rec['title'])
             var = (rec['title'])
             self.root.ids.scr_mngr.get_screen(
                 'locsearch').ids.rlist.children[0].content.add_widget(rw)
示例#9
0
    def on_enter(self):
        if self.has_already_opened:
            return
        else:
            self.has_already_opened = True

        content_for_panel = MoreInformation()
        md_expansion_panel = MDExpansionPanel(
            content=content_for_panel,
            icon=f"{PATH_TO_IMAGES}/information.png",
            panel_cls=MDExpansionPanelOneLine(text="More information"),
        )
        self.ids.expansion_panel_box.add_widget(md_expansion_panel)

        path = f"{PATH_TO_IMAGES}/previous_crop.jpg"
        if not os.path.exists(path):
            crop_image(
                (Window.width, int(dp(Window.height * 35 // 100))),
                f"{PATH_TO_IMAGES}/previous.jpg",
                path,
            )
        Clock.schedule_once(lambda x: self.set_path_to_image_product(path),
                            0.2)
示例#10
0
    def add_color_panel(self):
        def set_list_colors_themes(*args):
            self.settings_theme_panel_open = True
            if not theme_panel.content.ids.rv.data:
                for name_theme in palette:
                    theme_panel.content.ids.rv.data.append({
                        "viewclass":
                        "FileManagerSettingsColorItem",
                        "color":
                        get_color_from_hex(colors[name_theme]["500"]),
                        "text":
                        name_theme,
                        "manager":
                        self,
                    })

        # Adds a panel.
        theme_panel = MDExpansionPanel(
            icon="palette",
            content=Factory.FileManagerChangeTheme(),
            panel_cls=MDExpansionPanelOneLine(text="Select theme"),
        )
        theme_panel.bind(
            on_open=set_list_colors_themes,
            on_close=self._set_state_close_theme_panel,
        )
        self.ids.settings.add_widget(theme_panel)

        # Adds a close button to the settings panel.
        box = MDBoxLayout(adaptive_height=True)
        box.add_widget(Widget())
        box.add_widget(
            MDFlatButton(
                text="CLOSE",
                on_release=lambda x: self.hide_settings(theme_panel),
            ))
        self.ids.settings.add_widget(box)
示例#11
0
    def on_enter(self):
        if self.has_already_opened:
            return
        else:
            self.has_already_opened = True

        content_for_panel = MoreInformation()
        md_expansion_panel = MDExpansionPanel(
            content=content_for_panel,
            icon="data/images/information.png",
            title="More information",
        )
        md_expansion_panel.bind(on_open=self.on_panel_open)
        md_expansion_panel.bind(on_close=self.on_panel_close)
        self.ids.expansion_panel_box.add_widget(md_expansion_panel)

        path = "data/images/previous_crop.jpg"
        if not os.path.exists(path):
            crop_image(
                (Window.width, int(dp(Window.height * 35 // 100))),
                f"data/images/previous.jpg",
                path,
            )
        Clock.schedule_once(lambda x: self.set_path_toImage_product(path), 0.2)
示例#12
0
 def on_start(self):
     panel = MDExpansionPanel(title="Perfil", icon="índice.png", content=MyContent())
     self.root.ids.panel_container.add_widget(panel)
示例#13
0
    def checklist_screen(
        self,
        event,
        id,
        nome_lv,
        descricao_lv,
        data_emissao,
        porcentagem_c,
        quantidade_nc,
        quantidade_na,
        lv_status,
        item1_nome,
        item1_resultado,
        item1_acao,
        item1_prazo,
        item1_responsavel,
        item2_nome,
        item2_resultado,
        item2_acao,
        item2_prazo,
        item2_responsavel,
        item3_nome,
        item3_resultado,
        item3_acao,
        item3_prazo,
        item3_responsavel,
        item4_nome,
        item4_resultado,
        item4_acao,
        item4_prazo,
        item4_responsavel,
        item5_nome,
        item5_resultado,
        item5_acao,
        item5_prazo,
        item5_responsavel,
        item6_nome,
        item6_resultado,
        item6_acao,
        item6_prazo,
        item6_responsavel,
        item7_nome,
        item7_resultado,
        item7_acao,
        item7_prazo,
        item7_responsavel,
        item8_nome,
        item8_resultado,
        item8_acao,
        item8_prazo,
        item8_responsavel,
        item9_nome,
        item9_resultado,
        item9_acao,
        item9_prazo,
        item9_responsavel,
    ):

        self.manager.current = "screen3"
        self.manager.get_screen("screen3").ids.screen3_toolbar.title = nome_lv

        items = {
            "item1_nome": item1_nome,
            "item1_resultado": item1_resultado,
            "item1_acao": item1_acao,
            "item1_prazo": item1_prazo,
            "item1_responsavel": item1_responsavel,
            "item2_nome": item2_nome,
            "item2_resultado": item2_resultado,
            "item2_acao": item2_acao,
            "item2_prazo": item2_prazo,
            "item2_responsavel": item2_responsavel,
            "item3_nome": item3_nome,
            "item3_resultado": item3_resultado,
            "item3_acao": item3_acao,
            "item3_prazo": item3_prazo,
            "item3_responsavel": item3_responsavel,
            "item4_nome": item4_nome,
            "item4_resultado": item4_resultado,
            "item4_acao": item4_acao,
            "item4_prazo": item4_prazo,
            "item4_responsavel": item4_responsavel,
            "item5_nome": item5_nome,
            "item5_resultado": item5_resultado,
            "item5_acao": item5_acao,
            "item5_prazo": item5_prazo,
            "item5_responsavel": item5_responsavel,
            "item6_nome": item6_nome,
            "item6_resultado": item6_resultado,
            "item6_acao": item6_acao,
            "item6_prazo": item6_prazo,
            "item6_responsavel": item6_responsavel,
            "item7_nome": item7_nome,
            "item7_resultado": item7_resultado,
            "item7_acao": item7_acao,
            "item7_prazo": item7_prazo,
            "item7_responsavel": item7_responsavel,
            "item8_nome": item8_nome,
            "item8_resultado": item8_resultado,
            "item8_acao": item8_acao,
            "item8_prazo": item8_prazo,
            "item8_responsavel": item8_responsavel,
            "item9_nome": item9_nome,
            "item9_resultado": item9_resultado,
            "item9_acao": item9_acao,
            "item9_prazo": item9_prazo,
            "item9_responsavel": item9_responsavel,
        }

        for i in range(1, 10):

            self.list_item = ThreeLineIconListItem(
                text=items[f"item{i}_nome"],
                secondary_text=items[f"item{i}_resultado"])

            self.manager.get_screen("screen3").ids.box.add_widget(
                self.list_item)

        for i in range(1, 10):
            self.list_item = MDExpansionPanel(
                content=Content(),
                on_open=self.panel_open,
                on_close=self.panel_close,
                icon=f"kivymd.png",
                panel_cls=MDExpansionPanelThreeLine(
                    text=items[f'item{i}_nome'],
                    secondary_text=items[f'item{i}_resultado'],
                    tertiary_text=items[f'item{i}_prazo']))

            self.manager.get_screen('screen3').ids.my_checklist.add_widget(
                self.list_item)

            if items[f'item{i}_resultado'] == 'Não conforme':
                self.list_item.content.ids.list.add_widget(
                    MDTextField(
                        text=items[f'item{i}_acao'],
                        size_hint=(0.98, 0.1),
                        hint_text='Ação para uma não conformidade!',
                        icon_right='inbox',
                    ))
                self.list_item.content.ids.list.add_widget(
                    MDTextField(
                        text=items[f'item{i}_prazo'],
                        size_hint=(0.98, 0.1),
                        hint_text='Prazo para uma não conformidade!',
                        icon_right='inbox',
                    ))
                self.list_item.content.ids.list.add_widget(
                    MDTextField(
                        text=items[f'item{i}_responsavel'],
                        size_hint=(0.98, 0.1),
                        hint_text='Responsável para uma não conformidade!',
                        icon_right='inbox',
                    ))
示例#14
0
    def today(self):

        mycursor = main.sqliteConnection.cursor()
        mycursor.execute("SELECT b.id_task, a.task_name, a.scheduled_time "
                         "FROM task_type a "
                         "JOIN work_plan b "
                         "ON a.id_type=b.id_type "
                         "WHERE b.scheduled_date = date('now') "
                         "          AND b.done_date IS NULL")
        rows = mycursor.fetchall()

        task_id = []
        task_name = []
        task_time = []

        for i in range(len(rows)):
            task_id.append(rows[i][0])
            task_name.append(rows[i][1])
            task_time.append(rows[i][2])

        for i in range(len(task_name)):
            self.ids.today_list.add_widget(
                MDExpansionPanel(
                    icon='graphics/bart.jpg',
                    content=ItemContent(),
                    panel_cls=MDExpansionPanelTwoLine(
                        text=f'{str(task_name[i])}',
                        secondary_text=f'{str(task_time[i])} minutes',
                        on_press=partial(
                            task,
                            task_id[i],
                        ))))

        mycursor.execute(f"SELECT sum(a.scheduled_time) "
                         f"FROM task_type a "
                         f"JOIN work_plan b "
                         f"ON a.id_type=b.id_type "
                         f"WHERE b.scheduled_date = date('now') "
                         f"         AND b.done_date IS NULL")
        row = mycursor.fetchone()

        try:
            time = str(int(row[0]))

            self.ids.time.add_widget(
                MDLabel(text=f"W O R K  T I M E: {time} minutes",
                        halign='center',
                        pos_hint={
                            "center_x": 0.5,
                            "center_y": 0.8
                        },
                        theme_text_color='Custom',
                        text_color=get_color_from_hex('#3CB371'),
                        font_style='Caption',
                        font_size=10))
        except:
            self.ids.time.add_widget(
                MDLabel(text="F R E E  T I M E! \nP L A N  Y O U R  D A Y",
                        halign='center',
                        pos_hint={
                            "center_x": 0.5,
                            "center_y": 0.8
                        },
                        theme_text_color='Custom',
                        text_color=get_color_from_hex('#3CB371'),
                        font_style='Caption',
                        font_size=20))
示例#15
0
    def analyze(self, main): # main is pointing to ---> Main().show_data()
        """Analyse data with bighugelabs API"""
        sent = main.ids.sentence.text.lower()
        if LIST == []:
            self.empty()
        else:
            wrd = LIST[-1].lower()

            if wrd != '' and sent != '':
                API_KEY = 'a701e74e453ee6695e450310340401f5'
                URL = f'http://words.bighugelabs.com/api/2/{API_KEY}/{wrd}/json'

                if wrd not in sent:
                    #print("if wrd not in sent")
                    error = MDDialog(title="Error", text=f"Word: '{wrd}' is not in\n\n'{sent}'")
                    error.open()
                else:
                    #print("else...")
                    r = requests.get(URL) # get's url json file
                    try:
                        #print("j = json...")
                        j = json.loads(r.text) # loads json into 'j' as a dict
                    except KeyError:
                        #print("j = {/}")
                        j = {''}
                    if type(j) == dict: # check is 'j' variable is coming in as a Dict holds the new sentences new = f"{result}\n"
                        words = set()
                        try:
                            for w in j['adjective']['syn']:
                                words.add(w)
                        except KeyError:
                            pass
                            #print(f'Adjective for "{wrd}" is not found.')
                        try:
                            for w in j['noun']['syn']:
                                words.add(w)
                        except KeyError:
                            pass
                            #print(f'Noun for "{wrd}" is not found.') 
                        try:
                            for w in j['verb']['syn']:
                                words.add(w)
                        except KeyError:
                            pass
                            #print(f'Verb for "{wrd}" is not found.')

                        item = TwoLineListItem(text=f"Original sentence: {sent}", secondary_text=f"Analyze word: {wrd}", on_release=self.define)
                        self.ids.container.add_widget(item)
                        for word in words:
                            dictionary = self.load_json("dictionary.json")
                            # w = wordnet.synsets(word) # getting definition from nltk
                            try:
                                definition = dictionary[word.upper()]
                                # definition = str(w[0].definition())
                            except KeyError:
                                definition = "No definition found..."

                            item = TwoLineListItem(text=f"Definition '{word}': ", secondary_text=definition)
                            content = MDExpansionPanel(icon=f'{PATH}/dot.png',
                                                       content=item,
                                                       panel_cls=MDExpansionPanelTwoLine(
                                                            text=f"{sent.replace(wrd, word).lower()}",
                                                            secondary_text=f"{word.lower()}",
                                                        ))
                            self.ids.container.add_widget(content)
            else:
                self.empty()
示例#16
0
    def reload(self):
        try:
            students = api.students()
        except Exception as e:
            Snackbar(
                text=f"You seem to be offline, trying again in 10 seconds.",
                snackbar_x="10dp",
                snackbar_y="10dp",
                size_hint_x=.5).open()
            print(str(e))
            Clock.schedule_once(lambda *args: self.reload(), 10)
            return
        try:
            attendance = api.attendance()
        except Exception as e:
            Snackbar(
                text=f"You seem to be offline, trying again in 10 seconds.",
                snackbar_x="10dp",
                snackbar_y="10dp",
                size_hint_x=.5).open()
            print(str(e))
            Clock.schedule_once(lambda *args: self.reload(), 10)
            return

        self.attendance.clear_widgets()

        self.today_att = AttendanceContent()
        self.yesterday_att = AttendanceContent()

        std = MDExpansionPanel(content=self.today_att,
                               panel_cls=MDExpansionPanelOneLine(text="Today"))
        self.attendance.add_widget(std)
        std = MDExpansionPanel(
            content=self.yesterday_att,
            panel_cls=MDExpansionPanelOneLine(text="Yesterday"))
        self.attendance.add_widget(std)

        today = datetime.today()
        today_ = today.strftime('%Y-%m-%d')
        yesterday = (today - timedelta(days=1)).strftime('%Y-%m-%d')
        for student in students:
            if student['status'] == 'inactive':
                continue
            try:
                info = next(att for att in attendance
                            if att['student_id'] == student['id']
                            and att['date'] == today_)
            except StopIteration:
                info = {
                    'student_id': student['id'],
                    'date': today_,
                    'status': ''
                }

            att = Attendance(student_name=student['student_name'],
                             group='today' + student['id'],
                             state=info['status'],
                             student_id=info['student_id'],
                             date=today_)
            self.today_att.add_widget(att)

            has_yesterday = any(att['status'] for att in attendance
                                if att['student_id'] == student['id']
                                and att['date'] == yesterday)
            if not has_yesterday:
                att = Attendance(student_name=student['student_name'],
                                 group='yesterday' + student['id'],
                                 student_id=student['id'],
                                 date=yesterday)
                self.yesterday_att.add_widget(att)