def add_input(self, input):
     if input:
         field = MDTextFieldRect(
             size_hint=(None, None),
             size=(self.width - dp(40), dp(30)),
             pos_hint={
                 "center_y": 0.5,
                 "center_x": 0.5
             },
         )
         if isinstance(input, str):
             field.hint_text = input
         self.content_cls.add_widget(field)
Beispiel #2
0
    def build(self):
        self.operators = ["^", " / ", " * ", " + ", " - "]
        # operators /,*,+,- are added with leading and trailing space to make
        # identification possible between that and negative numbers
        self.last_was_operator = None
        self.last_button = None
        main_layout = MDBoxLayout(orientation="vertical")
        self.solution = MDTextFieldRect(multiline=False,
                                        readonly=True,
                                        size_hint=[1, None],
                                        halign="right",
                                        height="80sp",
                                        font_size='55sp')
        main_layout.add_widget(self.solution)
        buttons = [["", "C", "<-", "^"], ["", "", "", " / "],
                   ["7", "8", "9", " * "], ["4", "5", "6", " - "],
                   ["1", "2", "3", " + "], ["+/-", "0", ".", "="]]
        for row in buttons:
            h_layout = MDBoxLayout()
            for label in row:
                button = MDRectangleFlatButton(text=label,
                                               pos_hint={
                                                   "center_x": 0.5,
                                                   "center_y": 0.5
                                               },
                                               size_hint=(1, 1),
                                               font_size='20sp')
                button.bind(on_press=self.on_button_press)
                h_layout.add_widget(button)
            main_layout.add_widget(h_layout)

        return main_layout
Beispiel #3
0
    def build(self):
        Window.size=(350,180)
        screen = MDScreen()
        layout = BoxLayout(orientation="vertical")
        self.b_9=MDRaisedButton(text="9",on_press=self.insert_text)
        self.b_8=MDRaisedButton(text="8",on_press=self.insert_text)
        self.b_7=MDRaisedButton(text="7",on_press=self.insert_text)
        self.b_6=MDRaisedButton(text="6",on_press=self.insert_text)
        self.b_5=MDRaisedButton(text="5",on_press=self.insert_text)
        self.b_4=MDRaisedButton(text="4",on_press=self.insert_text)
        self.b_3=MDRaisedButton(text="3",on_press=self.insert_text)
        self.b_2=MDRaisedButton(text="2",on_press=self.insert_text)
        self.b_1=MDRaisedButton(text="1",on_press=self.insert_text)
        self.b_zero=MDRaisedButton(text="0",on_press=self.insert_text)
        self.b_equals=MDRaisedButton(text="=",on_press=self.equals)
        self.b_CLR=MDRaisedButton(text="CLR",on_press=self.clear_text)
        self.b_plus=MDRaisedButton(text="+",on_press=self.addition)
        self.b_minus=MDRaisedButton(text="-",on_press=self.sub)
        self.b_mul=MDRaisedButton(text="*",on_press=self.mul)
        self.b_Div=MDRaisedButton(text="/",on_press=self.div)
        self.text_field = MDTextFieldRect(text="",size_hint=(1, None),height="30dp",pos_hint={'centr_x':0,'center_y':0.96})
        gl = GridLayout(cols=4)
        layout.add_widget(self.text_field)

        lis=[self.b_9,self.b_8,self.b_7,self.b_plus,self.b_6,self.b_5,self.b_4,self.b_minus,self.b_3,self.b_2,self.b_1,self.b_mul,self.b_CLR,self.b_zero,self.b_equals,self.b_Div]
        for k in lis:
            gl.add_widget(k)
        
        
        layout.add_widget(gl)
        return layout
