コード例 #1
0
    def build(self):
        screen = Screen()

        # Creating a Simple List
        scroll = ScrollView()

        list_view = MDList()
        for i in range(20):

            item = ThreeLineIconListItem(text=str(i) + ' item',
                                         secondary_text='This is ' + str(i) +
                                         'th item',
                                         tertiary_text='hello')

            icons = IconLeftWidget(icon="cake-layered")
            #items = OneLineIconListItem(text=str(i) + ' item')

            item.add_widget(icons)
            list_view.add_widget(item)
        # list_view.add_widget(items)

        scroll.add_widget(list_view)
        # End List

        screen.add_widget(scroll)
        return screen
コード例 #2
0
ファイル: test.py プロジェクト: projectabhi/KivyMD-Basics
    def build(self):
        screen = Screen()
        scroll = ScrollView()
        list_view = MDList()
        scroll.add_widget(list_view)

        for i in range(20):
            item = OneLineListItem(text="Item " + str(i))
            list_view.add_widget(item)

        item2 = TwoLineListItem(text="Two Line item1",
                                secondary_text="Hello world")
        item3 = ThreeLineListItem(text="Three Line item1",
                                  secondary_text="Hello world",
                                  tertiary_text="Sample text")
        icon = IconLeftWidget(icon="android")
        itemicon = ThreeLineIconListItem(text="Three Line item1",
                                         secondary_text="Hello world",
                                         tertiary_text="Sample text")
        itemicon.add_widget(icon)

        list_view.add_widget(item2)
        list_view.add_widget(item3)
        list_view.add_widget(itemicon)
        screen.add_widget(scroll)
        return screen
コード例 #3
0
 def refresh_names_navdrawer(self):
     for i in self.nav_buttons:
         val = i.val
         i.text = eval(val)
     # Заодно обновим дату
     for i in range(7):
         item = ThreeLineIconListItem()
         item.text = DAYOFWEEK_DICT[i]
         item.secondary_text = ", ".join(SCHEDULE.get(i, DEFAULT_SCHED))
         self.main_widget.ids.rasp_all_list.add_widget(item)
     self.refresh_data()
コード例 #4
0
 def load_checklists_screen_main(self):
     store = JsonStore("dataChecklist.json")
     self.list_name = store.get('UserInfo')['name']
     criado_por = store.get('UserInfo')['data']
     criado_em = store.get('UserInfo')['responsavel']
     
     self.list_name = ThreeLineIconListItem(
     text=self.list_name,
     secondary_text='Responsável: ' + criado_por,
     tertiary_text='Data de emissão: ' + criado_em, on_release=self.change_screen)
     self.list_name.add_widget(IconLeftWidget(icon='check-box-outline'))
     self.strng.get_screen('screen2').ids.my_checklists.add_widget(self.list_name)
     self.strng.get_screen('screen1').manager.current = 'screen1'
コード例 #5
0
    def build(self):
        screen = Screen()
        self.theme_cls.primary_palette = "Green"

        list_view = MDList()

        scroll = ScrollView()
        scroll.add_widget(list_view)

        for i in range(1, 21):
            if i % 2 == 0:
                icon = IconLeftWidget(icon="android")

                item = ThreeLineIconListItem(
                    text=f"Item {i}",
                    secondary_text="Three lines version",
                    tertiary_text="Third line")
                item.add_widget(icon)

            else:
                image = ImageLeftWidget(source="logoC.png")

                item = ThreeLineAvatarListItem(
                    text=f"Item {i}",
                    secondary_text="Three lines version",
                    tertiary_text="Third line")
                item.add_widget(image)

            list_view.add_widget(item)

        screen.add_widget(scroll)

        return screen
コード例 #6
0
    def on_start(self):
        for i in range(1,21):
            if i % 2 == 0:
                icon = IconLeftWidget(
                    icon="android"
                )

                item =  ThreeLineIconListItem(
                    text=f"Item {i}",
                    secondary_text="Three lines version",
                    tertiary_text="Third line"
                )
                item.add_widget(icon)

            else:
                image = ImageLeftWidget(
                    source="logoC.png"
                )

                item =  ThreeLineAvatarListItem(
                    text=f"Item {i}",
                    secondary_text="Three lines version",
                    tertiary_text="Third line"
                )
                item.add_widget(image)


            self.root.ids.container.add_widget(item)
コード例 #7
0
 def history(self):
     self.root.ids.screen_manager.current = 'screen_5'
     # clear the previous lists from the screen
     self.root.ids.hist_id.clear_widgets()
     with open ('data.json') as json_file:
             data = json.load(json_file)
             data = data['NewRecord']
     if len(data) > 1:
         data.pop(0)
     icon = 'data/history_2.png'
     for item in data:
         first  = 'Distance: ' + str(item['new_record'])
         second = 'Date: ' + str(item['the_date']) 
         third  = 'Location: ' + str(item['location'])
         items = ThreeLineIconListItem(text=first, secondary_text=second, 
                                       tertiary_text=third)
         items.add_widget(IconLeftWidget(icon=icon))
         self.root.ids.hist_id.add_widget(items)
コード例 #8
0
ファイル: menu_screen_class.py プロジェクト: JanickiJ/OSPapp
 def show_developers_info(self):
     three_line_list = ThreeLineIconListItem(text="Ania, Jakub",
                                             secondary_text="*****@*****.**",
                                             tertiary_text="https://github.com/JanickiJ/OSPapp.git")
     three_line_list.add_widget(
         IconLeftWidget(icon='fire', text_color=self.app.theme_cls.primary_color, theme_text_color="Custom"))
     self.app.dialog = MDDialog(
         title="Twórcy aplikacji",
         type="custom",
         content_cls=three_line_list,
         buttons=[
             MDFlatButton(
                 text="OK", text_color=self.app.theme_cls.primary_color, on_release=self.app.close_dialog
             )
         ]
     )
     self.app.dialog.size_hint = 1, None
     self.app.dialog.open()
コード例 #9
0
ファイル: icon_code.py プロジェクト: radman-s/kivy_basic1
    def build(self):
        screen = Screen()

        scroll = ScrollView()
        list_view = MDList()
        scroll.add_widget(list_view)

        for i in range(20):
            # icon = IconLeftWidget(icon='android')
            image = ImageLeftWidget(source='my.jpg')
            items = ThreeLineIconListItem(text=f'Item {str(i)}',
                                          secondary_text='hello wold',
                                          tertiary_text='Thertiary text')

            # items.add_widget(icon)
            items.add_widget(image)
            list_view.add_widget(items)

        screen.add_widget(scroll)

        return screen
コード例 #10
0
    def on_box(self, *args):
        if path.isfile('./api_key.txt'):
            with open('api_key.txt', 'r') as file:
                self.full_name = file.readline().replace('\n', '')

        icon = IconLeftWidget(icon='laptop')
        item = OneLineIconListItem(text="Cluster One",
                                   on_release=self.choose_cluster_one)
        item.add_widget(icon)
        self.box.add_widget(item)
        self.slots.append(item)

        icon = IconLeftWidget(icon='laptop')
        item = OneLineIconListItem(text="Cluster Two",
                                   on_release=self.choose_cluster_two)
        item.add_widget(icon)
        self.box.add_widget(item)
        self.slots.append(item)

        for slot in self.cluster:
            slot_splited = slot.split('|')
            begin = "Begin: " + slot_splited[0]
            end = "End:    " + slot_splited[1]
            if slot_splited[3] == '47':
                place = "Place: " + slot_splited[2] + " Cluster: E1"
            else:
                place = "Place: " + slot_splited[2] + " Cluster: E2"

            if "21:00:00" in begin:
                icon = IconLeftWidget(icon='weather-night')
                # if 'night' in timeForSlotsToNotify:
                # 	notification.notify(title="Free Slot", message=begin + '\n' + end + '\n' + place)
            elif "15:00:00" in begin:
                icon = IconLeftWidget(icon='weather-cloudy')
                # if 'evening' in timeForSlotsToNotify:
                # 	notification.notify(title="Free Slot", message=begin + '\n' + end + '\n' + place)
            else:
                icon = IconLeftWidget(icon='weather-sunny')
                # if 'morning' in timeForSlotsToNotify:
                # 	notification.notify(title="Free Slot", message=begin + '\n' + end + '\n' + place)

            item = ThreeLineIconListItem(text=begin,
                                         secondary_text=end,
                                         tertiary_text=place)
            item.add_widget(icon)
            self.slots.append(item)
            self.box.add_widget(item)
コード例 #11
0
ファイル: menu_screen_class.py プロジェクト: JanickiJ/OSPapp
 def make_third_screen(self):
     for member in self.app.myfirebase.get_crew_members():
         permissions = ""
         if member[1]: permissions += "dow. akcji, "
         if member[2]: permissions += "kierowca, "
         if member[3]: permissions += "dow. sekcji"
         if permissions == "": permissions += "brak"
         to_add = ThreeLineIconListItem(text=member[0], secondary_text="Uprawnienia:", tertiary_text=permissions)
         to_add.tertiary_font_style = 'Caption'
         to_add.secondary_font_style = 'Caption'
         to_add.add_widget(IconLeftWidget(icon='fire'))
         self.screen.ids.crew_members.add_widget(to_add)
コード例 #12
0
ファイル: info.py プロジェクト: JuacyWillian/kivy_model
    def on_enter(self):
        url = 'https://covid19-brazil-api.now.sh/api/report/v1'

        response = requests.get(url)
        status_code = response.status_code
        content_json = response.json()
        #print(json.dumps(content_json['data'], indent=4))

        i=0
        app = MDApp.get_running_app()
        print(app.root.ids, '<<<<<========')
        list_states = app.root.ids.information_screen.ids.list_states

        for state in content_json['data']:
            items = ThreeLineIconListItem(text=content_json['data'][i]['state'], 
                                          secondary_text='Casos de COVID-19: ' + str(content_json['data'][i]['cases']), 
                                          tertiary_text='Casos suspeitos: ' + str(content_json['data'][i]['suspects']))
            list_states.add_widget(items)

            i+=1
コード例 #13
0
ファイル: final2.py プロジェクト: wenjie322/final_project
    def pressed(self, instance):
        print([
            int(self.left.two.input1.text),
            int(self.left.two.input3.text),
            int(self.left.two.input5.text)
        ])
        a = final_combiner.final_rank([
            int(self.left.two.input1.text),
            int(self.left.two.input3.text),
            int(self.left.two.input5.text)
        ])
        print(a)
        if not self.acard:
            #bb = ThreeLineIconListItem(text=self.left.two.input1.text, secondary_text='22', tertiary_text='333')
            #bb.add_widget(IconLeftWidget(icon='language-python'))
            #bb.bg_color = [0.5,1,1,1]
            print(a)
            self.rank1 = ThreeLineIconListItem(
                text=a[0][0],
                secondary_text='人口特性:' + str(a[0][1]),
                tertiary_text='新資所得:' + str(a[0][2]))  # , size = [352, 100]
            self.rank1.add_widget(IconLeftWidget(icon='numeric-1-box'))
            self.rank1.bg_color = [0.5, 0.5, 0.5, 0.5]
            self.rank1.children[1].children[2].font_name = 'msjhbd.ttc'
            self.rank1.children[1].children[1].font_name = 'msjhbd.ttc'
            self.rank1.children[1].children[0].font_name = 'msjhbd.ttc'
            self.rank1.children[1].children[2].font_size = '18'

            more_rank1 = MDLabel(text='人口消長:' + str(a[0][3]))
            more_rank1.font_name = 'msjhbd.ttc'
            more_rank1.font_style = 'Body1'
            more_rank1.font_size = 16
            more_rank1.color = [0, 0, 0, 0.54]
            self.rank1.children[1].add_widget(more_rank1)
            self.rank1.children[1].size_hint = [1, None]
            self.rank1.children[1].children[3].pos = [56, 280]

            self.rank2 = ThreeLineIconListItem(
                text=a[1][0],
                secondary_text='人口特性:' + str(a[1][1]),
                tertiary_text='新資所得:' + str(a[1][2]))
            #rank2.children[1].add_widget(MDLabel(text='新資所得' + str(a[1][2]), font_name='msjhbd.ttc', font_size=16, font_style='Body1'))
            #rank2.add_widget(tertiary_text='新資所得' + str(a[1][2]))
            self.rank2.add_widget(IconLeftWidget(icon='numeric-2-box'))
            self.rank2.bg_color = [0.5, 0.5, 0.5, 0.5]

            self.rank2.children[1].children[2].font_size = '18'
            self.rank2.children[1].children[2].font_name = 'msjhbd.ttc'
            self.rank2.children[1].children[1].font_name = 'msjhbd.ttc'
            self.rank2.children[1].children[0].font_name = 'msjhbd.ttc'

            more_rank2 = MDLabel(text='人口消長:' + str(a[1][3]))
            more_rank2.font_name = 'msjhbd.ttc'
            more_rank2.font_style = 'Body1'
            more_rank2.font_size = 16
            more_rank2.color = [0, 0, 0, 0.54]
            self.rank2.children[1].add_widget(more_rank2)
            self.rank2.children[1].size_hint = [1, None]

            self.rank3 = ThreeLineIconListItem(
                text=a[2][0],
                secondary_text='人口特性:' + str(a[2][1]),
                tertiary_text='新資所得:' + str(a[2][2]))
            #rank2.children[1].add_widget(MDLabel(text='新資所得' + str(a[1][2]), font_name='msjhbd.ttc', font_size=16, font_style='Body1'))
            #rank2.add_widget(tertiary_text='新資所得' + str(a[1][2]))
            self.rank3.add_widget(IconLeftWidget(icon='numeric-3-box'))
            self.rank3.bg_color = [0.5, 0.5, 0.5, 0.5]

            self.rank3.children[1].children[2].font_size = '18'
            self.rank3.children[1].children[2].font_name = 'msjhbd.ttc'
            self.rank3.children[1].children[1].font_name = 'msjhbd.ttc'
            self.rank3.children[1].children[0].font_name = 'msjhbd.ttc'

            more_rank3 = MDLabel(text='人口消長:' + str(a[2][3]))
            more_rank3.font_name = 'msjhbd.ttc'
            more_rank3.font_style = 'Body1'
            more_rank3.font_size = 16
            more_rank3.color = [0, 0, 0, 0.54]
            self.rank3.children[1].add_widget(more_rank3)
            self.rank3.children[1].size_hint = [1, None]
            # rank2.children[1].(MDLabel(text='新資所得' + str(a[1][2])))
            # rank2.children[1].children[3].font_name = 'msjhbd.ttc'
            # rank2.children[1].children[3].font_size = 16
            # rank2.children[1].children[3].font_style = 'Body1'

            self.rank1.size = [352, 100]
            self.rank2.size = [352, 100]
            self.rank3.size = [352, 100]
            #rank1.children[1].pos_hint = {'y': 1}

            self.click += 1
            self.rank1.bind(on_release=self.add_renk1_marker)
            self.rank2.bind(on_release=self.add_renk2_marker)
            self.rank3.bind(on_release=self.add_renk3_marker)
            # self.acard = MDDialog(
            #     #title="Discard draft?",
            #     type="simple",
            #     items=[
            #         rank1,
            #         rank2,
            #         rank3
            #     ],
            #     buttons=[
            #         MDFlatButton(
            #             text="     ", text_color=self.theme_cls.primary_color
            #         ),
            #         MDRectangleFlatIconButton(
            #             text="I know!", text_color=self.theme_cls.primary_color, font_name='msjhbd.ttc', on_release=self.dialog_vanish

            #         )
            #     ],

            #     #center = [640, 480]
            # )

            # self.acard.center = [640, 480]
            # self.acard.background_color = [0,0,0,0]
            # self.acard.md_bg_color = [0.9607,0.9607,0.9607,0.6]
            # self.acard.auto_dismiss = False
            # #self.rank1 = TwoLineIconListItem(text=self.left.two.input1.text, icon='crown')
            # #self.rank1 = FourLineIconListItem(text=self.left.two.input1.text, text_color=[0,0,0,1])
            # #self.rank1.add_widget(IconLeftWidget(icon='language-python'))
            # #self.rank1.bg_color=[0.5,0.5,0.5,0.5]

            # self.acard.size_hint = [0.25, 0.5]
            # self.acard.children[0].size_hint = [1, 1.1]
            # self.acard.children[0].children[2].children[0].spacing = [0, 3]  # 這式調整各rank之間距離
            # self.acard.children[0].children[2].size_hint = [1,1]  # 這是調scrollview的size比例,不要有捲動行為
            # self.acard.children[0].children[2].bar_width = 5
            # self.acard.children[0].children[2].bar_color = [0.5, 0.5, 0.7, 1]
            #self.acard.children[0].children[2].children[0].children[2].size_hint = [1, 1]
            #self.acard.children[0].children[2].children[0].size_hint = [1,1]  # 這是調
            #self.acard.children[0].children[2].children[0].add_widget(self.rank1)

            self.rank1.children[1].padding = [56, 16, 24, 7]
            self.rank2.children[1].padding = [56, 4, 24, 7]
            self.rank3.children[1].padding = [56, 4, 24, 7]

            self.rank1.children[1].children[0].adaptive_height = True
            self.rank1.children[1].pos = [0, 180]
            self.rank2.children[1].children[1].adaptive_height = True
            self.rank2.children[1].pos = [0, 130]
            self.rank3.children[1].children[1].adaptive_height = True
            #rank1.children[1].children[0].valign = 'top'
            #rank1.children[1].children[0].y = 224
            #self.acard.
            # self.acard.center_y = 480
            # self.acard.pos_hint = {'top':0.99, 'right':1}
            # self.wid.add_widget(self.rank1)
            # self.wid.add_widget(self.rank2)
            # self.r.add_widget(self.rank3)
            self.add_widget(
                MDGridLayout(cols=1,
                             size_hint=[0.285, 1],
                             md_bg_color=[0.39, 0.4, 0.72, 1]))
            self.children[0].add_widget(self.rank1)
            self.children[0].add_widget(self.rank2)
            self.children[0].add_widget(self.rank3)
