コード例 #1
0
 def newbutton(text):
     button = Button(
         height=44,
         size_hint=(0.7, None),
         text=text,
         halign='center',
         valign='middle',
     )
     button.bind(size=button.setter('text_size'))
     return button
コード例 #2
0
ファイル: main.py プロジェクト: aqulline/Yummy
    def front_shop_offline(self):
        filename = "helped/admin.json"
        try:
            file_size = os.path.getsize(filename)
            if file_size > 0:
                shop = self.root.ids.front_shop
                with open(filename) as file:
                    line = json.load(file)
                    print(line)
                    for y, x in line.items():
                        self.admin_product_name = x["product_name"]
                        self.customer_phone = x["admin_phone"]
                        self.admin_product_url = x["image_url"]
                        self.admin_product_price = x["product_price"]

                        front_shops = Front_shop(on_release=self.selling_front)
                        layout = FloatLayout()
                        layout.add_widget(Labels(text=self.admin_product_name,
                                                 pos_hint={"center_x": .5, "center_y": .2},
                                                 halign="center"))
                        layout.add_widget(Cool(source=self.admin_product_url))
                        front_shops.add_widget(layout)
                        front_shops.id = y
                        shop.add_widget(front_shops)
                        time.sleep(2)
                        self.spin_active = False
                        self.loading = ""
        except:
            button = MDTextButton(text="Retry", pos_hint={"center_x": .5, "center_y": .5},
                                  on_release=lambda x: self.refresh_front())
            button.id = "you"
            button.custom_color = 40 / 255, 123 / 255, 222 / 255, 1
            shop = self.root.ids.front_shop
            shop.add_widget(button)
            self.loading = ""
            self.spin_active = False
コード例 #3
0
    def __init__(self, **args):
        super().__init__(**args)
        self.app = App.get_running_app()
        try:
            with open(self.app.get_path('capture_scripts.json'), 'r') as f:
                self.scripts = json.load(f)
        except:
            # any problem loading => set up afresh
            self.scripts = {}
            for s in all_scripts:
                self.scripts[s] = {
                    'exposure': .1 if s in faf_scripts else 1,
                    'filter': ['dark' if s in {'bias', 'dark'} else 'L']
                }
            self.scripts['bias']['exposure'] = .001
            self.scripts['seq']['nsubs'] = 4
            self.scripts['seq']['filter'] = ['B', 'G', 'R', 'L']
            self.save()

        self.chooser = MDBoxLayout(orientation='vertical',
                                   size_hint=(None, None),
                                   size=(dp(100), dp(240)),
                                   pos_hint={
                                       'center_x': 10,
                                       'center_y': .5
                                   })

        self.app.gui.add_widget(self.chooser)

        self.script_buttons = {}
        for s in all_scripts:
            if s in faf_scripts:
                col = .75, .65, .65, 1
            elif s in light_scripts:
                col = .75, .75, .65, 1
            else:
                col = .65, .75, .65, 1
            but = self.script_buttons[s] = MDTextButton(
                text=s,
                text_color=col,
                theme_text_color='Custom',
                font_size='18sp',
                on_press=self.script_chosen)
            self.chooser.add_widget(but)

        # initialise via current script once dependencies have been built
        Clock.schedule_once(self.on_current_script, 0)
コード例 #4
0
    def Name_changed(self, val, *args):
        ''' Name is changed as soon as the text is altered to allow lookup
            while other properties are changed on defocus.
        '''

        # don't do any lookups if we are initialising
        if not self.check_ambiguity:
            return

        # lookup
        OTs = Component.get('ObservingList').lookup_OTs(val)

        # if unique match, fill in
        if len(OTs) == 1:
            self.exact_match(val + '/' + OTs[0])
            return

        # clear all but name field to signal ambiguity
        for p in set(self.props) - {'Name'}:
            setattr(self, p, '')

        if len(OTs) == 0:
            # no match so set name
            self.Name = val
            self.new_values['Name'] = val
            self.check_for_change()
            return

        self.choose_OT = MDStackLayout(pos_hint={
            'x': .1,
            'top': 1
        },
                                       spacing=[20, 20])
        self.app.gui.add_widget(self.choose_OT)
        for ot in OTs:
            self.choose_OT.add_widget(
                MDTextButton(text=ot,
                             on_press=partial(self.exact_match,
                                              val + '/' + ot)))
コード例 #5
0
ファイル: main.py プロジェクト: Sangwan5688/Kivy-Music-Player
 def get_playlist(self, title, listId):
     image = AsyncImage(source=playlist_images[listId],
                        size_hint=(1, 1),
                        pos_hint={'top': 0.9},
                        allow_stretch=True)
     card = MDCard(orientation='vertical',
                   border_radius=15,
                   radius=[0, 0, 15, 15],
                   pos_hint={
                       "center_x": 0.5,
                       "center_y": 0.5
                   },
                   size_hint=(None, None),
                   size=(self.win_size * 0.3, self.win_size * 0.3))
     card.add_widget(image)
     self.root.ids.trend_grid.add_widget(
         MDTextButton(text=title,
                      pos_hint={'center_x': 0.5},
                      on_press=lambda x: self.show_top(title, listId)))
     self.root.ids.trend_grid.add_widget(card)
     self.root.ids.trend_grid.add_widget(MDLabel(text=''))
     self.root.ids.trend_grid.add_widget(MDLabel(text=''))
     self.root.ids.trend_grid.add_widget(MDLabel(text=''))
     self.root.ids.trend_grid.add_widget(MDLabel(text=''))
コード例 #6
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
			)
コード例 #7
0
ファイル: analysis.py プロジェクト: tksundar/mark2market
    def add_widgets(self):
        tryout.init(updated=self.updated)
        floatLayout = FloatLayout(size_hint=(.9, .9))
        nav_btn = MDTextButton(text='NAV Plot',
                               pos_hint={
                                   'center_x': 0.55,
                                   'center_y': 0.7
                               })
        nav_btn.bind(on_press=self.go_nav_plot)
        floatLayout.add_widget(nav_btn)

        gl_btn = MDTextButton(text='Gain Loss Plot',
                              pos_hint={
                                  'center_x': 0.55,
                                  'center_y': 0.6
                              })
        gl_btn.bind(on_press=self.go_gl_plot)
        floatLayout.add_widget(gl_btn)

        sec_btn = MDTextButton(text='Sectoral Exposure Plot',
                               pos_hint={
                                   'center_x': 0.55,
                                   'center_y': 0.5
                               })
        sec_btn.bind(on_press=self.go_sec_plot)
        floatLayout.add_widget(sec_btn)

        trend_btn = MDTextButton(text='Stock Movement plot',
                                 pos_hint={
                                     'center_x': 0.55,
                                     'center_y': 0.4
                                 })
        trend_btn.bind(on_press=self.go_trend_plot)
        floatLayout.add_widget(trend_btn)
        self.add_widget(floatLayout)
        add_home_btn(self)