Beispiel #4
0
    def __init__(self, **kwargs):
        super().__init__()

        with self.canvas.before:
            Color(rgba=(0, .4, 0, 0.1))
            self.rect = RoundedRectangle(
                radius=[(40.0, 40.0), (40.0, 40.0), (40.0, 40.0), (40.0,
                                                                   40.0)])
        self.bind(pos=self.update_rect, size=self.update_rect)

        self.operation = kwargs["operation"]

        self.title = MDLabel(text=kwargs["title"],
                             pos_hint={
                                 "center_x": .5,
                                 "top": .9
                             },
                             size_hint=(.5, .3),
                             theme_text_color="Primary",
                             font_style="H6",
                             halign="center")
        self.text_field = MDTextFieldRect(pos_hint={
            "center_x": .25,
            "center_y": .4
        },
                                          size_hint=(.20, .20),
                                          hint_text="Ingresar Valor",
                                          halign="center")
        self.button = MDIconButton(on_release=self.ejecutar,
                                   pos_hint={
                                       "center_x": .5,
                                       "center_y": .4
                                   },
                                   size_hint=(.2, .3),
                                   icon="arrow-right-bold")
        self.result = MDLabel(pos_hint={
            "center_x": .75,
            "center_y": .4
        },
                              size_hint=(.2, .5),
                              halign="center")

        self.add_widget(self.title)
        self.add_widget(self.text_field)
        self.add_widget(self.button)
        self.add_widget(self.result)
    def makeQuestionPage(self):

        # Discovery Page

        screen = Screen(name='question')
        self.discoveryScreen = screen

        layout = StackLayout(orientation="tb-lr",
                             spacing=10,
                             size_hint=(1, None))
        screen.add_widget(layout)

        self.questionLabel = label = self.saneLabel(text='', container=layout)

        self.questionTextbox = textbox = MDTextFieldRect(text='',
                                                         multiline=True,
                                                         size_hint=(0.68,
                                                                    None))
        layout.add_widget(self.questionLabel)

        layout.add_widget(textbox)

        def cbr_no(*a):
            self.screenManager.current = self.preQuestionScreen

        def cbr_yes(*a):
            self.screenManager.current = self.preQuestionScreen
            self.questionCallback(textbox.text)

        layout.add_widget(
            Button(text="Cancel",
                   text_color=self.theme_cls.primary_color,
                   on_press=cbr_no))
        layout.add_widget(
            Button(text="Accept",
                   text_color=self.theme_cls.primary_color,
                   on_press=cbr_yes))
        layout.add_widget(Widget())

        return screen
    def __init__(self, **kwargs):
        super().__init__()

        with self.canvas.before:
            Color(rgb=(.9, .9, .9, 0.1)) #r g b transparencia
            self.rect = RoundedRectangle(radius=[(40.0,40.0),(40.0,40.0),(40.0,40.0),(40.0,40.0)])
        
        self.bind(pos = self.update_rect, size = self.update_rect)
        
        self.operation = kwargs["operation"]
        
        self.title = MDLabel(text = kwargs["title"],
                             pos_hint = {"center_x": .5, "top":.99},
                             size_hint = (.3,.2),
                             theme_text_color = "Primary", 
                             font_style= "Subtitle1",
                             halign = "center")
        
        self.text_field = MDTextFieldRect(pos_hint = {"center_x": .5, "top": .7},
                                          size_hint = (.4, .13),
                                          hint_text = "Ingresa el Valor",
                                          halign = "center")       
        
        self.button = MDRectangleFlatIconButton(on_release = self.ejecutar,                                        
                                               pos_hint = {"center_x":.5, "top": .5},
                                               size_hint = (.3,.1),
                                               icon = "math-compass",
                                               text = "Convertir")
        
        self.result = MDLabel(pos_hint = {"center_x": .5, "top": .3},
                              size_hint = (.5,.2),
                              halign = "center")
        
        self.add_widget(self.title)
        self.add_widget(self.text_field)
        self.add_widget(self.button)
        self.add_widget(self.result)