コード例 #14
0
ファイル: main.py プロジェクト: wenjie322/final_project
    def pressed(self, instance):
        top3_rank = final_combiner.final_rank([
            int(self.left.two.input1.text),
            int(self.left.two.input3.text),
            int(self.left.two.input5.text)
        ], self.spinner.text)
        print("實際的前三名:", end="")
        print(top3_rank)
        if not self.acard:
            self.rank1 = ThreeLineIconListItem(
                text=top3_rank[0][0].split('區')[1],
                secondary_text='人口特性:' + str(top3_rank[0][1]),
                tertiary_text='新資所得:' + str(top3_rank[0][2]),
                text_color=[1, 1, 1, 1])
            self.rank1.add_widget(IconLeftWidget(icon='numeric-1-box'))
            self.rank1.bg_color = [0, 0, 0, 0]
            self.rank1.children[1].children[2].font_name = 'msjhbd.ttc'
            self.rank1.children[1].children[1].font_name = 'msjhbd.ttc'
            self.rank1.children[1].children[0].font_name = 'msjhbd.ttc'
            self.rank1.children[1].children[2].font_size = '18'

            more_rank1 = MDLabel(text='人口消長:' + str(top3_rank[0][3]))
            more_rank1.font_name = 'msjhbd.ttc'
            more_rank1.font_style = 'Body1'
            more_rank1.font_size = 16
            more_rank1.color = [0, 0, 0, 0.7]
            self.rank1.children[1].add_widget(more_rank1)
            self.rank1.children[1].size_hint = [1, None]
            self.rank1.children[1].children[3].pos = [56, 280]

            self.rank1.children[0].children[0].children[0].color = [1, 1, 1, 1]
            self.rank1.children[0].children[0].children[0].pos_hint = {
                'left': 0.1
            }
            self.rank1.children[0].padding = [-10, 0, 0, 0]
            self.rank1.children[1].children[3].theme_text_color = 'Custom'
            self.rank1.children[1].children[3].text_color = [1, 1, 1, 1]
            self.rank1.children[1].children[2].theme_text_color = 'Custom'
            self.rank1.children[1].children[2].text_color = [1, 1, 1, 1]
            self.rank1.children[1].children[1].theme_text_color = 'Custom'
            self.rank1.children[1].children[1].text_color = [1, 1, 1, 1]
            self.rank1.children[1].children[0].theme_text_color = 'Custom'
            self.rank1.children[1].children[0].text_color = [1, 1, 1, 1]
            self.rank1.children[1].height = 110
            # 從另一個預先寫好、計算各里指標分數的模組final_combiner引進final_rank函數,取得前三名的區域及其各項指標分數後用top3_rank變數紀錄起來
            # 接著改寫、擴充kivy套件內的工具(ThreeLineIconListItem),做成資訊卡,同時使其擁有按鈕的特性讓使用者做點選

            self.rank2 = ThreeLineIconListItem(
                text=top3_rank[1][0].split('區')[1],
                secondary_text='人口特性:' + str(top3_rank[1][1]),
                tertiary_text='新資所得:' + str(top3_rank[1][2]))
            self.rank2.add_widget(IconLeftWidget(icon='numeric-2-box'))
            self.rank2.bg_color = [0, 0, 0, 0]

            self.rank2.children[1].children[2].font_size = '18'
            self.rank2.children[1].children[2].font_name = 'msjhbd.ttc'
            self.rank2.children[1].children[1].font_name = 'msjhbd.ttc'
            self.rank2.children[1].children[0].font_name = 'msjhbd.ttc'

            more_rank2 = MDLabel(text='人口消長:' + str(top3_rank[1][3]))
            more_rank2.font_name = 'msjhbd.ttc'
            more_rank2.font_style = 'Body1'
            more_rank2.font_size = 16
            more_rank2.color = [0, 0, 0, 0.54]
            self.rank2.children[1].add_widget(more_rank2)
            self.rank2.children[1].size_hint = [1, None]

            self.rank2.children[0].children[0].children[0].color = [1, 1, 1, 1]
            self.rank2.children[0].children[0].children[0].pos_hint = {
                'left': 0.1
            }
            self.rank2.children[0].padding = [-10, 0, 0, 0]
            self.rank2.children[1].children[3].theme_text_color = 'Custom'
            self.rank2.children[1].children[3].text_color = [1, 1, 1, 1]
            self.rank2.children[1].children[2].theme_text_color = 'Custom'
            self.rank2.children[1].children[2].text_color = [1, 1, 1, 1]
            self.rank2.children[1].children[1].theme_text_color = 'Custom'
            self.rank2.children[1].children[1].text_color = [1, 1, 1, 1]
            self.rank2.children[1].children[0].theme_text_color = 'Custom'
            self.rank2.children[1].children[0].text_color = [1, 1, 1, 1]

            self.rank3 = ThreeLineIconListItem(
                text=top3_rank[2][0].split('區')[1],
                secondary_text='人口特性:' + str(top3_rank[2][1]),
                tertiary_text='新資所得:' + str(top3_rank[2][2]))
            self.rank3.add_widget(IconLeftWidget(icon='numeric-3-box'))
            self.rank3.bg_color = [0, 0, 0, 0]

            self.rank3.children[1].children[2].font_size = '18'
            self.rank3.children[1].children[2].font_name = 'msjhbd.ttc'
            self.rank3.children[1].children[1].font_name = 'msjhbd.ttc'
            self.rank3.children[1].children[0].font_name = 'msjhbd.ttc'

            more_rank3 = MDLabel(text='人口消長:' + str(top3_rank[2][3]))
            more_rank3.font_name = 'msjhbd.ttc'
            more_rank3.font_style = 'Body1'
            more_rank3.font_size = 16
            more_rank3.color = [0, 0, 0, 0.54]
            self.rank3.children[1].add_widget(more_rank3)
            self.rank3.children[1].size_hint = [1, None]

            self.rank3.children[0].children[0].children[0].color = [1, 1, 1, 1]
            self.rank3.children[0].children[0].children[0].pos_hint = {
                'left': 0.1
            }
            self.rank3.children[0].padding = [-10, 0, 0, 0]
            self.rank3.children[1].children[3].theme_text_color = 'Custom'
            self.rank3.children[1].children[3].text_color = [1, 1, 1, 1]
            self.rank3.children[1].children[2].theme_text_color = 'Custom'
            self.rank3.children[1].children[2].text_color = [1, 1, 1, 1]
            self.rank3.children[1].children[1].theme_text_color = 'Custom'
            self.rank3.children[1].children[1].text_color = [1, 1, 1, 1]
            self.rank3.children[1].children[0].theme_text_color = 'Custom'
            self.rank3.children[1].children[0].text_color = [1, 1, 1, 1]

            self.rank1.size = [352, 100]
            self.rank2.size = [352, 100]
            self.rank3.size = [352, 100]

            self.click += 1

            self.rank1.children[1].padding = [56, 16, 24, 7]
            self.rank2.children[1].padding = [56, 4, 24, 7]
            self.rank3.children[1].padding = [56, 4, 24, 7]

            self.rank1.children[1].children[0].adaptive_height = True
            self.rank1.children[1].pos = [0, 180]
            self.rank2.children[1].children[1].adaptive_height = True
            self.rank2.children[1].pos = [0, 130]
            self.rank3.children[1].children[1].adaptive_height = True

            self.lll = ScatterLayout(size_hint=[0.2, 0.6])
            self.myLast = MDGridLayout(cols=1,
                                       size_hint=[0.8, 0.85],
                                       md_bg_color=[0.39, 0.4, 0.8, 0.8])
            self.myLast.add_widget(self.rank1)  # 0.285,0.5
            self.myLast.add_widget(self.rank2)
            self.myLast.add_widget(self.rank3)
            self.lll.add_widget(self.myLast)
            from kivy.core.window import Window
            Window.add_widget(self.lll)
            self.lll.center = (640, 328)
            self.rank1.bind(on_release=self.add_renk1_marker)
            self.rank2.bind(on_release=self.add_renk2_marker)
            self.rank3.bind(on_release=self.add_renk3_marker)

            lat = 0
            lon = 0
            try:
                with open(os.path.realpath(sys.argv[0]).strip(sys.argv[0]) +
                          'district.json',
                          'r',
                          encoding='utf-8') as q:
                    q = json.load(q)
                    lat = q["臺中市" + self.spinner.text][0][0]
                    lon = q["臺中市" + self.spinner.text][0][1]

            except:
                print(self.spinner.text + "經緯度有問題")

            self.map.zoom = 12
            self.map.center_on(float(lat), float(lon))
コード例 #15
0
    def FileCart_Update(self):
        MainScreenvar = sm.get_screen('main_screen')
        #We then clear the container of all widgets for a frsh batch of list items
        MainScreenvar.ids.back_layer.ids.container.clear_widgets()
        #First we get the amount of rows in the selection tables to see how much times we must itterate
        mycursor.execute("SELECT COUNT(name) FROM selection")
        self.cart_icons_amount  = mycursor.fetchone()
        #Then we get the actual data that we must use to create the elements
        mycursor.execute("SELECT * FROM selection")
        self.filecart_data = mycursor.fetchall()
        for i in range (self.cart_icons_amount[0]):

            #Check to see if the current element is a file or a directory
            if self.filecart_data[i][2] == "File":

                #Check too see if a copy operation was executed on the file
                if self.filecart_data[i][3] == '1':
                    #Create the list item to be insert into scroll view
                    self.item = ThreeLineIconListItem(text = str(self.filecart_data[i][0]),
                                                   secondary_text = self.filecart_data[i][1],
                                                   tertiary_text = "Copied",
                                                   )
                    #Create the icon
                    self.item2 = IconLeftWidget(icon = 'file',
                                                pos= self.pos,
                                                size = self.size,
                                                )
                    self.item.bind(on_release = self.customcallback_function)
                    #Add icon to list item
                    self.item.add_widget(self.item2)
                    #Add total list item with icon to the scroll view
                    MainScreenvar.ids.back_layer.ids.container.add_widget(self.item)

                #Check too see if a cut operation was executed on the file
                elif self.filecart_data[i][3] == '2':
                    self.item = ThreeLineIconListItem(text = str(self.filecart_data[i][0]),
                                                      secondary_text = self.filecart_data[i][1],
                                                      tertiary_text = "Cut",
                                                      )
                    self.item2 = IconLeftWidget(icon = 'file',
                                                pos= self.pos,
                                                size = self.size
                                                )
                    self.item.bind(on_release = self.customcallback_function)
                    self.item.add_widget(self.item2)
                    MainScreenvar.ids.back_layer.ids.container.add_widget(self.item)

                #Check to see if a delete operation was executed on the file
                elif self.filecart_data[i][3] == '3':
                    self.item = ThreeLineIconListItem(text = str(self.filecart_data[i][0]),
                                                   secondary_text = self.filecart_data[i][1],
                                                   tertiary_text = "Recycled",
                                                   )
                    self.item2 = IconLeftWidget(icon = 'file',
                                                pos= self.pos,
                                                size = self.size
                                                )
                    self.item.bind(on_release = self.customcallback_function)
                    self.item.add_widget(self.item2)
                    MainScreenvar.ids.back_layer.ids.container.add_widget(self.item)


            else:

                if self.filecart_data[i][3] == '1':
                    self.item = ThreeLineIconListItem(text = str(self.filecart_data[i][0]),
                                                       secondary_text = self.filecart_data[i][1],
                                                       tertiary_text = "Copied",
                                                       )
                    self.item2 = IconLeftWidget(icon = 'folder',
                                                pos= self.pos,
                                                size = self.size
                                                )
                    self.item.bind(on_release = self.customcallback_function)
                    self.item.add_widget(self.item2)
                    MainScreenvar.ids.back_layer.ids.container.add_widget(self.item)

                elif self.filecart_data[i][3] == '2':
                    self.item = ThreeLineIconListItem(text = str(self.filecart_data[i][0]),
                                                      secondary_text = self.filecart_data[i][1],
                                                      tertiary_text = "Cut",
                                                      )
                    self.item2 = IconLeftWidget(icon = 'folder',
                                                pos= self.pos,
                                                size = self.size
                                               )
                    self.item.bind(on_release = self.customcallback_function)
                    self.item.add_widget(self.item2)
                    MainScreenvar.ids.back_layer.ids.container.add_widget(self.item)

                elif self.filecart_data[i][3] == '3':
                    self.item = ThreeLineIconListItem(text = str(self.filecart_data[i][0]),
                                                      secondary_text = self.filecart_data[i][1],
                                                      tertiary_text = "Recycled",
                                                      )
                    self.item.bind(on_release = self.customcallback_function)
                    self.item2 = IconLeftWidget(icon = 'folder',
                                                pos= self.pos,
                                                size = self.size
                                                )
                    self.item.bind(on_release = self.customcallback_function)
                    self.item.add_widget(self.item2)
                    MainScreenvar.ids.back_layer.ids.container.add_widget(self.item)
コード例 #16
0
    def pressed(self, instance):
        print(self.spinner.text)
        #print(self.spinner.text)
        top3_rank = final_combiner.final_rank([
            int(self.left.two.input1.text),
            int(self.left.two.input3.text),
            int(self.left.two.input5.text)
        ])
        if not self.acard:
            self.rank1 = ThreeLineIconListItem(
                text=top3_rank[0][0],
                secondary_text='人口特性:' + str(top3_rank[0][1]),
                tertiary_text='新資所得:' + str(top3_rank[0][2]),
                text_color=[1, 1, 1, 1])
            self.rank1.add_widget(IconLeftWidget(icon='numeric-1-box'))
            self.rank1.bg_color = [0, 0, 0, 0]
            self.rank1.children[1].children[2].font_name = 'msjhbd.ttc'
            self.rank1.children[1].children[1].font_name = 'msjhbd.ttc'
            self.rank1.children[1].children[0].font_name = 'msjhbd.ttc'
            self.rank1.children[1].children[2].font_size = '18'

            more_rank1 = MDLabel(text='人口消長:' + str(top3_rank[0][3]))
            more_rank1.font_name = 'msjhbd.ttc'
            more_rank1.font_style = 'Body1'
            more_rank1.font_size = 16
            more_rank1.color = [0, 0, 0, 0.7]
            self.rank1.children[1].add_widget(more_rank1)
            self.rank1.children[1].size_hint = [1, None]
            self.rank1.children[1].children[3].pos = [56, 280]

            self.rank1.children[0].children[0].children[0].color = [1, 1, 1, 1]
            self.rank1.children[0].children[0].children[0].pos_hint = {
                'left': 0.1
            }
            self.rank1.children[0].padding = [-10, 0, 0, 0]
            self.rank1.children[1].children[3].theme_text_color = 'Custom'
            self.rank1.children[1].children[3].text_color = [1, 1, 1, 1]
            self.rank1.children[1].children[2].theme_text_color = 'Custom'
            self.rank1.children[1].children[2].text_color = [1, 1, 1, 1]
            self.rank1.children[1].children[1].theme_text_color = 'Custom'
            self.rank1.children[1].children[1].text_color = [1, 1, 1, 1]
            self.rank1.children[1].children[0].theme_text_color = 'Custom'
            self.rank1.children[1].children[0].text_color = [1, 1, 1, 1]
            # 從另一個預先寫好、計算各里指標分數的模組final_combiner引進final_rank函數,取得前三名的區域及其各項指標分數後用top3_rank變數紀錄起來
            # 接著改寫、擴充kivy套件內的工具(ThreeLineIconListItem),做成資訊卡,同時使其擁有按鈕的特性讓使用者做點選

            self.rank2 = ThreeLineIconListItem(
                text=top3_rank[1][0],
                secondary_text='人口特性:' + str(top3_rank[1][1]),
                tertiary_text='新資所得:' + str(top3_rank[1][2]))
            self.rank2.add_widget(IconLeftWidget(icon='numeric-2-box'))
            self.rank2.bg_color = [0, 0, 0, 0]

            self.rank2.children[1].children[2].font_size = '18'
            self.rank2.children[1].children[2].font_name = 'msjhbd.ttc'
            self.rank2.children[1].children[1].font_name = 'msjhbd.ttc'
            self.rank2.children[1].children[0].font_name = 'msjhbd.ttc'

            more_rank2 = MDLabel(text='人口消長:' + str(top3_rank[1][3]))
            more_rank2.font_name = 'msjhbd.ttc'
            more_rank2.font_style = 'Body1'
            more_rank2.font_size = 16
            more_rank2.color = [0, 0, 0, 0.54]
            self.rank2.children[1].add_widget(more_rank2)
            self.rank2.children[1].size_hint = [1, None]

            self.rank2.children[0].children[0].children[0].color = [1, 1, 1, 1]
            self.rank2.children[0].children[0].children[0].pos_hint = {
                'left': 0.1
            }
            self.rank2.children[0].padding = [-10, 0, 0, 0]
            self.rank2.children[1].children[3].theme_text_color = 'Custom'
            self.rank2.children[1].children[3].text_color = [1, 1, 1, 1]
            self.rank2.children[1].children[2].theme_text_color = 'Custom'
            self.rank2.children[1].children[2].text_color = [1, 1, 1, 1]
            self.rank2.children[1].children[1].theme_text_color = 'Custom'
            self.rank2.children[1].children[1].text_color = [1, 1, 1, 1]
            self.rank2.children[1].children[0].theme_text_color = 'Custom'
            self.rank2.children[1].children[0].text_color = [1, 1, 1, 1]

            self.rank3 = ThreeLineIconListItem(
                text=top3_rank[2][0],
                secondary_text='人口特性:' + str(top3_rank[2][1]),
                tertiary_text='新資所得:' + str(top3_rank[2][2]))
            self.rank3.add_widget(IconLeftWidget(icon='numeric-3-box'))
            self.rank3.bg_color = [0, 0, 0, 0]

            self.rank3.children[1].children[2].font_size = '18'
            self.rank3.children[1].children[2].font_name = 'msjhbd.ttc'
            self.rank3.children[1].children[1].font_name = 'msjhbd.ttc'
            self.rank3.children[1].children[0].font_name = 'msjhbd.ttc'

            more_rank3 = MDLabel(text='人口消長:' + str(top3_rank[2][3]))
            more_rank3.font_name = 'msjhbd.ttc'
            more_rank3.font_style = 'Body1'
            more_rank3.font_size = 16
            more_rank3.color = [0, 0, 0, 0.54]
            self.rank3.children[1].add_widget(more_rank3)
            self.rank3.children[1].size_hint = [1, None]

            self.rank3.children[0].children[0].children[0].color = [1, 1, 1, 1]
            self.rank3.children[0].children[0].children[0].pos_hint = {
                'left': 0.1
            }
            self.rank3.children[0].padding = [-10, 0, 0, 0]
            self.rank3.children[1].children[3].theme_text_color = 'Custom'
            self.rank3.children[1].children[3].text_color = [1, 1, 1, 1]
            self.rank3.children[1].children[2].theme_text_color = 'Custom'
            self.rank3.children[1].children[2].text_color = [1, 1, 1, 1]
            self.rank3.children[1].children[1].theme_text_color = 'Custom'
            self.rank3.children[1].children[1].text_color = [1, 1, 1, 1]
            self.rank3.children[1].children[0].theme_text_color = 'Custom'
            self.rank3.children[1].children[0].text_color = [1, 1, 1, 1]

            self.rank1.size = [352, 100]
            self.rank2.size = [352, 100]
            self.rank3.size = [352, 100]

            self.click += 1

            self.rank1.children[1].padding = [56, 16, 24, 7]
            self.rank2.children[1].padding = [56, 4, 24, 7]
            self.rank3.children[1].padding = [56, 4, 24, 7]

            self.rank1.children[1].children[0].adaptive_height = True
            self.rank1.children[1].pos = [0, 180]
            self.rank2.children[1].children[1].adaptive_height = True
            self.rank2.children[1].pos = [0, 130]
            self.rank3.children[1].children[1].adaptive_height = True

            self.add_widget(
                MDGridLayout(cols=1,
                             size_hint=[0.285, 1],
                             md_bg_color=[0.39, 0.4, 0.72, 1]))
            self.children[0].add_widget(self.rank1)
            self.children[0].add_widget(self.rank2)
            self.children[0].add_widget(self.rank3)

            self.rank1.bind(on_release=self.add_renk1_marker)
            self.rank2.bind(on_release=self.add_renk2_marker)
            self.rank3.bind(on_release=self.add_renk3_marker)
コード例 #17
0
class PawareApp(MDApp):

    def enable_items_inputs(self):

        ##Item 1
        if self.strng.get_screen('checklistItem1').ids.radio_item1_nc.active == True:
            self.strng.get_screen(f'checklistItem1').ids.acao_item1.disabled = False
            self.strng.get_screen(f'checklistItem1').ids.responsavel_item1.disabled = False
            self.strng.get_screen(f'checklistItem1').ids.prazo_item1.disabled = False

        else:
            self.strng.get_screen(f'checklistItem1').ids.acao_item1.disabled = True
            self.strng.get_screen(f'checklistItem1').ids.responsavel_item1.disabled = True
            self.strng.get_screen(f'checklistItem1').ids.prazo_item1.disabled = True


        ##Item 2
        if self.strng.get_screen('checklistItem2').ids.radio_item2_nc.active == True:
            self.strng.get_screen(f'checklistItem2').ids.acao_item2.disabled = False
            self.strng.get_screen(f'checklistItem2').ids.responsavel_item2.disabled = False
            self.strng.get_screen(f'checklistItem2').ids.prazo_item2.disabled = False

        else:
            self.strng.get_screen(f'checklistItem2').ids.acao_item2.disabled = True
            self.strng.get_screen(f'checklistItem2').ids.responsavel_item2.disabled = True
            self.strng.get_screen(f'checklistItem2').ids.prazo_item2.disabled = True


        ##Item 3
        if self.strng.get_screen('checklistItem3').ids.radio_item3_nc.active == True:
            self.strng.get_screen(f'checklistItem3').ids.acao_item3.disabled = False
            self.strng.get_screen(f'checklistItem3').ids.responsavel_item3.disabled = False
            self.strng.get_screen(f'checklistItem3').ids.prazo_item3.disabled = False

        else:
            self.strng.get_screen(f'checklistItem3').ids.acao_item3.disabled = True
            self.strng.get_screen(f'checklistItem3').ids.responsavel_item3.disabled = True
            self.strng.get_screen(f'checklistItem3').ids.prazo_item3.disabled = True

        ##Item 4
        if self.strng.get_screen('checklistItem4').ids.radio_item4_nc.active == True:
            self.strng.get_screen(f'checklistItem4').ids.acao_item4.disabled = False
            self.strng.get_screen(f'checklistItem4').ids.responsavel_item4.disabled = False
            self.strng.get_screen(f'checklistItem4').ids.prazo_item4.disabled = False

        else:
            self.strng.get_screen(f'checklistItem4').ids.acao_item4.disabled = True
            self.strng.get_screen(f'checklistItem4').ids.responsavel_item4.disabled = True
            self.strng.get_screen(f'checklistItem4').ids.prazo_item4.disabled = True

        ##Item 5
        if self.strng.get_screen('checklistItem5').ids.radio_item5_nc.active == True:
            self.strng.get_screen(f'checklistItem5').ids.acao_item5.disabled = False
            self.strng.get_screen(f'checklistItem5').ids.responsavel_item5.disabled = False
            self.strng.get_screen(f'checklistItem5').ids.prazo_item5.disabled = False

        else:
            self.strng.get_screen(f'checklistItem5').ids.acao_item5.disabled = True
            self.strng.get_screen(f'checklistItem5').ids.responsavel_item5.disabled = True
            self.strng.get_screen(f'checklistItem5').ids.prazo_item5.disabled = True

        ##Item 6
        if self.strng.get_screen('checklistItem6').ids.radio_item6_nc.active == True:
            self.strng.get_screen(f'checklistItem6').ids.acao_item6.disabled = False
            self.strng.get_screen(f'checklistItem6').ids.responsavel_item6.disabled = False
            self.strng.get_screen(f'checklistItem6').ids.prazo_item6.disabled = False

        else:
            self.strng.get_screen(f'checklistItem6').ids.acao_item6.disabled = True
            self.strng.get_screen(f'checklistItem6').ids.responsavel_item6.disabled = True
            self.strng.get_screen(f'checklistItem6').ids.prazo_item6.disabled = True

        ##Item 7
        if self.strng.get_screen('checklistItem7').ids.radio_item7_nc.active == True:
            self.strng.get_screen(f'checklistItem7').ids.acao_item7.disabled = False
            self.strng.get_screen(f'checklistItem7').ids.responsavel_item7.disabled = False
            self.strng.get_screen(f'checklistItem7').ids.prazo_item7.disabled = False

        else:
            self.strng.get_screen(f'checklistItem7').ids.acao_item7.disabled = True
            self.strng.get_screen(f'checklistItem7').ids.responsavel_item7.disabled = True
            self.strng.get_screen(f'checklistItem7').ids.prazo_item7.disabled = True

        ##Item 8
        if self.strng.get_screen('checklistItem8').ids.radio_item8_nc.active == True:
            self.strng.get_screen(f'checklistItem8').ids.acao_item8.disabled = False
            self.strng.get_screen(f'checklistItem8').ids.responsavel_item8.disabled = False
            self.strng.get_screen(f'checklistItem8').ids.prazo_item8.disabled = False

        else:
            self.strng.get_screen(f'checklistItem8').ids.acao_item8.disabled = True
            self.strng.get_screen(f'checklistItem8').ids.responsavel_item8.disabled = True
            self.strng.get_screen(f'checklistItem8').ids.prazo_item8.disabled = True

        ##Item 9
        if self.strng.get_screen('checklistItem9').ids.radio_item9_nc.active == True:
            self.strng.get_screen(f'checklistItem9').ids.acao_item9.disabled = False
            self.strng.get_screen(f'checklistItem9').ids.responsavel_item9.disabled = False
            self.strng.get_screen(f'checklistItem9').ids.prazo_item9.disabled = False

        else:
            self.strng.get_screen(f'checklistItem9').ids.acao_item9.disabled = True
            self.strng.get_screen(f'checklistItem9').ids.responsavel_item9.disabled = True
            self.strng.get_screen(f'checklistItem9').ids.prazo_item9.disabled = True

    def check_lv_items(self):

        #Item 1
        if self.strng.get_screen('checklistItem1').ids.radio_item1_nc.active == True and self.strng.get_screen(
                f'checklistItem1').ids.acao_item1.text.split() != [] and self.strng.get_screen(
                f'checklistItem1').ids.responsavel_item1.text.split() != [] and self.strng.get_screen(
                f'checklistItem1').ids.prazo_item1.text.split() != []:
            self.strng.get_screen(f'checklistItem1').ids.next_button1.disabled = False

        # Item 2
        if self.strng.get_screen('checklistItem2').ids.radio_item2_nc.active == True and self.strng.get_screen(
                f'checklistItem2').ids.acao_item2.text.split() != [] and self.strng.get_screen(
                f'checklistItem2').ids.responsavel_item2.text.split() != [] and self.strng.get_screen(
                f'checklistItem2').ids.prazo_item2.text.split() != []:
            self.strng.get_screen(f'checklistItem2').ids.next_button2.disabled = False

        # Item 3
        if self.strng.get_screen('checklistItem3').ids.radio_item3_nc.active == True and self.strng.get_screen(
                f'checklistItem3').ids.acao_item3.text.split() != [] and self.strng.get_screen(
                f'checklistItem3').ids.responsavel_item3.text.split() != [] and self.strng.get_screen(
                f'checklistItem3').ids.prazo_item3.text.split() != []:
            self.strng.get_screen(f'checklistItem3').ids.next_button3.disabled = False

        # Item 4
        if self.strng.get_screen('checklistItem4').ids.radio_item4_nc.active == True and self.strng.get_screen(
                f'checklistItem4').ids.acao_item4.text.split() != [] and self.strng.get_screen(
                f'checklistItem4').ids.responsavel_item4.text.split() != [] and self.strng.get_screen(
                f'checklistItem4').ids.prazo_item4.text.split() != []:
            self.strng.get_screen(f'checklistItem4').ids.next_button4.disabled = False

        # Item 5
        if self.strng.get_screen('checklistItem5').ids.radio_item5_nc.active == True and self.strng.get_screen(
                f'checklistItem5').ids.acao_item5.text.split() != [] and self.strng.get_screen(
                f'checklistItem5').ids.responsavel_item5.text.split() != [] and self.strng.get_screen(
                f'checklistItem5').ids.prazo_item5.text.split() != []:
            self.strng.get_screen(f'checklistItem5').ids.next_button5.disabled = False

        # Item 6
        if self.strng.get_screen('checklistItem6').ids.radio_item6_nc.active == True and self.strng.get_screen(
                f'checklistItem6').ids.acao_item6.text.split() != [] and self.strng.get_screen(
                f'checklistItem6').ids.responsavel_item6.text.split() != [] and self.strng.get_screen(
                f'checklistItem6').ids.prazo_item6.text.split() != []:
            self.strng.get_screen(f'checklistItem6').ids.next_button6.disabled = False

        # Item 7
        if self.strng.get_screen('checklistItem7').ids.radio_item7_nc.active == True and self.strng.get_screen(
                f'checklistItem7').ids.acao_item7.text.split() != [] and self.strng.get_screen(
                f'checklistItem7').ids.responsavel_item7.text.split() != [] and self.strng.get_screen(
                f'checklistItem7').ids.prazo_item7.text.split() != []:
            self.strng.get_screen(f'checklistItem7').ids.next_button7.disabled = False

        # Item 8
        if self.strng.get_screen('checklistItem8').ids.radio_item8_nc.active == True and self.strng.get_screen(
                f'checklistItem8').ids.acao_item8.text.split() != [] and self.strng.get_screen(
            f'checklistItem8').ids.responsavel_item8.text.split() != [] and self.strng.get_screen(
            f'checklistItem8').ids.prazo_item8.text.split() != []:
            self.strng.get_screen(f'checklistItem8').ids.next_button8.disabled = False

        # Item 9
        if self.strng.get_screen('checklistItem9').ids.radio_item9_nc.active == True and self.strng.get_screen(
                f'checklistItem9').ids.acao_item9.text.split() != [] and self.strng.get_screen(
            f'checklistItem9').ids.responsavel_item9.text.split() != [] and self.strng.get_screen(
            f'checklistItem9').ids.prazo_item9.text.split() != []:
            self.strng.get_screen(f'checklistItem9').ids.next_button9.disabled = False




    ##################CONFIRMAÇAO DE SAIDA FUNÇAO################
    dialog = None
    def show_alert_dialog(self):
        if not self.dialog:
            self.dialog = MDDialog(

                title="Você deseja mesmo sair ?",

                size_hint= (0.7,0.1),
                text="Você deseja mesmo sair ?",
                buttons=[
                    MDFlatButton(
                        text="Sim", text_color=self.theme_cls.primary_color, on_release=self.close_username_dialogue_app
                    ),
                    MDFlatButton(
                        text="Não", text_color=self.theme_cls.primary_color, on_release=self.close_username_dialogue
                    ),
                ],
            )
        self.dialog.open()  
    ####################CONFIRMAR EXCLUIR CHECKLIST######################
    def show_alert__delete_dialog(self):
        if not self.dialog:
            self.dialog = MDDialog(
                size_hint= (0.7,0.1),
                title="Você deseja mesmo excluir ?",
                buttons=[
                    MDFlatButton(
                        text="Sim", text_color=self.theme_cls.primary_color, on_release=self.close_username_dialogue_excluir
                    ),
                    MDFlatButton(
                        text="Não", text_color=self.theme_cls.primary_color, on_release=self.close_username_dialogue
                    ),
                ],
            )
        self.dialog.open()  

    ################CONFIG DA TELA DA CHECKLIST#################
    def save_in_data(self):
        name =   self.strng.get_screen('screen3').ids.profile_name_input.disabled = False
        data = self.strng.get_screen('screen3').ids.profile_data_input.disabled = False
        responsavel = self.strng.get_screen('screen3').ids.profile_responsavel_input.disabled = False
        acao = self.strng.get_screen('screen3').ids.profile_acao_input.disabled = False
        responsavel_realizar = self.strng.get_screen('screen3').ids.profile_responsavel_realizar_input.disabled = False
        prazo = self.strng.get_screen('screen3').ids.profile_prazo_input.disabled = False
        status  = self.strng.get_screen('screen3').ids.profile_status_input.disabled = False
 
        self.email_text = self.strng.get_screen('dob').ids.email_text_fied.text
        self.store = JsonStore("dataChecklist.json")
        self.store.put('UserInfo',name = name, data= data, responsavel= responsavel, acao= acao, reponsavel_relizar= responsavel_realizar, prazo= prazo, status= status)



    def enable_checklist_inputs(self):
        if self.strng.get_screen('screen3').ids.profile_name_input.disabled == True:

            self.strng.get_screen('screen3').ids.profile_name_input.disabled = False
            
            self.strng.get_screen('screen3').ids.profile_data_input.disabled = False


            self.strng.get_screen('screen3').ids.profile_responsavel_input.disabled = False


            self.strng.get_screen('screen3').ids.profile_acao_input.disabled = False
            self.strng.get_screen('screen3').ids.profile_acao_input.disabled = False
            
            self.strng.get_screen('screen3').ids.profile_responsavel_realizar_input.disabled = False
            self.strng.get_screen('screen3').ids.profile_responsavel_realizar_input.disabled = False

            self.strng.get_screen('screen3').ids.profile_prazo_input.disabled = False
            self.strng.get_screen('screen3').ids.profile_prazo_input.disabled = False

            self.strng.get_screen('screen3').ids.profile_status_input.disabled = False
            self.strng.get_screen('screen3').ids.profile_status_input.disabled = False

            self.strng.get_screen('screen3').ids.save_checklist_button.disabled = False
            self.strng.get_screen('screen3').ids.delete_checklist_button.disabled = False

        else:
            self.strng.get_screen('screen3').ids.profile_name_input.disabled = True

            self.strng.get_screen('screen3').ids.profile_data_input.disabled = True

            self.strng.get_screen('screen3').ids.profile_responsavel_input.disabled = True

            self.strng.get_screen('screen3').ids.profile_acao_input.disabled = True
            self.strng.get_screen('screen3').ids.profile_acao_input.disabled = True
            
            self.strng.get_screen('screen3').ids.profile_responsavel_realizar_input.disabled = True
            self.strng.get_screen('screen3').ids.profile_responsavel_realizar_input.disabled = True

            self.strng.get_screen('screen3').ids.profile_prazo_input.disabled = True
            self.strng.get_screen('screen3').ids.profile_prazo_input.disabled = True

            self.strng.get_screen('screen3').ids.profile_status_input.disabled = True
            self.strng.get_screen('screen3').ids.profile_status_input.disabled = True

            self.strng.get_screen('screen3').ids.save_checklist_button.disabled = True
            self.strng.get_screen('screen3').ids.delete_checklist_button.disabled = True
    #######################CONFIG DA TELA MEU PERFIL################
    def enable_profile_inputs(self):
        if self.strng.get_screen('profile').ids.profile_email_input.disabled == True:

            self.strng.get_screen('profile').ids.profile_email_input.disabled = False
            self.strng.get_screen('profile').ids.profile_email_input.disabled = False

            self.strng.get_screen('profile').ids.profile_name_input.disabled = False
            self.strng.get_screen('profile').ids.profile_name_input.disabled = False

            self.strng.get_screen('profile').ids.save_profile_button.disabled = False

        else:
            self.strng.get_screen('profile').ids.profile_email_input.disabled = True
            self.strng.get_screen('profile').ids.profile_email_input.disabled = True

            self.strng.get_screen('profile').ids.profile_name_input.disabled = True
            self.strng.get_screen('profile').ids.profile_name_input.disabled = True

            self.strng.get_screen('profile').ids.save_profile_button.disabled = True

    def get_date(self, date):
        '''
        :type date: <class 'datetime.date'>
        '''

    def show_date_picker(self):
        date_dialog = MDDatePicker(callback=self.get_date)
        date_dialog.open()

    def build(self):
        self.strng = Builder.load_file('conteudos.kv') #####CARREGANDO KV DAS TELA####
        return self.strng

    ###############DETALHES DO PERFIL ##############
    try:
        store = JsonStore("userProfile.json")
        nome_perfil = store.get('UserInfo')['name']
        email_perfil = store.get('UserInfo')['email']
    except:
        nome_perfil = "Usuário desconhecido"
        email_perfil = "Email não cadastrado"

    try:
        store = JsonStore("dataChecklist.json")
        list_name = store.get('UserInfo')['name']
        criado_em = store.get('UserInfo')['data']
        criado_por = store.get('UserInfo')['responsavel']
        reponsavel_relizar = store.get('UserInfo')['reponsavel_relizar']
        acao = store.get('UserInfo')['acao']
        prazo = store.get('UserInfo')['prazo']
        status = store.get('UserInfo')['status']
    except:
        pass
        

    #####INICIO DO APP CARREGANDO PERFIL E CADASTRO####
    def on_start(self):             
        self.store = JsonStore("userProfile.json")
        try:
            if self.store.get('UserInfo')['name'] != "":
                self.load_checklists_screen_main()
                self.strng.get_screen('screen1').manager.current = 'screen1'
                
        except KeyError:
            self.strng.get_screen('welcomescreen').manager.current = 'welcomescreen'   

    #########PREENCHIMENTO NOME OBRIGATORIO FUNCAO############
    def check_username(self):
        self.username_text = self.strng.get_screen('usernamescreen').ids.username_text_fied.text
        username_check_false = True
        try:
            int(self.username_text)
        except:
            username_check_false = False
        if username_check_false or self.username_text.split() == []:
                cancel_btn_username_dialogue = MDFlatButton(text='OK',on_release = self.close_username_dialogue)
                self.dialog = MDDialog(title = 'Nome inválido',text = "Por favor preencha um nome válido",size_hint = (0.7,0.2),buttons = [cancel_btn_username_dialogue])
                self.dialog.open()

        else:
            self.strng.get_screen('usernamescreen').ids.disabled_button.disabled = False

    #################BLOCO DE AVISO NOME INVALIDO##################
    def close_username_dialogue(self,obj):
        self.dialog.dismiss()

    def close_username_dialogue_app(self,obj):
        quit()
    #####################BLOCO DE AVISO ECLUIR CHECKLIST##############
    def close_username_dialogue_excluir(self, obj):
        os. remove("dataChecklist.json") 
        self.dialog.dismiss()

        
    
    def get_email(self):
        self.email_text = self.strng.get_screen('dob').ids.email_text_fied.text
        username_check_false = True
        try:
            int(self.username_text)
        except:
            username_check_false = False
        if username_check_false or self.email_text.split() == []:
                cancel_btn_username_dialogue = MDFlatButton(text='OK',on_release = self.close_username_dialogue)
                self.dialog = MDDialog(title = 'Email inválido',text = "Por favor preencha um email válido",size_hint = (0.7,0.2),buttons = [cancel_btn_username_dialogue])
                self.dialog.open()

        else:
            self.strng.get_screen('dob').ids.disabled_button.disabled = False

        ###############SALVANDO EM UM ARQUIVO OS DADOS LOGIN#################
        self.store.put('UserInfo',name = self.username_text, email = self.email_text)
        
        
        ######BUSCANDO NO BANCO AS CHECKLIST############
    def load_checklists_screen_main(self):
        store = JsonStore("dataChecklist.json")
        self.list_name = store.get('UserInfo')['name']
        criado_por = store.get('UserInfo')['data']
        criado_em = store.get('UserInfo')['responsavel']
        
        self.list_name = ThreeLineIconListItem(
        text=self.list_name,
        secondary_text='Responsável: ' + criado_por,
        tertiary_text='Data de emissão: ' + criado_em, on_release=self.change_screen)
        self.list_name.add_widget(IconLeftWidget(icon='check-box-outline'))
        self.strng.get_screen('screen2').ids.my_checklists.add_widget(self.list_name)
        self.strng.get_screen('screen1').manager.current = 'screen1'

        
    def remove_checklist(self):
        self.strng.get_screen('screen2').ids.my_checklists.remove_widget(self.list_name)
        print(self.list_name)
    

    ############AO SELECIONAR UMA CHECKLIST MUDANDO DE TELA##########
    def change_screen(self, ThreeLineIconListItem):
        self.strng.get_screen('screen3').manager.current = 'screen3'

    ###############MUDANDO A TELA PARA INICIAR A VERIFICACAO###########
    def start_checklist(self):
        self.strng.get_screen('screen5').manager.current = 'screen5'
       
    class ContentNavigationDrawer(BoxLayout):  #######PERFIL########
        pass

    class DrawerList(ThemableBehavior, MDList): ######lISTAS DE AÇÕES DO PERFIL######
        pass