Beispiel #7
0
	def set_content(self, instance_content_dialog):
		def _events_callback(result_press):
			self.dismiss()
			if result_press and self.events_callback:
				self.events_callback(result_press, self)

		if self.device_ios:  # create buttons for iOS
			self.background = self._background

			if isinstance(instance_content_dialog, ContentInputDialog):
				self.text_field = MDTextFieldRect(
					pos_hint={"center_x": 0.5},
					size_hint=(1, None),
					multiline=False,
					height=dp(33),
					cursor_color=self.theme_cls.primary_color,
					hint_text=instance_content_dialog.hint_text,
				)
				instance_content_dialog.ids.box_input.height = dp(33)
				instance_content_dialog.ids.box_input.add_widget(
					self.text_field
				)

			if self.text_button_cancel != "":
				anchor = "left"
			else:
				anchor = "center"
			box_button_ok = AnchorLayout(anchor_x=anchor)
			box_button_ok.add_widget(
				MDTextButton(
					text=self.text_button_ok,
					font_size="18sp",
					on_release=lambda x: _events_callback(self.text_button_ok),
				)
			)
			instance_content_dialog.ids.box_buttons.add_widget(box_button_ok)

			if self.text_button_cancel != "":
				box_button_ok.anchor_x = "left"
				box_button_cancel = AnchorLayout(anchor_x="right")
				box_button_cancel.add_widget(
					MDTextButton(
						text=self.text_button_cancel,
						font_size="18sp",
						on_release=lambda x: _events_callback(
							self.text_button_cancel
						),
					)
				)
				instance_content_dialog.ids.box_buttons.add_widget(
					box_button_cancel
				)

		else:  # create buttons for Android
			if isinstance(instance_content_dialog, ContentInputDialog):
				self.text_field = MDTextField(
					size_hint=(1, None),
					height=dp(48),
					hint_text=instance_content_dialog.hint_text,
				)
				instance_content_dialog.ids.box_input.height = dp(48)
				instance_content_dialog.ids.box_input.add_widget(
					self.text_field
				)
				instance_content_dialog.ids.box_buttons.remove_widget(
					instance_content_dialog.ids.sep
				)

			box_buttons = AnchorLayout(
				anchor_x="right", size_hint_y=None, height=dp(30)
			)
			box = BoxLayout(size_hint_x=None, spacing=dp(5))
			box.bind(minimum_width=box.setter("width"))
			button_ok = MDRaisedButton(
				text=self.text_button_ok,
				on_release=lambda x: _events_callback(self.text_button_ok),
			)
			box.add_widget(button_ok)

			if self.text_button_cancel != "":
				button_cancel = MDFlatButton(
					text=self.text_button_cancel,
					theme_text_color="Custom",
					text_color=self.theme_cls.primary_color,
					on_release=lambda x: _events_callback(
						self.text_button_cancel
					),
				)
				box.add_widget(button_cancel)

			box_buttons.add_widget(box)
			instance_content_dialog.ids.box_buttons.add_widget(box_buttons)
			instance_content_dialog.ids.box_buttons.height = button_ok.height
			instance_content_dialog.remove_widget(
				instance_content_dialog.ids.sep
			)
    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]
    def __init__(self, **kwargs):
        super().__init__()

        self.app = MDApp.get_running_app()

        self.mapview = MapView(lat=19.60389,
                          lon=-99.01260,
                          zoom=10
                          )

        self.marcadoresches = []
        self.marcadoressor = []
        self.marcadorescomer = []
        self.marcadoreshbe = []
        self.marcadoresbusqueda = []
        self.tipocomercio = ''

        self.datoshbe = {
            'hbe1': {'direccion': 'HDA. CERRO GORDO ',
                    'colonia': 'Balcones Campestre',
                    'lat': 21.156959409958873,
                    'lon': -101.70300001710274,
                    'tel': '8181531100',
                    'cp': '37150',
                    'municipio': 'Leon, Guanajuato'
                    },

            'hbe2': {'direccion': 'BLVD. ADOLFO LÓPEZ MATEOS 2102',
                     'colonia': 'Jardines del Moral',
                     'lat': 21.146246179033383,
                     'lon': -101.68449454293152,
                     'tel': '4777198103',
                     'cp': '37160',
                     'municipio': 'Leon, Guanajuato'
                     },

            'hbe3': {'direccion': 'BLVD. ADOLFO LOPEZ MATEOS 2102',
                     'colonia': 'Jardines del Moral',
                     'lat': 21.146236158514455,
                     'lon': -101.6846125617232,
                     'tel': '4777198103',
                     'cp': '37160',
                     'municipio': 'Leon, Guanajuato'
                     },

            'hbe4': {'direccion': 'AV. Guerrero 2415',
                     'colonia': 'Terracota',
                     'lat':  20.695401634729016,
                     'lon': -101.35843141409075,
                     'tel': '4621190160',
                     'cp': '36620',
                     'municipio': 'Irapuato, Guanajuato'
                     },
        }
        
        
        

        self.datosches = {
            'che1': {'direccion': '4TA. AVENIDA NO. 257 LOTE 1',
                     'colonia': 'Fracc Rey Neza',
                     'lat': 19.40068,
                     'lon': -98.98720,
                     'tel': '54412720',
                     'cp': '57000',
                     'municipio': 'Nezahualcoyotl'
                     },

            'che2': {'direccion': 'AV. TEXCOCO NO. 292',
                     'colonia': 'Pavón',
                     'lat': 19.396626,
                     'lon': -99.048428,
                     'tel': '11038000 ext 37140',
                     'cp': '57610',
                     'municipio': 'Nezahualcoyotl'
                     },

            'che3': {'direccion': 'AV. RIO DE LA LOZA NO. 4 ',
                     'colonia': 'San Miguel Chalma',
                     'lat': 19.545221,
                     'lon': -99.152201,
                     'tel': '11038000 ext 37130',
                     'cp': '07160',
                     'municipio': 'Tlalnepantla'
                     },

            'che4': {'direccion': 'AV. INSURGENTES SIN NUMERO',
                     'colonia': 'Calvario',
                     'lat': 19.60237,
                     'lon': -99.05572,
                     'tel': 'Sin tel',
                     'cp': '55020',
                     'municipio': 'Ecatepec de Morelos'
                     },

            'che5': {'direccion': 'AV ALFREDO DEL MAZO NO. 705',
                     'colonia': 'Tlacopa',
                     'lat': 19.309995,
                     'lon': -99.635682,
                     'tel': '017222379445',
                     'cp': '50100',
                     'municipio': 'Toluca de Lerdo'
                     },

            'che6': {'direccion': 'PROL. GUADALUPE VICTORIA NO. 471',
                     'colonia': 'La Purisima',
                     'lat': 19.258697,
                     'lon': -99.628197,
                     'tel': '017222127113',
                     'cp': '52140',
                     'municipio': 'Metepec'
                     },

            'che7': {'direccion': 'BLVRD JUAN HERRERA Y PIÑA 7',
                     'colonia': 'Barrio Otumba',
                     'lat': 19.204049,
                     'lon': -100.125421,
                     'tel': '7262626942',
                     'cp': '51200',
                     'municipio': 'Valle de Bravo'
                     },

            'che8': {'direccion': 'BLVD. MANUEL AVILA CAMACHO 5',
                     'colonia': 'Lomas de Sotelo',
                     'lat': 19.454290,
                     'lon': -99.219101,
                     'tel': '7262626942',
                     'cp': '53390',
                     'municipio': 'Naucalpan de Juárez'
                     },

            'che9': {'direccion': 'AV. DE LOS BOSQUES NO. 128',
                     'colonia': 'Lomas de Tecamachalco',
                     'lat': 19.411133,
                     'lon': -99.250840,
                     'tel': '5555967887',
                     'cp': '52780',
                     'municipio': 'Huixquilucan'
                     },
            'che10': {'direccion': 'AV. CENTRAL ESQ. AV JARDINES DE MORELOS S/N',
                      'colonia': 'Jardínes de Morelos',
                      'lat': 19.603457,
                      'lon': -99.013337,
                      'tel': '5558371634',
                      'cp': '55065',
                      'municipio': 'Ecatepec de Morelos'
                      },
            'che11': {'direccion': 'AV.AQUILES SERDAN 360',
                      'colonia': 'El Mirador',
                      'lat': 19.257597,
                      'lon': -99.022525,
                      'tel': '5525942726',
                      'cp': '16740',
                      'municipio': 'Xochimilco'
                      },

            'che12': {'direccion': 'CTRA. A SANTIAGO TEPELCATLALPAN 400',
                      'colonia': 'Santiago Tepalcatlalpan',
                      'lat': 19.257736,
                      'lon': -99.122394,
                      'tel': '5555557600',
                      'cp': '16210',
                      'municipio': 'Xochimilco'
                      },

            'che13': {'direccion': 'AV. UNIVERSIDAD 740',
                      'colonia': 'Sta Cruz Atoyac',
                      'lat': 19.373194,
                      'lon': -99.162387,
                      'tel': '8005632222',
                      'cp': '03310',
                      'municipio': 'Benito Juárez'
                      },

            'che14': {'direccion': 'VASCO DE QUIROGA 3800',
                      'colonia': 'Lomas de Santa Fe',
                      'lat': 19.359963,
                      'lon': -99.274583,
                      'tel': '5521678307',
                      'cp': '05348',
                      'municipio': 'Cuajimalpa'
                      },

            'che15': {'direccion': 'AV. BENITO JUAREZ NO. 39 MZ 36',
                      'colonia': 'Presidentes',
                      'lat': 19.376661,
                      'lon': -99.223099,
                      'tel': '5511038000',
                      'cp': '01290',
                      'municipio': 'Álvaro Obregón'
                      },

            'che16': {'direccion': 'AV. CANAL DE TEZONTLE 1512',
                      'colonia': 'Área Federal Central de Abastos',
                      'lat': 19.384808,
                      'lon': -99.082368,
                      'tel': '5511038000',
                      'cp': '09020',
                      'municipio': 'Iztapalapa'
                      },

            'che17': {'direccion': 'BUEN TONO NO. 8',
                      'colonia': 'Centro',
                      'lat': 19.428273,
                      'lon': -99.143175,
                      'tel': '5555124069',
                      'cp': '06070',
                      'municipio': 'Cuahtémoc'
                      },

            'che18': {'direccion': 'BLVD. MIGUEL DE CERVANTES SAAVEDRA 397',
                      'colonia': 'Irrigación',
                      'lat': 19.441866,
                      'lon': -99.206946,
                      'tel': '5555803422',
                      'cp': '11579',
                      'municipio': 'Miguel Hidalgo'
                      },

            'che19': {'direccion': 'AV. CUAUTEPEC NO. 117',
                      'colonia': 'Jorge Negrete',
                      'lat': 19.526125,
                      'lon': -99.141422,
                      'tel': '8009251111',
                      'cp': '07280',
                      'municipio': 'Gustavo A. Madero'
                      },

            'che20': {'direccion': 'AV. FORTUNA 334',
                      'colonia': 'Magdalena de las Salinas',
                      'lat': 19.482093,
                      'lon': -99.130347,
                      'tel': '8009251111',
                      'cp': '07760',
                      'municipio': 'Gustavo A. Madero'
                      },
        }

        self.datossor = {
            'sor1': {'direccion': 'CTRA. MEXICO-TEPEXPAN ESQ. LOS REYES TEXCOCO NO. 8',
                     'colonia': 'San Isidro Atlautenco',
                     'lat': 19.620721,
                     'lon': -98.997171,
                     'tel': '8007074262',
                     'cp': '55064',
                     'municipio': 'Ecatepec de Morelos'
                     },

            'sor2': {'direccion': 'LA PURISIMA NO. 5',
                     'colonia': 'San Cristóbal Lejipaya',
                     'lat': 19.602854,
                     'lon': -98.946640,
                     'tel': '5949569566',
                     'cp': '55800',
                     'municipio': 'Atenco'
                     },

            'sor3': {'direccion': 'AV. CENTRAL 65',
                     'colonia': '1ro de Agosto',
                     'lat': 19.551379,
                     'lon': -99.018549,
                     'tel': '8002201234',
                     'cp': '55100',
                     'municipio': 'Ecatepec de Morelos'
                     },

            'sor4': {'direccion': 'MEXICO NO. 5',
                     'colonia': 'Cd. López Mateos',
                     'lat': 19.568340,
                     'lon': -99.250645,
                     'tel': '5558225029',
                     'cp': '52960',
                     'municipio': 'Atizapán'
                     },

            'sor5': {'direccion': 'AV. 16 DE SEPTIEMBRE 34',
                     'colonia': 'Paraiso II',
                     'lat': 19.631577,
                     'lon': -99.119169,
                     'tel': '8007074262',
                     'cp': '55700',
                     'municipio': 'Coacalco'
                     },

            'sor6': {'direccion': 'AV. CUITLAHUAC 372',
                     'colonia': 'Cuitlahuac',
                     'lat': 19.471089,
                     'lon': -99.170700,
                     'tel': '8002201234',
                     'cp': '02530',
                     'municipio': 'Azcapotzalco'
                     },

            'sor7': {'direccion': 'AV. TOLTECAS S/N',
                     'colonia': 'Hab. Los Reyes',
                     'lat': 19.53765,
                     'lon': -99.189802,
                     'tel': '5516659002',
                     'cp': '54090',
                     'municipio': 'Tlalnepantla'
                     },

            'sor8': {'direccion': 'AV. GUSTAVO BAZ PRADA 250',
                     'colonia': 'Bosques de Echegaray',
                     'lat': 19.491437,
                     'lon': -99.227430,
                     'tel': '5553736844',
                     'cp': '53300',
                     'municipio': 'Naucalpan'
                     },

            'sor9': {'direccion': 'CALLE MEXIQUENSE 31',
                     'colonia': 'Los Héroes Tecámac',
                     'lat': 19.633013,
                     'lon': -99.033405,
                     'tel': '5558369960',
                     'cp': '55765',
                     'municipio': 'Tecámac'
                     },

            'sor10': {'direccion': 'CTRA. MEX-QRT KM 36.8',
                      'colonia': 'Reforma Política',
                      'lat': 19.650797,
                      'lon': -99.195386,
                      'tel': '8002201234',
                      'cp': '54700',
                      'municipio': 'Cuautitlán Izcalli'
                      },

            'sor11': {'direccion': 'AV. STA. FE 46',
                      'colonia': 'Lomas de Santa Fe',
                      'lat': 19.357175,
                      'lon': -99.273897,
                      'tel': 'Sin info',
                      'cp': '01219',
                      'municipio': 'Cuajimalpa'
                      },

            'sor12': {'direccion': 'AV. IMAN 550',
                      'colonia': 'Pedregal de Carrasco',
                      'lat': 19.306898,
                      'lon': -99.164659,
                      'tel': '5555288345',
                      'cp': '04700',
                      'municipio': 'Coyoacán'
                      },

            'sor13': {'direccion': 'ERMITA IZTAPALAPA 3016',
                      'colonia': 'Reforma Politica',
                      'lat': 19.344716,
                      'lon': -99.027594,
                      'tel': '8183299252',
                      'cp': '09730',
                      'municipio': 'Iztapalapa'
                      },

            'sor14': {'direccion': 'CALZ. DE LA VIGA 1805',
                      'colonia': 'Mexicaltzingo',
                      'lat': 19.360090,
                      'lon': -99.123618,
                      'tel': '8183299252',
                      'cp': '09080',
                      'municipio': 'Iztapalapa'
                      },

            'sor15': {'direccion': 'AV. REVOLUCION 780',
                      'colonia': 'San Juan',
                      'lat': 19.379381,
                      'lon': -99.185600,
                      'tel': '5555655046',
                      'cp': '03730',
                      'municipio': 'Benito Juárez'
                      },

            'sor16': {'direccion': 'OBRERO MUNDIAL 320',
                      'colonia': 'Piedad Narvarte',
                      'lat': 19.402383,
                      'lon': -99.154002,
                      'tel': '5583299000',
                      'cp': '03000',
                      'municipio': 'Benito Juárez'
                      },

            'sor17': {'direccion': 'AV. EL ROSARIO 901',
                      'colonia': 'El Rosario',
                      'lat': 19.504132,
                      'lon': -99.200933,
                      'tel': '8007074262',
                      'cp': '02100',
                      'municipio': 'Azcapotzalco'
                      },

            'sor18': {'direccion': 'CALZ. DE LOS MISTERIOS 62',
                      'colonia': 'Tepeyac Insurgentes',
                      'lat': 19.489655,
                      'lon': -99.119282,
                      'tel': '8002201234',
                      'cp': '07020',
                      'municipio': 'Gustavo A. Madero'
                      },

            'sor19': {'direccion': 'AV. EJERCITO NACIONAL 769',
                      'colonia': 'Granada',
                      'lat': 19.439809,
                      'lon': -99.199979,
                      'tel': '5591260960',
                      'cp': '11520',
                      'municipio': 'Miguel Hidalgo'
                      },

            'sor20': {'direccion': 'AV JARDIN 330',
                      'colonia': 'Col del Gas',
                      'lat': 19.468902,
                      'lon': -99.159565,
                      'tel': '8002201234',
                      'cp': '02970',
                      'municipio': 'Azcapotzalco'
                      },
        }

        self.datoscomer = {
            'comer1': {'direccion': 'CALZ DEL HUESO 530',
                       'colonia': 'Fracc. Los Girasoles',
                       'lat': 19.305154,
                       'lon': -99.126231,
                       'tel': '01 800 3777 333',
                       'cp': '4929',
                       'municipio': 'Coyoacan'
                       },

            'comer2': {'direccion': 'ATENAS 6',
                       'colonia': 'Fracc. Valle Dorado',
                       'lat': 19.551346,
                       'lon': -99.209801,
                       'tel': '01 800 3777 333',
                       'cp': '54020',
                       'municipio': 'Tlalnepantla'
                       },

            'comer3': {'direccion': 'BLVD MANUEL AVILA CAMACHO 3228',
                       'colonia': 'Boulevares',
                       'lat': 19.498145,
                       'lon': -99.237891,
                       'tel': '01 800 3777 333',
                       'cp': '53100',
                       'municipio': 'Naucalpan de Juárez'
                       },

            'comer4': {'direccion': 'PLAZUELA DE LA FAMA 1',
                       'colonia': 'La Fama',
                       'lat': 19.288794,
                       'lon': -99.179277,
                       'tel': '01 800 3777 333',
                       'cp': '14410',
                       'municipio': 'Tlalpan'
                       },

            'comer5': {'direccion': 'CIRCUITO MEDICOS 35',
                       'colonia': 'Ciudad Satélite',
                       'lat': 19.509474,
                       'lon': -99.232960,
                       'tel': '01 800 3777 333',
                       'cp': '53100',
                       'municipio': 'Naucalpan de Juárez'
                       },

            'comer6': {'direccion': 'NOGAL 212',
                       'colonia': 'Santa María La Ribera',
                       'lat': 19.451636,
                       'lon': -99.163952,
                       'tel': '01 800 3777 333',
                       'cp': '6400',
                       'municipio': 'Cuauhtémoc'
                       },

            'comer7': {'direccion': 'CTRA A CELAYA 2',
                       'colonia': 'Fracc. La Lejona 2da Sección',
                       'lat': 20.897708,
                       'lon': -100.752716,
                       'tel': '01 800 3777 333',
                       'cp': '37765',
                       'municipio': 'San Miguel Allende'
                       },

            'comer8': {'direccion': 'AV DE LAS TORRES 446',
                       'colonia': 'San José del Olivar',
                       'lat': 19.334798,
                       'lon': -99.227121,
                       'tel': '01 800 3777 333',
                       'cp': '1770',
                       'municipio': 'Álvaro Obregón'
                       },

            'comer9': {'direccion': 'AV MAGNOCENTRO LT 1 MZ 2',
                       'colonia': 'San Fernando Huixquilucan',
                       'lat': 19.399401,
                       'lon': -99.276681,
                       'tel': '01 800 3777 333',
                       'cp': '52796',
                       'municipio': 'Huixquilucan'
                       },

            'comer10': {'direccion': 'XOCHIMILCO 343',
                        'colonia': 'Anahuac',
                        'lat': 19.438072,
                        'lon': -99.179588,
                        'tel': '01 800 3777 333',
                        'cp': '11320',
                        'municipio': 'Miguel Hidalgo'
                        },

            'comer11': {'direccion': 'BOSQUES DE MOCTEZUMA 1B',
                        'colonia': 'Fracc. La Herradura',
                        'lat': 19.416958,
                        'lon': -99.249047,
                        'tel': '01 800 3777 333',
                        'cp': '53920',
                        'municipio': 'Huixquilucan'
                        },

            'comer12': {'direccion': 'CALZ ERMITA IZTAPALAPA 3865',
                        'colonia': 'Santa María Aztahuacán',
                        'lat': 19.351905,
                        'lon': -99.012747,
                        'tel': '01 800 3777 333',
                        'cp': '9730',
                        'municipio': 'Iztapalapa'
                        },

            'comer13': {'direccion': 'PERPETUA 35',
                        'colonia': 'San José Insurgentes',
                        'lat': 19.366372,
                        'lon': -99.182357,
                        'tel': '01 800 3777 333',
                        'cp': '3900',
                        'municipio': 'Benito Juárez'
                        },

            'comer14': {'direccion': 'MIGUEL ANGEL DE QUEVEDO 443',
                        'colonia': 'Romero de Terreros',
                        'lat': 19.345040,
                        'lon': -99.171795,
                        'tel': '01 800 3777 333',
                        'cp': '4310',
                        'municipio': 'Coyoacán'
                        },

            'comer15': {'direccion': 'BOSQUE DE ARRAYAN MZ 5 LT 1',
                        'colonia': 'Fracc. Conjunto Urbano Bosque Esmeralda',
                        'lat': 19.548925,
                        'lon': -99.287349,
                        'tel': '01 800 3777 333',
                        'cp': '52973',
                        'municipio': 'Atizapán de Zaragoza'
                        },

            'comer16': {'direccion': 'AV DE LAS FUENTES 190',
                        'colonia': 'Lomas de Tecamachalco',
                        'lat': 19.421845,
                        'lon': -99.237988,
                        'tel': '01 800 3777 333',
                        'cp': '53950',
                        'municipio': 'Naucalpán de Juárez'
                        },

            'comer17': {'direccion': 'PROLONGACION BOSQUES DE REFORMA 1813',
                        'colonia': 'Vista Hermosa',
                        'lat': 19.382919,
                        'lon': -99.267804,
                        'tel': '01 800 3777 333',
                        'cp': '5109',
                        'municipio': 'Cuajimalpa'
                        },

            'comer18': {'direccion': 'AV. JESUS DEL MONTE 271',
                        'colonia': 'Jesús del Monte',
                        'lat': 19.388758,
                        'lon': -99.293395,
                        'tel': '01 800 3777 333',
                        'cp': '52764',
                        'municipio': 'Huixquilucan'
                        },

            'comer19': {'direccion': 'AV. MIGUEL ANGEL DE QUEVEDO 1144',
                        'colonia': 'Parque San Andrés',
                        'lat': 19.342817,
                        'lon': -99.146703,
                        'tel': 'Sin Datos',
                        'cp': '4040',
                        'municipio': 'Coyoacan'
                        },

            'comer20': {'direccion': 'AV. DEL CARMEN 335',
                        'colonia': 'Fracc. Avandaro',
                        'lat': 19.164580,
                        'lon': -100.125154,
                        'tel': 'Sin Datos',
                        'cp': '51200',
                        'municipio': 'Valle de Bravo'
                        },
        }

        self.entradafield = MDTextFieldRect(pos_hint={"x": .05, "y":.93},
                                        hint_text = "Buscar por Municipio, Colonia, Calle",
                                        size_hint = (.6, .060),
                                        height = "30dp"
                                        )

        self.borramarcador = MDIconButton(pos_hint={"x": .80, "y":.9},
                                                   icon = "map-marker-off",
                                                   user_font_size = "32sp",
                                    )
        self.botonbusqueda = MDIconButton(pos_hint={"x": .65, "y": .9},
                                          icon="magnify",
                                          user_font_size="32sp",
                                          )


        self.botongps = MDIconButton(pos_hint={"x": .75, "y": .03},
                                     icon = "crosshairs-gps",
                                     user_font_size = "32sp"
                                     )

        self.botonayuda = MDIconButton(pos_hint={"x": .75, "y": .13}, #falta agregar funcion para mostrar
                                       icon="help-box",
                                       user_font_size="32sp"
                                       )

        self.botonche = MDFillRoundFlatButton(pos_hint={"x": .1, "y": .05},
                                              size_hint=(.25, .07),
                                              text = "Chedraui",
                                              )
        self.mr = Image(source="imagenes/pinrojo.png",
                        pos_hint={"x": -.385, "y": -.41})

        self.botonhbe = MDFillRoundFlatButton(pos_hint={"x": .5, "y": .05},
                                              size_hint=(.25, .07),
                                              text="HEB"
                                              )
        self.mg = Image(source="imagenes/pingris.png",
                        pos_hint={"x": .013, "y": -.41})

        self.botoncomer = MDFillRoundFlatButton(pos_hint={"x": .1, "y": .15},
                                              size_hint=(.25, .07),
                                              text="La Comer"
                                              )
        self.mv = Image(source="imagenes/pinverde.png",
                        pos_hint={"x": -.385, "y": -.31})

        self.botonsor = MDFillRoundFlatButton(pos_hint={"x": .5, "y": .15},
                                              size_hint=(.25, .07),
                                              text="Soriana"
                                              )
        self.ma = Image(source="imagenes/pinazul.png",
                        pos_hint={"x": .013, "y": -.31})

        self.botongps.bind(on_press=lambda x: self.ActivaGPS())
        self.botonayuda.bind(on_press=lambda x: self.AyudaMapa())
        self.botonche.bind(on_press=lambda x: self.Consulta_Che())
        self.botonsor.bind(on_press=lambda x: self.Consulta_Sor())
        self.botoncomer.bind(on_press=lambda x: self.Consulta_Comer())
        self.botonhbe.bind(on_press=lambda x: self.Consulta_HBE())
        self.borramarcador.bind(on_press=lambda x: self.BorraMarcador())
        self.botonbusqueda.bind(on_press=lambda x: self.Consulta_Busqueda())

        self.add_widget(self.mapview) # Se agrega el mapa en la "capa inferior"
        #self.add_widget(self.botongps) # En una "capa" posterior se agrega el boton para que se vea
        self.add_widget(self.botonbusqueda)
        self.add_widget(self.entradafield)

        self.add_widget(self.botonche)
        self.add_widget(self.botonhbe)
        self.add_widget(self.botoncomer)
        self.add_widget(self.botonsor)
        self.add_widget(self.botonayuda)
        self.add_widget(self.borramarcador)
        self.add_widget(self.mr)
        self.add_widget(self.mv)
        self.add_widget(self.mg)
        self.add_widget(self.ma)
Beispiel #10
0
    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)