コード例 #18
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',
                    ))
コード例 #19
0
    async def load_checklists(self):
        query = gql("""
            query {
                allVerificationLists(completed: false) {
                    id,
                    name,
                    conclusionPercentage
                }
            }
        """)

        result = await async_request(
            query, {"Authentication": f"JWT {self.auth_token}"})

        for question in result["allVerificationLists"]:
            print(question)

        myclient = pymongo.MongoClient(
            "mongodb+srv://julio:[email protected]/kivyapp?retryWrites=true&w=majority"
        )
        db = myclient["kivyapp"]
        col_lv = db["lvs"]

        for item in col_lv.find():

            checklist_table = ThreeLineIconListItem(
                text=item["nome_lv"],
                secondary_text=item["descricao_lv"],
                tertiary_text=item["Data_emissao"],
                on_press=partial(
                    self.checklist_screen,
                    id=str(item["_id"]),
                    nome_lv=item["nome_lv"],
                    descricao_lv=item["descricao_lv"],
                    data_emissao=item["Data_emissao"],
                    porcentagem_c=item["porcentagem_c"],
                    quantidade_nc=item["quantidade_nc"],
                    quantidade_na=item["quantidade_na"],
                    lv_status=item["lv_status"],
                    item1_nome=item["item1_nome"],
                    item1_resultado=item["item1_resultado"],
                    item1_acao=item["item1_acao"],
                    item1_prazo=item["item1_prazo"],
                    item1_responsavel=item["item1_responsavel"],
                    item2_nome=item["item2_nome"],
                    item2_resultado=item["item2_resultado"],
                    item2_acao=item["item2_acao"],
                    item2_prazo=item["item2_prazo"],
                    item2_responsavel=item["item2_responsavel"],
                    item3_nome=item["item3_nome"],
                    item3_resultado=item["item4_resultado"],
                    item3_acao=item["item3_acao"],
                    item3_prazo=item["item3_prazo"],
                    item3_responsavel=item["item3_responsavel"],
                    item4_nome=item["item3_responsavel"],
                    item4_resultado=item["item4_resultado"],
                    item4_acao=item["item4_acao"],
                    item4_prazo=item["item4_prazo"],
                    item4_responsavel=item["item4_responsavel"],
                    item5_nome=item["item5_nome"],
                    item5_resultado=item["item5_resultado"],
                    item5_acao=item["item5_acao"],
                    item5_prazo=item["item5_prazo"],
                    item5_responsavel=item["item5_responsavel"],
                    item6_nome=item["item6_nome"],
                    item6_resultado=item["item6_resultado"],
                    item6_acao=item["item6_acao"],
                    item6_prazo=item["item6_prazo"],
                    item6_responsavel=item["item6_responsavel"],
                    item7_nome=item["item7_nome"],
                    item7_resultado=item["item7_resultado"],
                    item7_acao=item["item7_acao"],
                    item7_prazo=item["item7_prazo"],
                    item7_responsavel=item["item7_responsavel"],
                    item8_nome=item["item8_nome"],
                    item8_resultado=item["item8_resultado"],
                    item8_acao=item["item8_acao"],
                    item8_prazo=item["item8_prazo"],
                    item8_responsavel=item["item8_responsavel"],
                    item9_nome=item["item9_nome"],
                    item9_resultado=item["item9_resultado"],
                    item9_acao=item["item9_acao"],
                    item9_prazo=item["item9_prazo"],
                    item9_responsavel=item["item9_responsavel"],
                ),
            )

            self.manager.get_screen("screen1").ids.checklist.add_widget(
                checklist_table)
コード例 #20
0
class Test(MDGridLayout, MDApp, Widget):
    '''這是螢幕主畫面(不包含一開始進去tutorial,tutorial在650多行那邊的on_start()'''
    '''這邊到300行出頭是一開始進去後會難到的配置,300多行後會是按完Run之後會秀出來的畫面'''

    progress_bar = ObjectProperty()

    def __init__(self, **kwargs):
        super(Test, self).__init__(**kwargs)

        self.click = 0

        # ---以下定義點擊前三名按鈕時的次數---
        self.add1 = 0
        self.add1_shop_list = []
        self.add1_temp_list = []
        self.add1_rent_list = []
        self.add1_bound = []
        self.bound1 = GeoJsonMapLayer()

        self.add2 = 0
        self.add2_shop_list = []
        self.add2_temp_list = []
        self.add2_rent_list = []
        self.add2_bound = []
        self.bound2 = GeoJsonMapLayer()

        self.add3 = 0
        self.add3_shop_list = []
        self.add3_temp_list = []
        self.add3_rent_list = []
        self.add3_bound = []
        self.bound3 = GeoJsonMapLayer()

        # from geopy.geocoders import Nominatim
        # self.geolocator = Nominatim(user_agent="Brian_map")

        # self.wid = Widget()
        self.progress_bar = MDProgressBar()
        self.popup = MDDialog(title='數據加載中,請稍後!',

                              #content = self.progress_bar
                              )
        self.popup.auto_dismiss = False
        self.popup.add_widget(self.progress_bar)
        self.popup.children[1].size_hint = [1, 1]
        self.popup.children[1].children[5].font_size = 40
        self.popup.children[1].children[5].font_name = 'msjhbd.ttc'
        self.popup.size_hint = [0.5, 0.5]
        self.popup.background_color = [0.5, 0.5, 0.5, 0.75]
        self.progress_bar.value = 1
        self.popup.bind(on_open=self.puopen)

        # 主畫面切成左右兩欄
        self.cols = 3

        # 左欄是一個Gridlayout,有四列
        self.left = MDGridLayout(rows=6, size_hint=[0.4, 1], spacing=[0, 3])
        # 創建地圖
        self.map = FarmersMapView()

        # 左欄最上方要來做店租範圍
        self.left.one = MDGridLayout(size=[590, 657],
                                     rows=2,
                                     size_hint=[1, 0.2],
                                     md_bg_color=[0.39, 0.4, 0.72, 1],
                                     padding=[35, -20, 35, -20],
                                     spacing=[0, -30])
        # 把標籤裝進去最上層
        self.left.one.add_widget(
            Label(text='選擇月租範圍',
                  font_size='20sp',
                  font_name='msjhbd.ttc',
                  size_hint_y=0.18))
        # 新增一層容器準備裝三個東西
        self.left.one.box = BoxLayout(spacing=8, size_hint_y=0.15)
        # 盒子裝進一個下限input、一上限input、一個'-'tag
        self.lower_bound = MDTextFieldRect(x=275,
                                           hint_text="$下限",
                                           font_name='msjhbd.ttc',
                                           pos_hint={'y': 0.45},
                                           size_hint=[1.5, 0.5],
                                           use_bubble=True,
                                           use_handles=True)
        self.upper_bound = MDTextFieldRect(hint_text="$上限",
                                           font_name='msjhbd.ttc',
                                           pos_hint={'y': 0.45},
                                           center_x=275.76,
                                           center_y=508.20,
                                           size_hint=[1.5, 0.5],
                                           use_bubble=True,
                                           use_handles=True)
        self.dash_sign = MDFlatButton(text='-',
                                      font_size=30,
                                      size_hint=[1, 0.49],
                                      pos_hint={'y': 0.45})
        self.dash_sign.md_bg_color = [1, 1, 1, 1]
        self.left.one.box.add_widget(self.lower_bound)
        self.left.one.box.add_widget(self.dash_sign)
        self.left.one.box.add_widget(self.upper_bound)
        # 盒子裝回上層
        self.left.one.add_widget(self.left.one.box)

        # 新增行政區選單
        self.left.six = MDGridLayout(size=[590, 657],
                                     rows=2,
                                     size_hint=[1, 0.25],
                                     md_bg_color=[0.39, 0.4, 0.72, 1],
                                     padding=[35, -5, 35, 5],
                                     spacing=[0, -10])
        self.left.six.add_widget(
            Label(text='行政區選擇',
                  font_size='20sp',
                  font_name='msjhbd.ttc',
                  height=32,
                  size_hint=[1, 0.1]))
        self.left.six.box = BoxLayout(size_hint_y=0.15, center_y=390)
        from kivy.uix.spinner import Spinner
        district = [
            "中區", "東區", "西區", "南區", "北區", "西屯區", "南屯區", "北屯區", "豐原區", "大里區",
            "太平區", "清水區", "沙鹿區", "大甲區", "東勢區", "梧棲區", "烏日區", "神岡區", "大肚區",
            "大雅區", "后里區", "霧峰區", "潭子區", "龍井區", "外埔區", "和平區", "石岡區", "大安區",
            "新社區"
        ]
        self.spinner = Spinner(
            text='行政區',
            values=[n for n in district],
            size_hint=(None, None),
            size=(95, 44),
            #pos_hint = {'right':0.2},
            font_name='msjhbd.ttc',
            background_color=[1, 0, 0, 1])
        self.spinner.option_cls.font_name = 'msjhbd.ttc'
        self.spinner.option_cls.background_color = [1, 0, 0, 1]
        #self.spinner.values[0].font_name = 'msjhbd.ttc'
        self.spinner.dropdown_cls.max_height = self.spinner.height * 7 + 7 * 4
        #self.spinner.center_x = 160
        #self.left.six.box.add_widget(BoxLayout(size_hint_y=0.5, size_hint_x=0.5, width=100))
        self.left.six.box.add_widget(
            MDGridLayout(md_bg_color=[0.39, 0.4, 0.72, 1],
                         size_hint=[None, 0.5]))
        self.left.six.box.add_widget(self.spinner)
        self.left.six.add_widget(self.left.six.box)
        #self.left.six.box.children[0].center = (160, 522.1339285)
        #self.spinner.pos_hint = {'right':0.9}
        #self.spinner.center_x = 150

        # 這裡是畫面左欄第二格
        self.left.two = MDGridLayout(rows=2,
                                     size_hint=[1, None],
                                     size=[365, 170],
                                     md_bg_color=[0.39, 0.4, 0.72, 1])
        #self.left.two.center_y = 400
        # 把"指標排序"標籤裝進第二格子的上方
        self.left.two.add_widget(
            Label(text='指標排序',
                  font_size='20sp',
                  font_name='msjhbd.ttc',
                  height=32,
                  size_hint=[1, 0.1]))
        # 左欄第二格下方增加一個grid容器
        self.left.two.grid = MDGridLayout(rows=3,
                                          size_hint=[1, 0.26],
                                          padding=[30, 0, 20, 0])
        self.left.two.grid.size_hint = [1, 0.26]
        self.left.two.add_widget(self.left.two.grid)
        # 準備三個box放入此grid
        self.left.two.box1 = BoxLayout(size_hint=[1, None],
                                       size=[365, 40],
                                       spacing=13)
        self.left.two.box2 = BoxLayout(size_hint=[1, None],
                                       size=[365, 40],
                                       spacing=13)
        self.left.two.box3 = BoxLayout(size_hint=[1, None],
                                       size=[365, 40],
                                       spacing=13)
        self.left.two.grid.add_widget(self.left.two.box1)
        self.left.two.grid.add_widget(self.left.two.box2)
        self.left.two.grid.add_widget(self.left.two.box3)
        # 處理第一個box的標籤(全用按鈕取代)、輸入
        self.left.two.btn1 = MDRaisedButton(text='      人口特性      ',
                                            font_name='msjhbd.ttc',
                                            font_size='16sp')
        self.left.two.btn1.md_bg_color = [0.55, 0.63, 0.99, 1]
        self.left.two.input1 = MDTextFieldRect(hint_text='請輸入1、2、3:',
                                               size_hint=[1, None],
                                               size=[94, 37],
                                               font_name='msjhbd.ttc')
        self.left.two.input1.size_hint_x = None
        self.left.two.input1.width = 120
        self.left.two.box1.add_widget(self.left.two.btn1)
        self.left.two.box1.add_widget(self.left.two.input1)

        self.left.two.btn3 = MDRaisedButton(text='      薪資所得      ',
                                            font_name='msjhbd.ttc',
                                            font_size='16sp')
        self.left.two.btn3.md_bg_color = [0.68, 0.82, 0.96, 1]
        self.left.two.input3 = MDTextFieldRect(hint_text='請輸入1、2、3:',
                                               size_hint=[1, None],
                                               size=[94, 37],
                                               font_name='msjhbd.ttc')
        self.left.two.input3.size_hint_x = None
        self.left.two.input3.width = 120
        self.left.two.box2.add_widget(self.left.two.btn3)
        self.left.two.box2.add_widget(self.left.two.input3)

        self.left.two.btn5 = MDRaisedButton(text='      人口消長      ',
                                            font_name='msjhbd.ttc',
                                            font_size='16sp')
        self.left.two.btn5.md_bg_color = [0.5, 0.87, 0.98, 1]
        self.left.two.input5 = MDTextFieldRect(hint_text='請輸入1、2、3:',
                                               size_hint=[1, None],
                                               size=[94, 37],
                                               font_name='msjhbd.ttc')
        self.left.two.input5.size_hint_x = None
        self.left.two.input5.width = 120
        self.left.two.box3.add_widget(self.left.two.btn5)
        self.left.two.box3.add_widget(self.left.two.input5)

        # 這裡是畫面左欄第三格
        self.left.three = MDGridLayout(rows=2,
                                       md_bg_color=[0.39, 0.4, 0.72, 1],
                                       size_hint=[1, 0.57])
        # 把"指標排序"標籤裝進第二格子的上方
        self.left.three.add_widget(
            Label(text='選擇競爭對手',
                  font_size='20sp',
                  font_name='msjhbd.ttc',
                  height=32,
                  size_hint=[1, 0.06]))

        # 左欄第三格下方增加一個grid容器
        self.left.three.grid = MDGridLayout(rows=5,
                                            size_hint=[1, 0.26],
                                            spacing=3,
                                            padding=[30, 0, 40, 0])
        self.left.three.add_widget(self.left.three.grid)
        # 準備五個box放入此grid
        self.left.three.box1 = BoxLayout(size_hint=[1, 0.05])
        self.left.three.box2 = BoxLayout(size_hint=[1, 0.05])
        self.left.three.box3 = BoxLayout(size_hint=[1, 0.05])
        self.left.three.box4 = BoxLayout(size_hint=[1, 0.05])
        #self.left.three.box5 = BoxLayout(size_hint=[1, 0.4])
        self.left.three.box6 = BoxLayout()
        self.left.three.grid.add_widget(self.left.three.box1)
        self.left.three.grid.add_widget(self.left.three.box2)
        self.left.three.grid.add_widget(self.left.three.box3)
        self.left.three.grid.add_widget(self.left.three.box4)

        # 處理第一個box的標籤(全用按鈕取代)、勾選
        self.left.three.btn1 = MDRaisedButton(text='       早餐店         ',
                                              font_name='msjhbd.ttc',
                                              size_hint=[None, 0.9],
                                              font_size='16sp')
        self.left.three.btn1.md_bg_color = [0.55, 0.63, 0.99, 1]
        self.left.three.input1 = MDCheckbox()
        self.left.three.input1.x = 140
        self.left.three.input1.selected_color = (1, 1, 1, 1)
        self.left.three.input1.unselected_color = (1, 1, 1, 1)
        self.left.three.box1.add_widget(self.left.three.btn1)
        self.left.three.box1.add_widget(self.left.three.input1)
        # 處理第二個box的標籤(全用按鈕取代)、勾選
        self.left.three.btn2 = MDRaisedButton(text='便當、自助餐店',
                                              font_name='msjhbd.ttc',
                                              size_hint=[None, 0.9],
                                              font_size='16sp')
        self.left.three.btn2.md_bg_color = [0.48, 0.81, 0.78, 1]
        self.left.three.input2 = MDCheckbox()
        self.left.three.input2.x = 140
        self.left.three.input2.selected_color = (1, 1, 1, 1)
        self.left.three.input2.unselected_color = (1, 1, 1, 1)
        self.left.three.box2.add_widget(self.left.three.btn2)
        self.left.three.box2.add_widget(self.left.three.input2)
        # 處理第三個box的標籤(全用按鈕取代)、勾選
        self.left.three.btn3 = MDRaisedButton(text='麵店、小吃店    ',
                                              font_name='msjhbd.ttc',
                                              size_hint=[None, 0.9],
                                              font_size='16sp')
        self.left.three.btn3.md_bg_color = [0.68, 0.82, 0.96, 1]
        self.left.three.input3 = MDCheckbox()
        self.left.three.input3.x = 140
        self.left.three.input3.selected_color = (1, 1, 1, 1)
        self.left.three.input3.unselected_color = (1, 1, 1, 1)
        self.left.three.box3.add_widget(self.left.three.btn3)
        self.left.three.box3.add_widget(self.left.three.input3)
        # 處理第四個box的標籤(全用按鈕取代)、勾選
        self.left.three.btn4 = MDRaisedButton(text='      餐館餐廳      ',
                                              font_name='msjhbd.ttc',
                                              size_hint=[None, 0.9],
                                              font_size='16sp')
        self.left.three.btn4.md_bg_color = [0.62, 0.84, 0.51, 1]
        self.left.three.input4 = MDCheckbox()
        self.left.three.input4.x = 140
        #self.left.three.input4.color = [1,1,1,2]
        self.left.three.input4.selected_color = (1, 1, 1, 1)
        self.left.three.input4.unselected_color = (1, 1, 1, 1)
        self.left.three.box4.add_widget(self.left.three.btn4)
        self.left.three.box4.add_widget(self.left.three.input4)

        self.run_button = MDRaisedButton(text='Run')

        # 製作廟宇按鈕
        self.left.four = MDGridLayout(rows=2,
                                      size_hint=[1, None],
                                      size=[365, 90],
                                      md_bg_color=[0.39, 0.4, 0.72, 1])
        self.left.four.add_widget(
            Label(text='廟宇出現與否',
                  font_size='20sp',
                  font_name='msjhbd.ttc',
                  height=32,
                  size_hint=[1, 0.025]))
        self.left.four.box = BoxLayout(size_hint=[1, 0.025],
                                       padding=[30, -20, 40, 5])
        self.left.four.add_widget(self.left.four.box)
        self.left.four.btn = MDRaisedButton(text='          廟宇          ',
                                            font_name='msjhbd.ttc',
                                            size_hint=[None, 0.8],
                                            font_size='16sp')
        self.left.four.input = MDCheckbox()
        self.left.four.input.selected_color = (1, 1, 1, 1)
        self.left.four.input.unselected_color = (1, 1, 1, 1)
        self.left.four.box.add_widget(self.left.four.btn)
        self.left.four.box.add_widget(self.left.four.input)

        # 把每一層加回去
        self.left.add_widget(self.left.one)
        self.left.add_widget(self.left.six)
        self.left.add_widget(self.left.two)
        self.left.add_widget(self.left.three)
        self.left.add_widget(self.left.four)
        self.add_widget(self.left)
        self.add_widget(self.map)

        # 測試用的按鈕
        #self.run_button = MDRaisedButton(text='Run')
        self.left.five = MDGridLayout(size_hint=[1, 0.1],
                                      md_bg_color=[0.39, 0.4, 0.72, 1])
        self.left.five.add_widget(self.run_button)
        self.run_button.bind(on_release=self.popup.open)
        self.left.add_widget(self.left.five)
        self.run_button.right = 270
        self.run_button.ripple_alpha = 0.7
        self.run_button.radius = [10, 10, 10, 10]
        self.run_button.md_bg_color = [1, 1, 1, 1]
        self.run_button.text_color = [0, 0, 0, 1]
        #self.left.six.box.children[0].right = 150
        #self.left.six.box.right = 390
        #self.left.six.box.children[0].pos_hint = {'right':0.001, 'left':0.9}

        #self.left.four.box.pos_hint = {'top':0.5}

    def add_shop(self, neigh, clist, password):
        shop_list = gd.get_shop_codata(neigh, clist)
        # print(shop_list)
        #self.add1 += 1
        #print(self.add1)
        print('###add_shop_func###')
        if shop_list == ['no data']:
            print('')
        else:
            for shop in shop_list:
                lon = float(shop['coor'][1])
                lat = float(shop['coor'][0])
                marker = MapMarkerPopup(lat=lat, lon=lon, source="競爭對手_標點.png")
                marker.add_widget(
                    Button(text=neigh + '\n' + shop['name'] + '\n' +
                           shop['class'],
                           font_name='msjhbd.ttc',
                           font_size=15,
                           size_hint=[None, None],
                           size=[150, 150]))
                self.map.add_marker(marker)
                if (password == 1):
                    self.add1_shop_list.append(marker)
                elif (password == 2):
                    self.add2_shop_list.append(marker)
                elif (password == 3):
                    self.add3_shop_list.append(marker)
            #print(self.add1)
        # else:
        #     for marker in self.add1_shop_list:
        #         self.map.remove_marker(marker)
        #print('sucess')
    def clear_shop(self, password):

        print('###clear_shop_func###')

        if (password == 1):
            print("clear1!")
            for marker in self.add1_shop_list:
                self.map.remove_marker(marker)
            self.add1_shop_list.clear()
        elif (password == 2):
            print("clear2!")
            for marker in self.add2_shop_list:
                self.map.remove_marker(marker)
            self.add2_shop_list.clear()
        elif (password == 3):
            for marker in self.add3_shop_list:
                self.map.remove_marker(marker)
            self.add3_shop_list.clear()

    def add_temp(self, neigh, boolt, password):
        print('###add_temp_func###')

        temp_list = gd.get_temp_codata(neigh)
        # print(temp_list)
        if boolt == True:
            if temp_list == ['no data']:
                print('')
            else:
                for temp in temp_list:
                    lon = float(temp['coor'][1])
                    lat = float(temp['coor'][0])
                    marker = MapMarkerPopup(lat=lat,
                                            lon=lon,
                                            source="廟_標點.png")
                    marker.add_widget(
                        Button(text=neigh + '\n' + temp['name'],
                               font_name='msjhbd.ttc',
                               font_size=15,
                               size_hint=[None, None],
                               size=[100, 100]))
                    self.map.add_widget(marker)
                    if (password == 1):
                        self.add1_temp_list.append(marker)
                    elif (password == 2):
                        self.add2_temp_list.append(marker)
                        print('hoooooo')
                    elif (password == 3):
                        self.add3_temp_list.append(marker)
        else:
            print("")

    def clear_temp(self, password):
        print('###clear_temp_func###')

        if (password == 1):
            print("clear1!")
            for marker in self.add1_temp_list:
                print(marker)
                self.map.remove_marker(marker)
            self.add1_temp_list.clear()
        elif (password == 2):
            print("clear2!")
            for marker in self.add2_temp_list:
                print(marker)
                self.map.remove_marker(marker)
            self.add2_temp_list.clear()
        elif (password == 3):
            for marker in self.add3_temp_list:
                print(marker)
                self.map.remove_marker(marker)
            self.add3_temp_list.clear()

    def add_rent(self, password, neigh, Min_price=0, Max_price=100000000):
        print('###add_rent_func###')

        # print(Min_price, Max_price)
        rent_list = gd.get_rent_codata(neigh)
        # print(rent_list)
        if rent_list == ['no data']:
            print('')
        else:
            cou = 1
            for rent in rent_list:
                if (int(rent['price']) >= Min_price) & (int(rent['price']) <=
                                                        Max_price):
                    lon = float(rent['coor'][1])
                    lat = float(rent['coor'][0])
                    marker = MapMarkerPopup(lat=lat,
                                            lon=lon,
                                            source="店面_標點.png")
                    rent_button = Button(text=neigh + '\n' + '店面' + str(cou) +
                                         '\n' + rent['size'] + '\n' + '$' +
                                         rent['price'] + '/月',
                                         font_name='msjhbd.ttc',
                                         font_size=15,
                                         size_hint=[None, None],
                                         size=[100, 100])
                    rent_button.bind(
                        on_press=partial(webbrowser.open, rent['web']))
                    marker.add_widget(rent_button)
                    self.map.add_widget(marker)
                    cou += 1
                    if (password == 1):
                        self.add1_rent_list.append(marker)
                    elif (password == 2):
                        self.add2_rent_list.append(marker)
                    elif (password == 3):
                        self.add3_rent_list.append(marker)

    def clear_rent(self, password):
        print('###clear_rent_func###')

        if (password == 1):
            print("clear1!")
            for marker in self.add1_rent_list:
                self.map.remove_marker(marker)
            self.add1_rent_list.clear()
        elif (password == 2):
            print("clear2!")
            for marker in self.add2_rent_list:
                self.map.remove_marker(marker)
            self.add2_rent_list.clear()
        elif (password == 3):
            for marker in self.add3_rent_list:
                self.map.remove_marker(marker)
            self.add3_rent_list.clear()

    # def add_border(self, filename):
    #     import os, sys
    #     import json
    #     with open(os.path.realpath(sys.argv[0]).strip(sys.argv[0])+"data\\"+"鄰里邊界\\"+filename, 'r', encoding = 'utf-8') as f:
    #         data = json.load(f)
    #     for i in data['features'][0]['geometry']['coordinates'][0]:
    #         lon = i[0]
    #         lat = i[1]
    #         marker = MapMarkerPopup(lon=lon, lat=lat, source='邊界.png')
    #         self.map.add_widget(marker)

    def add_boundary(self, password):
        print('###add_boundary_func###')

        print('我要密碼')
        print(password)
        # if(self.add1 == 1 and password == 1):
        #     self.bound1 = GeoJsonMapLayer()
        # elif(self.add2 == 1 and password == 2):
        #     self.bound2 = GeoJsonMapLayer()
        # if(self.add3 == 1 and password == 3):
        #     self.bound3 = GeoJsonMapLayer()
        #self.bound3 = GeoJsonMapLayer()

        # if(password == 1):
        #     print('1號邊界成功')
        #     #print("梧棲區\\" + self.rank1.text + ".json")

        #     self.bound1.source = os.path.realpath(sys.argv[0]).strip(sys.argv[0]) + "梧棲區\\" + self.rank1.text + ".json"
        #     self.add1_bound.append(self.bound1)
        #     self.map.add_layer(self.bound1)
        if (password == 1):

            self.bound1.source = os.path.realpath(sys.argv[0]).strip(
                sys.argv[0]
            ) + "data\\" + "鄰里邊界\\" + self.spinner.text + "\\" + self.rank1.text + ".json"

            self.add1_bound.append(self.bound1)
            self.map.add_layer(self.bound1)
        elif (password == 2):

            self.bound2.source = os.path.realpath(sys.argv[0]).strip(
                sys.argv[0]
            ) + "data\\" + "鄰里邊界\\" + self.spinner.text + "\\" + self.rank2.text + ".json"
            self.add2_bound.append(self.bound2)
            self.map.add_layer(self.bound2)
        elif (password == 3):

            self.bound3.source = os.path.realpath(sys.argv[0]).strip(
                sys.argv[0]
            ) + "data\\" + "鄰里邊界\\" + self.spinner.text + "\\" + self.rank3.text + ".json"

            self.add3_bound.append(self.bound3)
            self.map.add_layer(self.bound3)
        # elif(password == 3):
        #     print(password)

        #     self.bound3.source = os.path.realpath(sys.argv[0]).strip(sys.argv[0]) + "梧棲區\\" + self.rank3.text + ".json"
        #     self.add3_bound.append(self.bound3)
        #     self.map.add_layer(self.bound3)
        # if(password == 1):
        #     self.bound1.source = os.path.realpath(sys.argv[0]).strip(sys.argv[0]) + "梧棲區\\" + self.rank1.text + ".json"
        #     #print(bound1.source)
        #     self.add1_bound.append(self.bound1)
        #     print("我是密碼" + str(password))
        #     print(self.rank1.text)
        # elif(password == 2):
        #     self.bound2.source = os.path.realpath(sys.argv[0]).strip(sys.argv[0]) + "梧棲區\\" + self.rank2.text + ".json"
        #     #print(self.bound2.source)
        #     self.add2_bound.append(self.bound2)
        #     print("我是密碼" + str(password))
        #     print(self.rank2.text)
        # elif(password == 3):
        #     self.bound3.source = os.path.realpath(sys.argv[0]).strip(sys.argv[0]) + "梧棲區\\" + self.rank3.text + ".json"
        #     self.add3_bound.append(self.bound3)
        #     print("我是密碼" + str(password))

        # if(password == 1):
        #     self.map.add_layer(self.bound1)
        # elif(password == 2):
        #     self.map.add_layer(self.bound2)
        # elif(password == 3):
        #     self.map.add_layer(self.bound3)

    def remove_boundary(self, password):
        print('###remove_boundary_func###')

        #target = None
        # if(password == 1):
        #     for a in self.add1_bound:
        #         self.map.remove_layer(a)
        #         self.add1_bound.clear()
        if (password == 1):
            for b in self.add1_bound:
                self.map.remove_layer(b)
                self.add1_bound.clear()
        elif (password == 2):
            for b in self.add2_bound:
                self.map.remove_layer(b)
                self.add2_bound.clear()
        elif (password == 3):
            for b in self.add3_bound:
                self.map.remove_layer(b)
                self.add3_bound.clear()
        # elif(password == 3):
        #     for c in self.add3_bound:
        #         self.map.remove_layer(c)
        #         self.add3_bound.clear()
        #print(target, end=',,')
        #self.map.remove_layer(target[0])
        #target.clear()
        #print(target, end=',,')

    '''pressed定義Run之後處理數據並放到資訊卡上的事件'''

    acard = None

    def pressed(self, instance):
        print(self.spinner.text)
        #print(self.spinner.text)
        top3_rank = final_combiner.final_rank([
            int(self.left.two.input1.text),
            int(self.left.two.input3.text),
            int(self.left.two.input5.text)
        ])
        if not self.acard:
            self.rank1 = ThreeLineIconListItem(
                text=top3_rank[0][0],
                secondary_text='人口特性:' + str(top3_rank[0][1]),
                tertiary_text='新資所得:' + str(top3_rank[0][2]),
                text_color=[1, 1, 1, 1])
            self.rank1.add_widget(IconLeftWidget(icon='numeric-1-box'))
            self.rank1.bg_color = [0, 0, 0, 0]
            self.rank1.children[1].children[2].font_name = 'msjhbd.ttc'
            self.rank1.children[1].children[1].font_name = 'msjhbd.ttc'
            self.rank1.children[1].children[0].font_name = 'msjhbd.ttc'
            self.rank1.children[1].children[2].font_size = '18'

            more_rank1 = MDLabel(text='人口消長:' + str(top3_rank[0][3]))
            more_rank1.font_name = 'msjhbd.ttc'
            more_rank1.font_style = 'Body1'
            more_rank1.font_size = 16
            more_rank1.color = [0, 0, 0, 0.7]
            self.rank1.children[1].add_widget(more_rank1)
            self.rank1.children[1].size_hint = [1, None]
            self.rank1.children[1].children[3].pos = [56, 280]

            self.rank1.children[0].children[0].children[0].color = [1, 1, 1, 1]
            self.rank1.children[0].children[0].children[0].pos_hint = {
                'left': 0.1
            }
            self.rank1.children[0].padding = [-10, 0, 0, 0]
            self.rank1.children[1].children[3].theme_text_color = 'Custom'
            self.rank1.children[1].children[3].text_color = [1, 1, 1, 1]
            self.rank1.children[1].children[2].theme_text_color = 'Custom'
            self.rank1.children[1].children[2].text_color = [1, 1, 1, 1]
            self.rank1.children[1].children[1].theme_text_color = 'Custom'
            self.rank1.children[1].children[1].text_color = [1, 1, 1, 1]
            self.rank1.children[1].children[0].theme_text_color = 'Custom'
            self.rank1.children[1].children[0].text_color = [1, 1, 1, 1]
            # 從另一個預先寫好、計算各里指標分數的模組final_combiner引進final_rank函數,取得前三名的區域及其各項指標分數後用top3_rank變數紀錄起來
            # 接著改寫、擴充kivy套件內的工具(ThreeLineIconListItem),做成資訊卡,同時使其擁有按鈕的特性讓使用者做點選

            self.rank2 = ThreeLineIconListItem(
                text=top3_rank[1][0],
                secondary_text='人口特性:' + str(top3_rank[1][1]),
                tertiary_text='新資所得:' + str(top3_rank[1][2]))
            self.rank2.add_widget(IconLeftWidget(icon='numeric-2-box'))
            self.rank2.bg_color = [0, 0, 0, 0]

            self.rank2.children[1].children[2].font_size = '18'
            self.rank2.children[1].children[2].font_name = 'msjhbd.ttc'
            self.rank2.children[1].children[1].font_name = 'msjhbd.ttc'
            self.rank2.children[1].children[0].font_name = 'msjhbd.ttc'

            more_rank2 = MDLabel(text='人口消長:' + str(top3_rank[1][3]))
            more_rank2.font_name = 'msjhbd.ttc'
            more_rank2.font_style = 'Body1'
            more_rank2.font_size = 16
            more_rank2.color = [0, 0, 0, 0.54]
            self.rank2.children[1].add_widget(more_rank2)
            self.rank2.children[1].size_hint = [1, None]

            self.rank2.children[0].children[0].children[0].color = [1, 1, 1, 1]
            self.rank2.children[0].children[0].children[0].pos_hint = {
                'left': 0.1
            }
            self.rank2.children[0].padding = [-10, 0, 0, 0]
            self.rank2.children[1].children[3].theme_text_color = 'Custom'
            self.rank2.children[1].children[3].text_color = [1, 1, 1, 1]
            self.rank2.children[1].children[2].theme_text_color = 'Custom'
            self.rank2.children[1].children[2].text_color = [1, 1, 1, 1]
            self.rank2.children[1].children[1].theme_text_color = 'Custom'
            self.rank2.children[1].children[1].text_color = [1, 1, 1, 1]
            self.rank2.children[1].children[0].theme_text_color = 'Custom'
            self.rank2.children[1].children[0].text_color = [1, 1, 1, 1]

            self.rank3 = ThreeLineIconListItem(
                text=top3_rank[2][0],
                secondary_text='人口特性:' + str(top3_rank[2][1]),
                tertiary_text='新資所得:' + str(top3_rank[2][2]))
            self.rank3.add_widget(IconLeftWidget(icon='numeric-3-box'))
            self.rank3.bg_color = [0, 0, 0, 0]

            self.rank3.children[1].children[2].font_size = '18'
            self.rank3.children[1].children[2].font_name = 'msjhbd.ttc'
            self.rank3.children[1].children[1].font_name = 'msjhbd.ttc'
            self.rank3.children[1].children[0].font_name = 'msjhbd.ttc'

            more_rank3 = MDLabel(text='人口消長:' + str(top3_rank[2][3]))
            more_rank3.font_name = 'msjhbd.ttc'
            more_rank3.font_style = 'Body1'
            more_rank3.font_size = 16
            more_rank3.color = [0, 0, 0, 0.54]
            self.rank3.children[1].add_widget(more_rank3)
            self.rank3.children[1].size_hint = [1, None]

            self.rank3.children[0].children[0].children[0].color = [1, 1, 1, 1]
            self.rank3.children[0].children[0].children[0].pos_hint = {
                'left': 0.1
            }
            self.rank3.children[0].padding = [-10, 0, 0, 0]
            self.rank3.children[1].children[3].theme_text_color = 'Custom'
            self.rank3.children[1].children[3].text_color = [1, 1, 1, 1]
            self.rank3.children[1].children[2].theme_text_color = 'Custom'
            self.rank3.children[1].children[2].text_color = [1, 1, 1, 1]
            self.rank3.children[1].children[1].theme_text_color = 'Custom'
            self.rank3.children[1].children[1].text_color = [1, 1, 1, 1]
            self.rank3.children[1].children[0].theme_text_color = 'Custom'
            self.rank3.children[1].children[0].text_color = [1, 1, 1, 1]

            self.rank1.size = [352, 100]
            self.rank2.size = [352, 100]
            self.rank3.size = [352, 100]

            self.click += 1

            self.rank1.children[1].padding = [56, 16, 24, 7]
            self.rank2.children[1].padding = [56, 4, 24, 7]
            self.rank3.children[1].padding = [56, 4, 24, 7]

            self.rank1.children[1].children[0].adaptive_height = True
            self.rank1.children[1].pos = [0, 180]
            self.rank2.children[1].children[1].adaptive_height = True
            self.rank2.children[1].pos = [0, 130]
            self.rank3.children[1].children[1].adaptive_height = True

            self.add_widget(
                MDGridLayout(cols=1,
                             size_hint=[0.285, 1],
                             md_bg_color=[0.39, 0.4, 0.72, 1]))
            self.children[0].add_widget(self.rank1)
            self.children[0].add_widget(self.rank2)
            self.children[0].add_widget(self.rank3)

            self.rank1.bind(on_release=self.add_renk1_marker)
            self.rank2.bind(on_release=self.add_renk2_marker)
            self.rank3.bind(on_release=self.add_renk3_marker)

    ''' 當初設計沒有想好架構,導致要再次定義pressed事件(第二次之後的Run),如果是如果是第二次點擊Run之後要重新更新資訊卡的內容'''

    def second_pressed(self, instance):
        for i in range(1, 4):
            self.clear_shop(i)
            self.clear_temp(i)
            self.clear_rent(i)
            self.remove_boundary(i)
        self.add1 = 0
        self.add2 = 0
        self.add3 = 0
        #self.map.children[0].unload()
        top3_rank = final_combiner.final_rank([
            int(self.left.two.input1.text),
            int(self.left.two.input3.text),
            int(self.left.two.input5.text)
        ])
        self.rank1.children[1].children[3].text = top3_rank[0][0]
        self.rank1.children[1].children[2].text = "人口特性:" + str(
            top3_rank[0][1])
        self.rank1.children[1].children[1].text = "新資所得:" + str(
            top3_rank[0][2])
        self.rank1.children[1].children[0].text = "人口消長:" + str(
            top3_rank[0][3])

        self.rank2.children[1].children[3].text = top3_rank[1][0]
        self.rank2.children[1].children[2].text = "人口特性:" + str(
            top3_rank[1][1])
        self.rank2.children[1].children[1].text = "新資所得:" + str(
            top3_rank[1][2])
        self.rank2.children[1].children[0].text = "人口消長:" + str(
            top3_rank[1][3])

        self.rank3.children[1].children[3].text = top3_rank[2][0]
        self.rank3.children[1].children[2].text = "人口特性:" + str(
            top3_rank[2][1])
        self.rank3.children[1].children[1].text = "新資所得:" + str(
            top3_rank[2][2])
        self.rank3.children[1].children[0].text = "人口消長:" + str(
            top3_rank[2][3])
        self.rank1.bind(on_release=self.add_renk1_marker)
        self.rank2.bind(on_release=self.add_renk2_marker)
        self.rank3.bind(on_release=self.add_renk3_marker)

    def add_renk1_marker(self, instance):
        # print(len(self.map.children[2]))
        cla_list = [
            self.left.three.btn1.text.strip(),
            self.left.three.btn2.text.strip(),
            self.left.three.btn3.text.strip(),
            self.left.three.btn4.text.strip()
        ]
        ch_list = [
            self.left.three.input1.active, self.left.three.input2.active,
            self.left.three.input3.active, self.left.three.input4.active
        ]
        #print(cla_list, ch_list)
        act_list = []
        for cont in range(4):
            if ch_list[cont] == True:
                act_list.append(cla_list[cont])
        #print(self.rank1.text)
        self.add1 += 1

        if (self.add1 % 2 == 1):
            self.add_boundary(1)
            self.add_shop(self.rank1.text, act_list, 1)
            self.add_temp(self.rank1.text, self.left.four.input.active, 1)
            self.add_rent(1, self.rank1.text, int(self.lower_bound.text),
                          int(self.upper_bound.text))

            # location = self.geolocator.geocode("梧棲區大庄里")
            # self.map.center_on(location.latitude , location.longitude)
            self.map.center_on(24.2454073, 120.54976945174974)
        elif (self.add1 % 2 == 0):
            self.remove_boundary(1)
            self.clear_shop(1)
            self.clear_temp(1)
            self.clear_rent(1)

        # filename = self.rank1.text + ".json"
        # self.add_border(filename)

        self.map.zoom = 13
        # from geopy.geocoders import Nominatim
        # geolocator = Nominatim(user_agent="Brian_map")

    def add_renk2_marker(self, instance):
        cla_list = [
            self.left.three.btn1.text.strip(),
            self.left.three.btn2.text.strip(),
            self.left.three.btn3.text.strip(),
            self.left.three.btn4.text.strip()
        ]
        ch_list = [
            self.left.three.input1.active, self.left.three.input2.active,
            self.left.three.input3.active, self.left.three.input4.active
        ]

        act_list = []
        for cont in range(4):
            if ch_list[cont] == True:
                act_list.append(cla_list[cont])

        self.add2 += 1

        if (self.add2 % 2 == 1):
            self.add_boundary(2)
            self.add_shop(self.rank2.text, act_list, 2)
            self.add_temp(self.rank2.text, self.left.four.input.active, 2)
            self.add_rent(2, self.rank2.text, int(self.lower_bound.text),
                          int(self.upper_bound.text))

            # location = self.geolocator.geocode("梧棲區大村里")
            # self.map.center_on(location.latitude , location.longitude)
            self.map.center_on(24.2549239, 120.5316259)
        elif (self.add2 % 2 == 0):
            self.remove_boundary(2)
            self.clear_shop(2)
            self.clear_temp(2)
            self.clear_rent(2)

    def add_renk3_marker(self, instance):
        cla_list = [
            self.left.three.btn1.text.strip(),
            self.left.three.btn2.text.strip(),
            self.left.three.btn3.text.strip(),
            self.left.three.btn4.text.strip()
        ]
        ch_list = [
            self.left.three.input1.active, self.left.three.input2.active,
            self.left.three.input3.active, self.left.three.input4.active
        ]

        act_list = []
        for cont in range(4):
            if ch_list[cont] == True:
                act_list.append(cla_list[cont])

        self.add3 += 1

        if (self.add3 % 2 == 1):
            self.add_boundary(3)
            self.add_shop(self.rank3.text, act_list, 3)
            self.add_temp(self.rank3.text, self.left.four.input.active, 3)
            self.add_rent(3, self.rank3.text, int(self.lower_bound.text),
                          int(self.upper_bound.text))

            # location = self.geolocator.geocode("梧棲區大村里")
            # self.map.center_on(location.latitude , location.longitude)
            self.map.center_on(24.2570033, 120.53346300048884)
        elif (self.add3 % 2 == 0):
            self.remove_boundary(3)
            self.clear_shop(3)
            self.clear_temp(3)
            self.clear_rent(3)

    '''進度條跑到滿格時,要讓他reset變1'''

    def progress_reset(self, run):
        self.progress_bar.value = 1

    '''讓進度條要一直往右跑,如果滿了就要關掉進度條畫面'''

    def next(self, dt):
        self.progress_bar.value += 6
        if self.progress_bar.value >= 100:

            Clock.schedule_once(self.popup.dismiss, 0.5)
            if self.click == 0:
                Clock.schedule_once(self.pressed, 0.6)
            else:
                Clock.schedule_once(self.second_pressed, 0.6)
            #else:
            Clock.unschedule(self.new)
            Clock.schedule_once(self.progress_reset, 0.6)

    '''定義進度條跑的速率'''

    def puopen(self, instance):

        self.new = Clock.schedule_interval(self.next, 1 / 20)
コード例 #21
0
    def refresh_data(self):
        print("data", self.data)
        self.now = datetime.now()
        tz = pytz.timezone("Etc/GMT+4")
        tz.localize(self.now)

        self.check_expired_alerts()

        hierarchy = []
        weekday = self.now.weekday()
        old_weekday = self.now.weekday()
        hour = self.now.hour
        today = False
        if hour < 14:
            today = True

        for i in range(6):
            if not today:
                i += 1
            i += weekday
            if i == 6:
                i = 0
            elif i > 6:
                i -= 6

            for j in SCHEDULE[i]:
                if j not in hierarchy:
                    hierarchy.append(j)

        self.algoritmus_data = {}
        self.algoritmus_header = ""
        for i in hierarchy:
            for j in self.data:
                if j.startswith(i):
                    self.algoritmus_data[j] = self.data[j]
                    self.algoritmus_header = i
            if self.algoritmus_data:
                break

        self.main_widget.ids.rasp_list.clear_widgets()

        today_list_item = ThreeLineIconListItem()
        today_list_item.text = "Сегодня ({})".format(DAYOFWEEK_DICT[weekday])
        today_list_item.secondary_text = ", ".join(
            SCHEDULE.get(weekday, DEFAULT_SCHED))

        self.main_widget.ids.rasp_list.add_widget(today_list_item)
        self.algoritmus_nextday = "На потом"
        if weekday in (5, 6):
            weekday = -1
        weekday += 1
        if self.algoritmus_header in SCHEDULE.get(weekday, []):
            self.algoritmus_nextday = "На завтра"
        if self.algoritmus_header in SCHEDULE.get(old_weekday, []) and today:
            self.algoritmus_nextday = "СДЕЛАТЬ СЕГОДНЯ!"

        today_list_item = ThreeLineIconListItem()
        today_list_item.text = "Завтра ({})".format(DAYOFWEEK_DICT[weekday])
        today_list_item.secondary_text = ", ".join(
            SCHEDULE.get(weekday, DEFAULT_SCHED))

        self.main_widget.ids.rasp_list.add_widget(today_list_item)

        if self.data:
            self.main_widget.ids.algoritmuscard.set_data(
                self.algoritmus_data, self.algoritmus_header,
                self.algoritmus_nextday)
        else:
            self.main_widget.ids.algoritmuscard.set_data(
                {
                    "Действия":
                    "Попробуй обновить данные. Если ничего не поменялось, отдыхай))"
                }, "Наверное, ты всё сделал", False, "База данных пуста :(")

        self.tasks_data = {}

        self.main_widget.ids.alerts_list.clear_widgets()
        if alerts['unreaded']:
            item = OneLineIconListItem()
            item.text = "Новые"
            item.add_widget(IconLeftWidget(icon="newspaper-plus"))
            self.main_widget.ids.alerts_list.add_widget(item)
            for i in alerts["unreaded"]:
                self.main_widget.ids.alerts_list.add_widget(
                    ThreeLineListItem(text=i[0]))

        if alerts['readed']:
            item = OneLineIconListItem()
            item.text = "Прочитанные"
            item.add_widget(IconLeftWidget(icon="newspaper"))
            self.main_widget.ids.alerts_list.add_widget(item)
            for i in alerts["readed"]:
                self.main_widget.ids.alerts_list.add_widget(
                    ThreeLineListItem(text=i[0]))

        for i in hierarchy:
            self.tasks_data[i] = {}
            for j in self.data:
                if j.startswith(i):
                    self.tasks_data[i][j] = self.data[j]
            if self.tasks_data[i] == {}:
                self.tasks_data[i] = {
                    "Не найдено записей в базе данных":
                    "Обновите базу данных. Если так и остаётся, значит, всё сделано!"
                }

        self.main_widget.ids.tasks_layout.clear_widgets()
        for i in self.tasks_data:
            item = ItemCard()
            nextday = "На потом"
            if i in SCHEDULE[weekday]:
                nextday = "На завтра"
            if today and i in SCHEDULE[old_weekday]:
                nextday = "СДЕЛАТЬ СЕГОДНЯ!!"
            item.set_data(self.tasks_data[i], i, nextday, from_tasks=True)
            self.main_widget.ids.tasks_layout.add_widget(item)
        self.update_db()
        self.refresh_alerts_navdrawer()
コード例 #22
0
ファイル: final2.py プロジェクト: wenjie322/final_project
class Test(MDGridLayout, MDApp, Widget):

    progress_bar = ObjectProperty()

    def __init__(self, **kwargs):
        super(Test, self).__init__(**kwargs)

        self.click = 0

        # rect_color = Color(1,0,0,1)
        # rect_color1 = Color(0,1,1,0.6)
        # rect = Rectangle(pos=(100,10), size=(400,300))
        # rect1 = Rectangle(pos=(400,50), size=(400,300))

        # self.wid = Widget()
        self.progress_bar = MDProgressBar()
        self.popup = Popup(title='數據加載中,請稍後!', content=self.progress_bar)
        self.popup.title_size = 30
        self.popup.title_font = 'msjhbd.ttc'
        self.popup.size_hint = [0.5, 0.5]
        self.popup.background_color = [0.5, 0.5, 0.5, 0.75]
        self.progress_bar.value = 1
        self.popup.bind(on_open=self.puopen)

        # 主畫面切成左右兩欄
        self.cols = 3
        #self.origin = MDGridLayout(cols=2, padding=[35, 0, 35, 0])

        # 左欄是一個Gridlayout,有四列
        self.left = MDGridLayout(rows=5, size_hint=[0.4, 1], spacing=[0, 3])
        # 創建地圖
        self.map = FarmersMapView()

        # 左欄最上方要來做店租範圍
        self.left.one = MDGridLayout(size=[590, 657],
                                     rows=2,
                                     size_hint=[1, 0.2],
                                     md_bg_color=[0.39, 0.4, 0.72, 1],
                                     padding=[35, -20, 35, -20],
                                     spacing=[0, -30])
        # 把標籤裝進去最上層
        self.left.one.add_widget(
            Label(text='選擇店租範圍',
                  font_size='20sp',
                  font_name='msjhbd.ttc',
                  size_hint_y=0.18))
        # 新增一層容器準備裝三個東西
        self.left.one.box = BoxLayout(spacing=8, size_hint_y=0.15)
        # 盒子裝進一個下限input、一上限input、一個'-'tag
        self.lower_bound = MDTextFieldRect(x=275,
                                           hint_text="$下限",
                                           font_name='msjhbd.ttc',
                                           pos_hint={'y': 0.45},
                                           size_hint=[1, 0.5],
                                           use_bubble=True,
                                           use_handles=True)
        self.upper_bound = MDTextFieldRect(hint_text="$上限",
                                           font_name='msjhbd.ttc',
                                           pos_hint={'y': 0.45},
                                           center_x=275.76,
                                           center_y=508.20,
                                           size_hint=[1, 0.5],
                                           use_bubble=True,
                                           use_handles=True)
        self.dash_sign = MDFlatButton(text='-',
                                      font_size=30,
                                      size_hint=[1, 0.49],
                                      pos_hint={'y': 0.45})
        self.dash_sign.md_bg_color = [1, 1, 1, 1]
        self.left.one.box.add_widget(self.lower_bound)
        self.left.one.box.add_widget(self.dash_sign)
        self.left.one.box.add_widget(self.upper_bound)
        # 盒子裝回上層
        self.left.one.add_widget(self.left.one.box)

        # 這裡是畫面左欄第二格
        self.left.two = MDGridLayout(rows=2,
                                     size_hint=[1, None],
                                     size=[365, 180],
                                     md_bg_color=[0.39, 0.4, 0.72, 1])
        #self.left.two.center_y = 400
        # 把"指標排序"標籤裝進第二格子的上方
        self.left.two.add_widget(
            Label(text='指標排序',
                  font_size='20sp',
                  font_name='msjhbd.ttc',
                  height=32,
                  size_hint=[1, 0.1]))
        # 左欄第二格下方增加一個grid容器
        self.left.two.grid = MDGridLayout(rows=3,
                                          size_hint=[1, 0.26],
                                          padding=[30, 0, 20, 0])
        self.left.two.grid.size_hint = [1, 0.26]
        self.left.two.add_widget(self.left.two.grid)
        # 準備三個box放入此grid
        self.left.two.box1 = BoxLayout(size_hint=[1, None],
                                       size=[365, 40],
                                       spacing=13)
        self.left.two.box2 = BoxLayout(size_hint=[1, None],
                                       size=[365, 40],
                                       spacing=13)
        self.left.two.box3 = BoxLayout(size_hint=[1, None],
                                       size=[365, 40],
                                       spacing=13)
        self.left.two.grid.add_widget(self.left.two.box1)
        self.left.two.grid.add_widget(self.left.two.box2)
        self.left.two.grid.add_widget(self.left.two.box3)
        # 處理第一個box的標籤(全用按鈕取代)、輸入
        self.left.two.btn1 = MDRaisedButton(text='      人口特性      ',
                                            font_name='msjhbd.ttc',
                                            font_size='16sp')
        self.left.two.btn1.md_bg_color = [0.55, 0.63, 0.99, 1]
        self.left.two.input1 = MDTextFieldRect(hint_text='排序:',
                                               size_hint=[1, None],
                                               size=[94, 37],
                                               font_name='msjhbd.ttc')
        self.left.two.input1.size_hint_x = None
        self.left.two.input1.width = 120
        #self.left.two.input1.right = 310
        self.left.two.box1.add_widget(self.left.two.btn1)
        self.left.two.box1.add_widget(self.left.two.input1)

        # self.left.two.btn2 = MDRaisedButton(text='薪資所得', font_name='msjhbd.ttc', font_size='16sp')
        # self.left.two.btn2.md_bg_color =  [0.48, 0.81, 0.78, 1]
        # self.left.two.input2 = TextInput(hint_text='排序:', size_hint=[1,None], size=[94,37], font_name='msjhbd.ttc')
        # self.left.two.box1.add_widget(self.left.two.btn2)
        # self.left.two.box1.add_widget(self.left.two.input2)
        # 處理第二個box的標籤(全用按鈕取代)、輸入
        self.left.two.btn3 = MDRaisedButton(text='      薪資所得      ',
                                            font_name='msjhbd.ttc',
                                            font_size='16sp')
        self.left.two.btn3.md_bg_color = [0.68, 0.82, 0.96, 1]
        self.left.two.input3 = MDTextFieldRect(hint_text='排序:',
                                               size_hint=[1, None],
                                               size=[94, 37],
                                               font_name='msjhbd.ttc')
        self.left.two.input3.size_hint_x = None
        self.left.two.input3.width = 120
        self.left.two.box2.add_widget(self.left.two.btn3)
        self.left.two.box2.add_widget(self.left.two.input3)

        # self.left.two.btn4 = MDRaisedButton(text='生活指數', font_name='msjhbd.ttc', font_size='16sp')
        # self.left.two.btn4.md_bg_color =  [0.62, 0.84, 0.51, 1]
        # self.left.two.input4 = TextInput(hint_text='排序:', size_hint=[1,None], size=[94,37], font_name='msjhbd.ttc')
        # self.left.two.box2.add_widget(self.left.two.btn4)
        # self.left.two.box2.add_widget(self.left.two.input4)
        # 處理第三個box的標籤(全用按鈕取代)、輸入
        self.left.two.btn5 = MDRaisedButton(text='      人口消長      ',
                                            font_name='msjhbd.ttc',
                                            font_size='16sp')
        self.left.two.btn5.md_bg_color = [0.5, 0.87, 0.98, 1]
        self.left.two.input5 = MDTextFieldRect(hint_text='排序:',
                                               size_hint=[1, None],
                                               size=[94, 37],
                                               font_name='msjhbd.ttc')
        self.left.two.input5.size_hint_x = None
        self.left.two.input5.width = 120
        self.left.two.box3.add_widget(self.left.two.btn5)
        self.left.two.box3.add_widget(self.left.two.input5)

        # self.left.two.btn6 = MDRaisedButton(text='薪資所得', font_name='msjhbd.ttc', font_size='16sp')
        # self.left.two.btn6.md_bg_color =  [0.81, 0.88, 0.39, 1]
        # self.left.two.input6 = TextInput(hint_text='排序:', size_hint=[1,None], size=[94,37], font_name='msjhbd.ttc')
        # self.left.two.box3.add_widget(self.left.two.btn6)
        # self.left.two.box3.add_widget(self.left.two.input6)

        # 這裡是畫面左欄第三格
        self.left.three = MDGridLayout(rows=2,
                                       md_bg_color=[0.39, 0.4, 0.72, 1],
                                       size_hint=[1, 0.57])
        # 把"指標排序"標籤裝進第二格子的上方
        self.left.three.add_widget(
            Label(text='選擇競爭對手',
                  font_size='20sp',
                  font_name='msjhbd.ttc',
                  height=32,
                  size_hint=[1, 0.06]))

        # 左欄第三格下方增加一個grid容器
        self.left.three.grid = MDGridLayout(rows=5,
                                            size_hint=[1, 0.26],
                                            spacing=3,
                                            padding=[30, 0, 40, 0])
        self.left.three.add_widget(self.left.three.grid)
        # 準備五個box放入此grid
        self.left.three.box1 = BoxLayout(size_hint=[1, 0.05])
        self.left.three.box2 = BoxLayout(size_hint=[1, 0.05])
        self.left.three.box3 = BoxLayout(size_hint=[1, 0.05])
        self.left.three.box4 = BoxLayout(size_hint=[1, 0.05])
        #self.left.three.box5 = BoxLayout(size_hint=[1, 0.4])
        self.left.three.box6 = BoxLayout()
        self.left.three.grid.add_widget(self.left.three.box1)
        self.left.three.grid.add_widget(self.left.three.box2)
        self.left.three.grid.add_widget(self.left.three.box3)
        self.left.three.grid.add_widget(self.left.three.box4)
        #self.left.three.grid.add_widget(self.left.three.box5)
        #self.left.three.grid.add_widget(self.left.three.box6)

        # 處理第一個box的標籤(全用按鈕取代)、勾選
        self.left.three.btn1 = MDRaisedButton(text='       早餐店         ',
                                              font_name='msjhbd.ttc',
                                              size_hint=[None, 0.9],
                                              font_size='16sp')
        self.left.three.btn1.md_bg_color = [0.55, 0.63, 0.99, 1]
        self.left.three.input1 = MDCheckbox()
        self.left.three.input1.x = 140
        #self.left.three.input1.color = [1,1,1,2]
        self.left.three.input1.selected_color = (1, 1, 1, 1)
        self.left.three.input1.unselected_color = (1, 1, 1, 1)
        self.left.three.box1.add_widget(self.left.three.btn1)
        self.left.three.box1.add_widget(self.left.three.input1)
        # 處理第二個box的標籤(全用按鈕取代)、勾選
        self.left.three.btn2 = MDRaisedButton(text='便當、自助餐店',
                                              font_name='msjhbd.ttc',
                                              size_hint=[None, 0.9],
                                              font_size='16sp')
        self.left.three.btn2.md_bg_color = [0.48, 0.81, 0.78, 1]
        self.left.three.input2 = MDCheckbox()
        self.left.three.input2.x = 140
        #self.left.three.input2.color = [1,1,1,2]
        self.left.three.input2.selected_color = (1, 1, 1, 1)
        self.left.three.input2.unselected_color = (1, 1, 1, 1)
        self.left.three.box2.add_widget(self.left.three.btn2)
        self.left.three.box2.add_widget(self.left.three.input2)
        # 處理第三個box的標籤(全用按鈕取代)、勾選
        self.left.three.btn3 = MDRaisedButton(text='麵店、小吃店    ',
                                              font_name='msjhbd.ttc',
                                              size_hint=[None, 0.9],
                                              font_size='16sp')
        self.left.three.btn3.md_bg_color = [0.68, 0.82, 0.96, 1]
        self.left.three.input3 = MDCheckbox()
        self.left.three.input3.x = 140
        #self.left.three.input3.color = [1,1,1,2]
        self.left.three.input3.selected_color = (1, 1, 1, 1)
        self.left.three.input3.unselected_color = (1, 1, 1, 1)
        self.left.three.box3.add_widget(self.left.three.btn3)
        self.left.three.box3.add_widget(self.left.three.input3)
        # 處理第四個box的標籤(全用按鈕取代)、勾選
        self.left.three.btn4 = MDRaisedButton(text='      餐館餐廳      ',
                                              font_name='msjhbd.ttc',
                                              size_hint=[None, 0.9],
                                              font_size='16sp')
        self.left.three.btn4.md_bg_color = [0.62, 0.84, 0.51, 1]
        self.left.three.input4 = MDCheckbox()
        self.left.three.input4.x = 140
        #self.left.three.input4.color = [1,1,1,2]
        self.left.three.input4.selected_color = (1, 1, 1, 1)
        self.left.three.input4.unselected_color = (1, 1, 1, 1)
        self.left.three.box4.add_widget(self.left.three.btn4)
        self.left.three.box4.add_widget(self.left.three.input4)
        # 處理第五個box的標籤(全用按鈕取代)、勾選
        # self.left.three.btn5 = MDRaisedButton(text='咖啡館', font_name='msjhbd.ttc', size_hint=[None, 1], font_size='16sp')
        # self.left.three.btn5.md_bg_color = [0.62, 0.84, 0.51, 1]
        # self.left.three.input5 = CheckBox()
        # self.left.three.input5.color = [1,1,1,2]
        # self.left.three.box5.add_widget(self.left.three.btn5)
        # self.left.three.box5.add_widget(self.left.three.input5)

        self.run_button = MDRaisedButton(text='Run')
        #self.left.three.box6.add_widget(self.run_button)

        # 製作廟宇按鈕
        self.left.four = MDGridLayout(rows=2,
                                      size_hint=[1, None],
                                      size=[365, 110],
                                      md_bg_color=[0.39, 0.4, 0.72, 1])
        self.left.four.add_widget(
            Label(text='廟宇出現與否',
                  font_size='20sp',
                  font_name='msjhbd.ttc',
                  height=32,
                  size_hint=[1, 0.04]))
        self.left.four.box = BoxLayout(size_hint=[1, 0.035],
                                       padding=[30, 0, 40, 0])
        self.left.four.add_widget(self.left.four.box)
        self.left.four.btn = MDRaisedButton(text='          廟宇          ',
                                            font_name='msjhbd.ttc',
                                            size_hint=[None, 1],
                                            font_size='16sp')
        self.left.four.input = MDCheckbox()
        self.left.four.input.selected_color = (1, 1, 1, 1)
        self.left.four.input.unselected_color = (1, 1, 1, 1)
        self.left.four.box.add_widget(self.left.four.btn)
        self.left.four.box.add_widget(self.left.four.input)

        # 把每一層加回去
        self.left.add_widget(self.left.one)
        self.left.add_widget(self.left.two)
        self.left.add_widget(self.left.three)
        self.left.add_widget(self.left.four)
        self.add_widget(self.left)
        self.add_widget(self.map)

        #self.add_widget(self.right)
        #self.add_widget(self.right)

        # 測試用的按鈕
        #self.run_button = MDRaisedButton(text='Run')
        self.run_button.bind(on_release=self.popup.open)
        self.left.add_widget(self.run_button)
        #elf.left.add_widget(self.run_button)

    def add_shop(self, neigh, clist):
        shop_list = gd.get_shop_codata(neigh, clist)
        # print(shop_list)
        if shop_list == ['no data']:
            print('no shop data')
        else:
            for shop in shop_list:
                lon = float(shop['coor'][1])
                lat = float(shop['coor'][0])
                marker = MapMarkerPopup(lat=lat, lon=lon, source="競爭對手_標點.png")
                marker.add_widget(
                    Button(text=neigh + '\n' + shop['name'] + '\n' +
                           shop['class'],
                           font_name='msjhbd.ttc',
                           font_size=15,
                           size_hint=[None, None],
                           size=[150, 150]))
                self.map.add_widget(marker)

    def add_temp(self, neigh, boolt):
        temp_list = gd.get_temp_codata(neigh)
        # print(temp_list)
        if boolt == True:
            if temp_list == ['no data']:
                print('no temple data')
            else:
                for temp in temp_list:
                    lon = float(temp['coor'][1])
                    lat = float(temp['coor'][0])
                    marker = MapMarkerPopup(lat=lat,
                                            lon=lon,
                                            source="廟_標點.png")
                    marker.add_widget(
                        Button(text=neigh + '\n' + temp['name'],
                               font_name='msjhbd.ttc',
                               font_size=15,
                               size_hint=[None, None],
                               size=[100, 100]))
                    self.map.add_widget(marker)
        else:
            print("do not show temple")

    def add_rent(self, neigh, Min_price=0, Max_price=100000000):
        print(Min_price, Max_price)
        rent_list = gd.get_rent_codata(neigh)
        # print(rent_list)
        if rent_list == ['no data']:
            print('no rent data')
        else:
            cou = 1
            for rent in rent_list:
                if (int(rent['price']) >= Min_price) & (int(rent['price']) <=
                                                        Max_price):
                    lon = float(rent['coor'][1])
                    lat = float(rent['coor'][0])
                    marker = MapMarkerPopup(lat=lat,
                                            lon=lon,
                                            source="店面_標點.png")
                    rent_button = Button(text=neigh + '\n' + '店面' + str(cou) +
                                         '\n' + rent['size'] + '\n' + '$' +
                                         rent['price'] + '/月',
                                         font_name='msjhbd.ttc',
                                         font_size=15,
                                         size_hint=[None, None],
                                         size=[100, 100])
                    rent_button.bind(
                        on_press=partial(webbrowser.open, rent['web']))
                    marker.add_widget(rent_button)
                    self.map.add_widget(marker)
                    cou += 1

    acard = None

    def pressed(self, instance):
        print([
            int(self.left.two.input1.text),
            int(self.left.two.input3.text),
            int(self.left.two.input5.text)
        ])
        a = final_combiner.final_rank([
            int(self.left.two.input1.text),
            int(self.left.two.input3.text),
            int(self.left.two.input5.text)
        ])
        print(a)
        if not self.acard:
            #bb = ThreeLineIconListItem(text=self.left.two.input1.text, secondary_text='22', tertiary_text='333')
            #bb.add_widget(IconLeftWidget(icon='language-python'))
            #bb.bg_color = [0.5,1,1,1]
            print(a)
            self.rank1 = ThreeLineIconListItem(
                text=a[0][0],
                secondary_text='人口特性:' + str(a[0][1]),
                tertiary_text='新資所得:' + str(a[0][2]))  # , size = [352, 100]
            self.rank1.add_widget(IconLeftWidget(icon='numeric-1-box'))
            self.rank1.bg_color = [0.5, 0.5, 0.5, 0.5]
            self.rank1.children[1].children[2].font_name = 'msjhbd.ttc'
            self.rank1.children[1].children[1].font_name = 'msjhbd.ttc'
            self.rank1.children[1].children[0].font_name = 'msjhbd.ttc'
            self.rank1.children[1].children[2].font_size = '18'

            more_rank1 = MDLabel(text='人口消長:' + str(a[0][3]))
            more_rank1.font_name = 'msjhbd.ttc'
            more_rank1.font_style = 'Body1'
            more_rank1.font_size = 16
            more_rank1.color = [0, 0, 0, 0.54]
            self.rank1.children[1].add_widget(more_rank1)
            self.rank1.children[1].size_hint = [1, None]
            self.rank1.children[1].children[3].pos = [56, 280]

            self.rank2 = ThreeLineIconListItem(
                text=a[1][0],
                secondary_text='人口特性:' + str(a[1][1]),
                tertiary_text='新資所得:' + str(a[1][2]))
            #rank2.children[1].add_widget(MDLabel(text='新資所得' + str(a[1][2]), font_name='msjhbd.ttc', font_size=16, font_style='Body1'))
            #rank2.add_widget(tertiary_text='新資所得' + str(a[1][2]))
            self.rank2.add_widget(IconLeftWidget(icon='numeric-2-box'))
            self.rank2.bg_color = [0.5, 0.5, 0.5, 0.5]

            self.rank2.children[1].children[2].font_size = '18'
            self.rank2.children[1].children[2].font_name = 'msjhbd.ttc'
            self.rank2.children[1].children[1].font_name = 'msjhbd.ttc'
            self.rank2.children[1].children[0].font_name = 'msjhbd.ttc'

            more_rank2 = MDLabel(text='人口消長:' + str(a[1][3]))
            more_rank2.font_name = 'msjhbd.ttc'
            more_rank2.font_style = 'Body1'
            more_rank2.font_size = 16
            more_rank2.color = [0, 0, 0, 0.54]
            self.rank2.children[1].add_widget(more_rank2)
            self.rank2.children[1].size_hint = [1, None]

            self.rank3 = ThreeLineIconListItem(
                text=a[2][0],
                secondary_text='人口特性:' + str(a[2][1]),
                tertiary_text='新資所得:' + str(a[2][2]))
            #rank2.children[1].add_widget(MDLabel(text='新資所得' + str(a[1][2]), font_name='msjhbd.ttc', font_size=16, font_style='Body1'))
            #rank2.add_widget(tertiary_text='新資所得' + str(a[1][2]))
            self.rank3.add_widget(IconLeftWidget(icon='numeric-3-box'))
            self.rank3.bg_color = [0.5, 0.5, 0.5, 0.5]

            self.rank3.children[1].children[2].font_size = '18'
            self.rank3.children[1].children[2].font_name = 'msjhbd.ttc'
            self.rank3.children[1].children[1].font_name = 'msjhbd.ttc'
            self.rank3.children[1].children[0].font_name = 'msjhbd.ttc'

            more_rank3 = MDLabel(text='人口消長:' + str(a[2][3]))
            more_rank3.font_name = 'msjhbd.ttc'
            more_rank3.font_style = 'Body1'
            more_rank3.font_size = 16
            more_rank3.color = [0, 0, 0, 0.54]
            self.rank3.children[1].add_widget(more_rank3)
            self.rank3.children[1].size_hint = [1, None]
            # rank2.children[1].(MDLabel(text='新資所得' + str(a[1][2])))
            # rank2.children[1].children[3].font_name = 'msjhbd.ttc'
            # rank2.children[1].children[3].font_size = 16
            # rank2.children[1].children[3].font_style = 'Body1'

            self.rank1.size = [352, 100]
            self.rank2.size = [352, 100]
            self.rank3.size = [352, 100]
            #rank1.children[1].pos_hint = {'y': 1}

            self.click += 1
            self.rank1.bind(on_release=self.add_renk1_marker)
            self.rank2.bind(on_release=self.add_renk2_marker)
            self.rank3.bind(on_release=self.add_renk3_marker)
            # self.acard = MDDialog(
            #     #title="Discard draft?",
            #     type="simple",
            #     items=[
            #         rank1,
            #         rank2,
            #         rank3
            #     ],
            #     buttons=[
            #         MDFlatButton(
            #             text="     ", text_color=self.theme_cls.primary_color
            #         ),
            #         MDRectangleFlatIconButton(
            #             text="I know!", text_color=self.theme_cls.primary_color, font_name='msjhbd.ttc', on_release=self.dialog_vanish

            #         )
            #     ],

            #     #center = [640, 480]
            # )

            # self.acard.center = [640, 480]
            # self.acard.background_color = [0,0,0,0]
            # self.acard.md_bg_color = [0.9607,0.9607,0.9607,0.6]
            # self.acard.auto_dismiss = False
            # #self.rank1 = TwoLineIconListItem(text=self.left.two.input1.text, icon='crown')
            # #self.rank1 = FourLineIconListItem(text=self.left.two.input1.text, text_color=[0,0,0,1])
            # #self.rank1.add_widget(IconLeftWidget(icon='language-python'))
            # #self.rank1.bg_color=[0.5,0.5,0.5,0.5]

            # self.acard.size_hint = [0.25, 0.5]
            # self.acard.children[0].size_hint = [1, 1.1]
            # self.acard.children[0].children[2].children[0].spacing = [0, 3]  # 這式調整各rank之間距離
            # self.acard.children[0].children[2].size_hint = [1,1]  # 這是調scrollview的size比例,不要有捲動行為
            # self.acard.children[0].children[2].bar_width = 5
            # self.acard.children[0].children[2].bar_color = [0.5, 0.5, 0.7, 1]
            #self.acard.children[0].children[2].children[0].children[2].size_hint = [1, 1]
            #self.acard.children[0].children[2].children[0].size_hint = [1,1]  # 這是調
            #self.acard.children[0].children[2].children[0].add_widget(self.rank1)

            self.rank1.children[1].padding = [56, 16, 24, 7]
            self.rank2.children[1].padding = [56, 4, 24, 7]
            self.rank3.children[1].padding = [56, 4, 24, 7]

            self.rank1.children[1].children[0].adaptive_height = True
            self.rank1.children[1].pos = [0, 180]
            self.rank2.children[1].children[1].adaptive_height = True
            self.rank2.children[1].pos = [0, 130]
            self.rank3.children[1].children[1].adaptive_height = True
            #rank1.children[1].children[0].valign = 'top'
            #rank1.children[1].children[0].y = 224
            #self.acard.
            # self.acard.center_y = 480
            # self.acard.pos_hint = {'top':0.99, 'right':1}
            # self.wid.add_widget(self.rank1)
            # self.wid.add_widget(self.rank2)
            # self.r.add_widget(self.rank3)
            self.add_widget(
                MDGridLayout(cols=1,
                             size_hint=[0.285, 1],
                             md_bg_color=[0.39, 0.4, 0.72, 1]))
            self.children[0].add_widget(self.rank1)
            self.children[0].add_widget(self.rank2)
            self.children[0].add_widget(self.rank3)

    def second_pressed(self, instance):
        self.map.children[0].unload()
        a = final_combiner.final_rank([
            int(self.left.two.input1.text),
            int(self.left.two.input3.text),
            int(self.left.two.input5.text)
        ])
        self.rank1.children[1].children[3].text = a[0][0]
        self.rank1.children[1].children[2].text = "人口特性:" + str(a[0][1])
        self.rank1.children[1].children[1].text = "新資所得:" + str(a[0][2])
        self.rank1.children[1].children[0].text = "人口消長:" + str(a[0][3])

        self.rank2.children[1].children[3].text = a[1][0]
        self.rank2.children[1].children[2].text = "人口特性:" + str(a[1][1])
        self.rank2.children[1].children[1].text = "新資所得:" + str(a[1][2])
        self.rank2.children[1].children[0].text = "人口消長:" + str(a[1][3])

        self.rank3.children[1].children[3].text = a[2][0]
        self.rank3.children[1].children[2].text = "人口特性:" + str(a[2][1])
        self.rank3.children[1].children[1].text = "新資所得:" + str(a[2][2])
        self.rank3.children[1].children[0].text = "人口消長:" + str(a[2][3])
        self.rank1.bind(on_release=self.add_renk1_marker)
        self.rank2.bind(on_release=self.add_renk2_marker)
        self.rank3.bind(on_release=self.add_renk3_marker)

    def add_renk1_marker(self, instance):
        # print(len(self.map.children[2]))
        cla_list = [
            self.left.three.btn1.text.strip(),
            self.left.three.btn2.text.strip(),
            self.left.three.btn3.text.strip(),
            self.left.three.btn4.text.strip()
        ]
        ch_list = [
            self.left.three.input1.active, self.left.three.input2.active,
            self.left.three.input3.active, self.left.three.input4.active
        ]

        act_list = []
        for cont in range(4):
            if ch_list[cont] == True:
                act_list.append(cla_list[cont])
        self.add_shop(self.rank1.text, act_list)
        self.add_temp(self.rank1.text, self.left.four.input.active)
        self.add_rent(self.rank1.text, int(self.lower_bound.text),
                      int(self.upper_bound.text))

    def add_renk2_marker(self, instance):
        cla_list = [
            self.left.three.btn1.text.strip(),
            self.left.three.btn2.text.strip(),
            self.left.three.btn3.text.strip(),
            self.left.three.btn4.text.strip()
        ]
        ch_list = [
            self.left.three.input1.active, self.left.three.input2.active,
            self.left.three.input3.active, self.left.three.input4.active
        ]

        act_list = []
        for cont in range(4):
            if ch_list[cont] == True:
                act_list.append(cla_list[cont])
        self.add_shop(self.rank2.text, act_list)
        self.add_temp(self.rank2.text, self.left.four.input.active)
        self.add_rent(self.rank2.text, int(self.lower_bound.text),
                      int(self.upper_bound.text))

    def add_renk3_marker(self, instance):
        cla_list = [
            self.left.three.btn1.text.strip(),
            self.left.three.btn2.text.strip(),
            self.left.three.btn3.text.strip(),
            self.left.three.btn4.text.strip()
        ]
        ch_list = [
            self.left.three.input1.active, self.left.three.input2.active,
            self.left.three.input3.active, self.left.three.input4.active
        ]

        act_list = []
        for cont in range(4):
            if ch_list[cont] == True:
                act_list.append(cla_list[cont])
        self.add_shop(self.rank3.text, act_list)
        self.add_temp(self.rank3.text, self.left.four.input.active)
        self.add_rent(self.rank3.text, int(self.lower_bound.text),
                      int(self.upper_bound.text))

    def dialog_vanish(self, obj):
        self.acard.dismiss()

    #self.add_widget(Button(text ='Download', on_release = self.pop))
    # the function which works when you clicj = k the button

    #self.popup.open()
    def progress_reset(self, run):
        self.progress_bar.value = 1

        #self.add_widget(MDRaisedButton(text='hi',md_bg_color=[1,0,0,1]))
        #self.canvas.add(rect_color)
        # self.canvas.add(rect)

        #rect_color1
        #rect1

        # Add a red color
        #Color(1., 0, 0)

        # Add a rectangle

        # Button(text='ho')
        #Color(1., 0, 0)
        #self.canvas.open()

    # To continuesly increasing the value of pb.
    def next(self, dt):
        self.progress_bar.value += 6
        if self.progress_bar.value >= 100:

            Clock.schedule_once(self.popup.dismiss, 0.5)
            if self.click == 0:
                Clock.schedule_once(self.pressed, 0.6)
            else:
                Clock.schedule_once(self.second_pressed, 0.6)
            #else:
            Clock.unschedule(self.event)
            Clock.schedule_once(self.progress_reset, 0.6)

    def puopen(self, instance):

        self.event = Clock.schedule_interval(self.next, 1 / 20)