Python kivy.uix.button 模块,Button() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用kivy.uix.button.Button()

项目:kivy-tutorials    作者:inclement    | 项目源码 | 文件源码
def build(self):
        root_widget = BoxLayout(orientation='vertical')

        output_label = Label(size_hint_y=1)  

        button_symbols = ('1', '2', '3', '+',
                          '4', '5', '6', '-',
                          '7', '8', '9', '.',
                          '0', '*', '/', '=')

        button_grid = GridLayout(cols=4, size_hint_y=2) 
        for symbol in button_symbols:
            button_grid.add_widget(Button(text=symbol))

        clear_button = Button(text='clear', size_hint_y=None,
                              height=100)

        root_widget.add_widget(output_label)
        root_widget.add_widget(button_grid)
        root_widget.add_widget(clear_button)

        return root_widget
项目:HeaTDV4A    作者:HeaTTheatR    | 项目源码 | 文件源码
def __init__(self, **kvargs):
        super(FileChooser, self).__init__(**kvargs)

        box = BoxLayout(orientation="vertical", spacing=10)
        filechooser = FileChooserListView()
        filechooser.bind(selection=self.select_callback)
        box.add_widget(filechooser)

        if self.filter == "folder":
            box.add_widget(SettingSpacer())
            box.add_widget(Button(text=self.text_button_select,
                                  size_hint=(1, .1),
                                  on_press=self.select_callback))
            filechooser.filters = [self.is_dir]
        elif self.filter == "files":
            filechooser.filters = [self.is_file]

        self.body = Popup(title=self.title, content=box, size_hint=self.size,
                          auto_dismiss=self.auto_dismiss,
                          background=self.background_image)
        self.body.bind(on_dismiss=self.dismiss_callback)
        self.body.open()
项目:HeaTDV4A    作者:HeaTTheatR    | 项目源码 | 文件源码
def __init__(self, **kvargs):
        super(SelectColor, self).__init__(**kvargs)

        box = BoxLayout(orientation="vertical")
        select_color = ColorPicker(hex_color=self.default_color)
        button_select = Button(text=self.text_button_ok, size_hint=(1, .1))

        box.add_widget(select_color)
        box.add_widget(Widget(size_hint=(None, .02)))
        box.add_widget(SettingSpacer())
        box.add_widget(Widget(size_hint=(None, .02)))
        box.add_widget(button_select)

        self.body = Popup(title=self.title, content=box, size_hint=self.size,
                          background=self.background_image)
        self.body.bind(on_dismiss=self.dismiss_callback)

        button_select.bind(on_press=lambda color: self.select_callback(
            select_color.hex_color), on_release=lambda *args: self.body.dismiss())
        self.body.open()
项目:POS-System    作者:obernardovieira    | 项目源码 | 文件源码
def addToBuyList(self, obj):
        if(self.pos_system.getBuyList() == None):
            content = Label(text = 'You need to start a new list!')
            popup = Popup(
                        title           = 'No Buy List',
                        content         = content,
                        size_hint       = (None, None),
                        size            = (400, 100)
                    )

            # open the popup
            popup.open()
            return

        button = Button(text=obj.text, size_hint_y = None, height = 40)
        button.bind(on_press = self.removeFromBuyList)
        self.a_buylist.add_widget(button)
        self.pos_system.getBuyList().addItem(obj.item)
        self.updateTotalPrice()

    ###
项目:ninety_per_ten    作者:arruda    | 项目源码 | 文件源码
def _build_evaluation_box(self):
        evaluation_box = BoxLayout(orientation='horizontal')
        positive_button = Button(
            text="Positive",
            font_size=50,
            size_hint=(.5, .5),
            background_normal='',
            background_color=rgb_to_kivy(0, 102, 0, 1)
        )
        positive_button.bind(on_release=self.handle_positive_button)

        negative_button = Button(
            text="Negative",
            font_size=50,
            size_hint=(.5, .5),
            background_normal='',
            background_color=rgb_to_kivy(255, 0, 0, 1)
        )
        negative_button.bind(on_release=self.handle_negative_button)

        evaluation_box.add_widget(positive_button)
        evaluation_box.add_widget(negative_button)
        return evaluation_box
项目:ninety_per_ten    作者:arruda    | 项目源码 | 文件源码
def _reset_layout(self):
        reset_layout = RelativeLayout(
            size_hint=(None, None),
            size=(100, 100),
            pos_hint={'right': 1, 'top': 1},
        )
        history_button = Button(
            text="History",
            font_size=30,
            size_hint=(1, 1),
        )
        history_button.bind(on_release=self.handle_history_button)
        reset_layout.add_widget(history_button)
        return reset_layout
项目:ninety_per_ten    作者:arruda    | 项目源码 | 文件源码
def _build_detail_event_box(self, event):
        event_layout = BoxLayout(orientation='horizontal')
        label_color = rgb_to_kivy(0, 102, 0, 1) if event.evaluation else rgb_to_kivy(255, 0, 0, 1)
        # event_eval_text = 'Positive' if event.evaluation else 'Negative'
        # event_text = "{} [{}]".format(event.date.strftime("%d/%m/%y  %H:%M:%S"), event_eval_text)
        event_text = event.date.strftime("%d/%m/%y  %H:%M:%S")
        event_label = Label(text=event_text, font_size=70, color=label_color, size_hint=(1, 1))

        event_rm_button = Button(
            text="-",
            font_size=50,
            size_hint=(.15, 1),
            background_normal='',
            background_color=rgb_to_kivy(255, 0, 0, 1)
        )
        handle_rm_with_event = partial(self.handle_rm_event, event)
        event_rm_button.bind(on_release=handle_rm_with_event)

        event_layout.add_widget(event_label)
        event_layout.add_widget(event_rm_button)
        return event_layout
项目:cloud-clipboard    作者:krsoninikhil    | 项目源码 | 文件源码
def __init__(self, auth_token, **kwargs):
        super(CloudCBScreen, self).__init__(**kwargs)
        self.header = {'Authorization': "Basic %s" % auth_token}
        self.url = SERVER_URI + 'copy-paste/'
        self.old_text = Clipboard.paste()
        self.cloud_clip = TextInput(text="Fetching...")

        layout = BoxLayout(orientation='vertical')
        layout.add_widget(Label(text='Cloud Clipboard'))
        layout.add_widget(Label(text='Current text on clipboard:'))
        layout.add_widget(self.cloud_clip)
        layout.add_widget(Button(text='Refresh', on_press=self.download))
        layout.add_widget(Label(text='Earlier text on your clipboard:'))
        layout.add_widget(TextInput(text=self.old_text))
        layout.add_widget(Button(text='Update Cloud Clipboard with this text', on_press=self.upload))
        self.add_widget(layout)

        self.download()
项目:GAP    作者:Tileyon    | 项目源码 | 文件源码
def new_button(self):

        a_caption = 'Button' + '{:02d}'.format(self.count_objs)
        self.count_objs += 1
        mypage.unibutton((40, 80, 80, 40, a_caption))
        a_button = mypage.unibuttons [-1]

        a_button.color = a_button.background_color
        if mypage.kivy:
            a_button.bind(on_touch_move=self.touch_move)
            a_button.bind(on_touch_down=self.touch_down)
        else:
            a_button.touch_enabled = False
            a_button.color = a_button.background_color
            a_button.pos = (a_button.x, a_button.y)
        self.new_objs.append(a_button)
项目:GAP    作者:Tileyon    | 项目源码 | 文件源码
def new_button(self):

        a_caption = 'Button' + '{:02d}'.format(self.count_objs)
        self.count_objs += 1
        mypage.unibutton((40, 80, 80, 40, a_caption))
        a_button = mypage.unibuttons [-1]

        a_button.color = a_button.background_color
        if mypage.kivy:
            a_button.bind(on_touch_move=self.touch_move)
            a_button.bind(on_touch_down=self.touch_down)
        else:
            a_button.touch_enabled = False
            a_button.color = a_button.background_color
            a_button.pos = (a_button.x, a_button.y)
        self.new_objs.append(a_button)
项目:autopen    作者:autopen    | 项目源码 | 文件源码
def build(self):
        floater = FloatLayout()
        logo = Image(source='AutoPen.png', pos_hint={'center_x': 0.5, 'center_y': .6})
        spiderman = Label(
            text='[size=24][i]With Great Power comes Great Responsibility[/i][/size]',
            markup=True,
            pos_hint={'center_x': 0.5, 'center_y': .2})
        enter = Button(text='enter', size_hint=(0.2,0.1), pos_hint={'center_x': 0.5, 'center_y': .1})
        floater.add_widget(logo)
        floater.add_widget(spiderman)
        floater.add_widget(enter)
        return floater
项目:Mobile-TetriNET    作者:Smug28    | 项目源码 | 文件源码
def __init__(self, app, **kwargs):
        img = Image('crop/overlay_gradient_POT.png')
        img.texture.wrap = "repeat"
        self.texture = img.texture
        self.app = app
        super(Overlay, self).__init__(**kwargs)
        self.app.btnStart = Button(text='', size_hint=(.4,.07), pos_hint={"right":.57, "y":.02}, opacity=0, markup=True, background_color=(1,1,1, .3))
        self.app.insertStrings.append((self.app.btnStart, 'STR_START'))
        self.app.btnPause = Button(text='', size_hint=(.4,.07),pos_hint={"right":.99, "y":.02}, opacity=0, markup=True, background_color=(1,1,1, .3))
        self.app.insertStrings.append((self.app.btnPause, 'STR_PAUSE'))
        self.app.btnStart.bind(on_press=self.app.startgame)
        self.app.btnPause.bind(on_press=self.app.pausegame)
        self.add_widget(self.app.btnStart)
        self.add_widget(self.app.btnPause)
        self.add_widget(Arrow(size=(47,97), pos_hint={"center_y":0.98, "x":0}))
        self.add_widget(Players(size_hint_x=0.85, pos_hint=self.pos_hint, opacity=0))
        self.dposStorage = [0, ]
        self.trueSizeHint = 0
项目:Team-HK-Project    作者:GrahamMThomas    | 项目源码 | 文件源码
def ReAddButtons(self,instance = None):
        global UPLOADBUTTON
        global DOWNLOADBUTTON
        global clientSide
        global serverSide

        UPLOADBUTTON = Button(text='UPLOAD', size_hint_y=None, height=50, on_press = self.UploadFile)
        self.add_widget(UPLOADBUTTON)

        DOWNLOADBUTTON = Button(text='DOWNLOAD', on_press=self.DownloadFile, size_hint_y=None, height=50)
        self.add_widget(DOWNLOADBUTTON)

        clientSide = TextInput(hint_text = "New File Name (SERVER)", size_hint_y = None, height = 50)
        self.add_widget(clientSide)
        serverSide = TextInput(hint_text = "Create/Rename(SERVER)", size_hint_y = None, height = 50)
        self.add_widget(serverSide)
项目:mobileinsight-mobile    作者:mobile-insight    | 项目源码 | 文件源码
def onGoTo(self):
        if self.loaded == 'Yes':
            popup = BoxLayout(
                orientation='vertical',
                size=self.size,
                pos=self.pos)
            self.goto_popup = Popup(title='Go To' +
                                    '          (1~' +
                                    str(len(self.data_view)) +
                                    ')', content=popup, size_hint=(0.9, 0.25), auto_dismiss=False)
            self.goto_textinput = TextInput()
            cancel = Button(text='Cancel', on_release=self.dismiss_goto_popup)
            ok = Button(text='Ok', on_release=self.goto_ok)
            buttons = BoxLayout(size_hint_y=None, height=self.height / 20)
            buttons.add_widget(cancel)
            buttons.add_widget(ok)
            popup.add_widget(self.goto_textinput)
            popup.add_widget(buttons)
            self.goto_popup.open()
项目:Easy    作者:HeaTTheatR    | 项目源码 | 文件源码
def __init__(self, **kvargs):
        super(CDialog, self).__init__(**kvargs)

        box = BoxLayout(orientation='vertical')
        select_color = ColorPicker(hex_color=self.default_color)
        button_select = Button(
            text=self.text_button_ok, size_hint=(1, .1),
            background_normal=self.background_image_buttons[0],
            background_down=self.background_image_shadows[0]
        )

        box.add_widget(select_color)
        box.add_widget(Widget(size_hint=(None, .02)))
        box.add_widget(SettingSpacer())
        box.add_widget(Widget(size_hint=(None, .02)))
        box.add_widget(button_select)

        button_select.bind(
            on_press=lambda color: self.events_callback(select_color.hex_color),
            on_release=lambda *args: self.dismiss()
        )
        self.content = box
        self.open()
项目:displayminion    作者:cedarsuite    | 项目源码 | 文件源码
def __init__(self, client):
        # TODO handle connection errors properly
        self.client = client
        self.layout = GridLayout(cols = 2, pos_hint={'x': 0, 'y': 0}, size_hint=(1, 0.1))
        self.client.layout.add_widget(self.layout, index = 1000)

        self.client.bind('connected', self.connected)
        self.client.bind('loaded', self.loaded)
        self.client.bind('registered', self.registered)

        if self.client.config.get('connection', 'autoconnect') == 'yes':
            self.auto = True
            self.client.connect(self.client.config.get('connection', 'server'))
        else:
            self.auto = False

            self.server_input = TextInput(text = self.client.config.get('connection', 'server'))
            self.server_button = Button(text = 'Connect', size_hint = (0.25, 1))
            self.server_button.bind(on_press = self.do_connect)

            self.layout.add_widget(self.server_input)
            self.layout.add_widget(self.server_button)
项目:webupdate    作者:Bakterija    | 项目源码 | 文件源码
def update_dialog(self, cur_build, upd_build):
        popup = Popup(title='Update', content=ScrollView(), size_hint=(0.8,None), height=cm(5))
        grid = GridLayout(cols=1, spacing=0, size_hint_y=None)
        grid.bind(minimum_height= grid.setter('height'))
        con = StackLayout()
        grid.add_widget(con)
        popup.content.add_widget(grid)
        lbl1 = Label(text='Current build is %s' % (cur_build), size_hint_y=None, height=cm(1))
        lbl2 = Label(text='Build %s available' % (upd_build), size_hint_y=None, height=cm(1))
        btn1 = Button(text='Cancel', size_hint=(0.5, None), height=cm(1))
        btn2 = Button(text='Update', size_hint=(0.5, None), height=cm(1))
        btn1.bind(on_release=popup.dismiss)
        btn2.bind(on_release=lambda x: {self.update(), popup.dismiss()})
        for x in (lbl1, lbl2, btn1, btn2):
            con.add_widget(x)
        popup.open()
项目:webupdate    作者:Bakterija    | 项目源码 | 文件源码
def update_dialog(self, cur_build, upd_build):
        popup = Popup(title='Update', content=ScrollView(), size_hint=(0.8,None), height=cm(5))
        grid = GridLayout(cols=1, spacing=0, size_hint_y=None)
        grid.bind(minimum_height= grid.setter('height'))
        con = StackLayout()
        grid.add_widget(con)
        popup.content.add_widget(grid)
        lbl1 = Label(text='Current build is %s' % (cur_build), size_hint_y=None, height=cm(1))
        lbl2 = Label(text='Build %s available' % (upd_build), size_hint_y=None, height=cm(1))
        btn1 = Button(text='Cancel', size_hint=(0.5, None), height=cm(1))
        btn2 = Button(text='Update', size_hint=(0.5, None), height=cm(1))
        btn1.bind(on_release=popup.dismiss)
        btn2.bind(on_release=lambda x: {self.update(), popup.dismiss()})
        for x in (lbl1, lbl2, btn1, btn2):
            con.add_widget(x)
        popup.open()
项目:kivy_rpg    作者:spinningD20    | 项目源码 | 文件源码
def __init__(self, target, **kwargs):
        super(BattleMenuState, self).__init__(target, **kwargs)
        print('battle menu state here, how ya doin', self, target)
        overlay = App.get_running_app().overlay
        self.move_button = Button(text='Move', on_release=lambda dt: self.change(SelectMoveState))
        self.attack_button = Button(text='Attack', on_release=lambda dt: self.change(SelectAttackState))
        self.wait_button = Button(text='Wait', on_release=lambda dt: self.change(TurnEnd))
        menu = GridLayout(cols=1, size_hint=(None, None), row_force_default=True, row_default_height=40)
        menu.width = dp(100)
        menu.height = menu.minimum_height
        buttons = [self.move_button, self.attack_button, self.wait_button]
        for button in buttons:
            menu.add_widget(button)
        menu.y = dp((Window.height / 2) + (menu.height / 2))
        menu.x = dp(40)
        self.menu = menu
        overlay.add_widget(self.menu)
        self.target.game.set_focus_target(self.target)
项目:kdialog    作者:HeaTTheatR    | 项目源码 | 文件源码
def __init__(self, **kvargs):
        super(CDialog, self).__init__(**kvargs)

        box = BoxLayout(orientation='vertical')
        select_color = ColorPicker(hex_color=self.default_color)
        button_select = Button(
            text=self.text_button_ok, size_hint=(1, .1),
            background_normal=self.background_image_buttons[0],
            background_down=self.background_image_shadows[0],
            background_color=choice(self.background_color_buttons)
        )

        box.add_widget(select_color)
        box.add_widget(Widget(size_hint=(None, .02)))
        box.add_widget(SettingSpacer())
        box.add_widget(Widget(size_hint=(None, .02)))
        box.add_widget(button_select)

        button_select.bind(
            on_press=lambda color: self.events_callback(select_color.hex_color),
            on_release=lambda *args: self.dismiss()
        )
        self.content = box
        self.open()
项目:kivy_samples    作者:AtsushiSakai    | 项目源码 | 文件源码
def __init__(self, **kwargs):
        super(RootWidget, self).__init__(cols=2)

        self.btn1=Button(text="Btn1",size_hint = (0.5, 0.5))
        layout = AnchorLayout(anchor_x='center', anchor_y='center')
        layout.add_widget(self.btn1)
        self.add_widget(layout)

        self.btn2=Button(text="Btn2",size_hint = (0.5, 0.5))
        layout2 = AnchorLayout(anchor_x='center', anchor_y='center')
        layout2.add_widget(self.btn2)
        self.add_widget(layout2)

        self.btn3=Button(text="Btn3",size_hint = (0.5, 0.5))
        layout3 = AnchorLayout(anchor_x='center', anchor_y='center')
        layout3.add_widget(self.btn3)
        self.add_widget(layout3)

        self.btn4=Button(text="Btn4",size_hint = (0.5, 0.5))
        layout4 = AnchorLayout(anchor_x='center', anchor_y='center')
        layout4.add_widget(self.btn4)
        self.add_widget(layout4)
项目:Self-Driving-Car    作者:Ujjwal-9    | 项目源码 | 文件源码
def build(self): # building the app
        parent = Game()
        parent.serve_car()
        Clock.schedule_interval(parent.update, 1.0 / 60.0)
        self.painter = MyPaintWidget()
        clearbtn = Button(text='clear')
        savebtn = Button(text='save',pos=(parent.width,0))
        loadbtn = Button(text='load',pos=(2*parent.width,0))
        clearbtn.bind(on_release=self.clear_canvas)
        savebtn.bind(on_release=self.save)
        loadbtn.bind(on_release=self.load)
        parent.add_widget(self.painter)
        parent.add_widget(clearbtn)
        parent.add_widget(savebtn)
        parent.add_widget(loadbtn)
        return parent
项目:KivMob    作者:MichaelStott    | 项目源码 | 文件源码
def desktop_warning(self):
        layout = BoxLayout(orientation='vertical')
        layout.add_widget(Label(text='KivMob will not display ads on ' +\
                          'nonmobile platforms. You must build an ' +\
                          'Android project to demo ads. (iOS not yet ' +\
                          'supported)',
                          size_hint_y=1,
                          text_size=(250,  None),
                          halign='left',
                          valign='middle'))
        button_layout = BoxLayout()
        button1=Button(text="Open Build Steps", size_hint=(0.8, 0.2))
        button1.bind(on_release = lambda x :
                     webbrowser.open("https://www.google.com"))
        button_layout.add_widget(button1)
        button2=Button(text="Close", size_hint=(0.8, 0.2))
        button2.bind(on_release = lambda x : popup.dismiss())
        button_layout.add_widget(button2)
        layout.add_widget(button_layout)
        popup = Popup(title='KivMob Demo Alert',
                      content=layout,
                      size_hint=(0.9, 0.9))
        popup.open()
项目:KivMob    作者:MichaelStott    | 项目源码 | 文件源码
def interstitial_warning(self):
        layout = BoxLayout(orientation='vertical')
        layout.add_widget(Label(text="Ad has not loaded. " +\
                                    "Wait a few seconds and then " +\
                                    "try again.",
                                    size_hint_y=1,
                                    text_size=(250,  None),
                                    halign='left',
                                    valign='middle'))
        button_layout = BoxLayout()
        close=Button(text="Close", size_hint=(0.8, 0.2))
        close.bind(on_release = lambda x : popup.dismiss())
        button_layout.add_widget(close)
        layout.add_widget(button_layout)
        popup = Popup(title='KivMob Demo Alert',
                      content=layout,
                      size_hint=(0.9, 0.9))
        popup.open()
项目:HeaTDV4A    作者:HeaTTheatR    | 项目源码 | 文件源码
def build(self):
            return Button(text="Press Me!",
                          on_press=self.show_progress_download)
项目:HeaTDV4A    作者:HeaTTheatR    | 项目源码 | 文件源码
def build(self):
            return Button(text="Press me!", on_press=self.show)
项目:HeaTDV4A    作者:HeaTTheatR    | 项目源码 | 文件源码
def build(self):
            return Button(text="Press me!", on_release=self.show_manager)
项目:HeaTDV4A    作者:HeaTTheatR    | 项目源码 | 文件源码
def __init__(self, **kvargs):
            super(ProgressLoad, self).__init__(**kvargs)

            self.orientation = "vertical"
            self.padding = 20
            self.KProgress = kvargs.get("KProgress")

            self.label_one = Label(text="", size_hint=(1, .1), markup=True)
            self.label_two = Label(text="", size_hint=(1, .1), markup=True)
            self.progress_load = self.KProgress()
            self.button_cancel = \
                Button(text="Cancel", on_press=self.events_callback,
                       size_hint=(1, .2))

            self.label_one.bind(
                size=lambda *args: self._update_text_size(args))
            self.label_two.bind(
                size=lambda *args: self._update_text_size(args))

            self.add_widget(self.label_one)
            self.add_widget(self.label_two)
            self.add_widget(Widget(size_hint=(None, .02)))
            self.add_widget(SettingSpacer())
            self.add_widget(Widget(size_hint=(None, .02)))
            self.add_widget(self.progress_load)
            self.add_widget(Widget(size_hint=(None, .3)))
            self.add_widget(SettingSpacer())
            self.add_widget(Widget(size_hint=(None, .02)))
            self.add_widget(self.button_cancel)

            self.progress_load.min = 0
            self.progress_load.max = 100
            self.progress_load.bar_value = 0
            self.progress_load.spacing_widget = 2
            self.progress_load.height_widget = 1
            self.progress_load.color = "#ff7f32"
            self.progress_load.background_color = "#2fbfe0"
            self.progress_load.border_color = "#2fbfe0"
项目:HeaTDV4A    作者:HeaTTheatR    | 项目源码 | 文件源码
def build(self):
            return Button(text="Press Me!",
                          on_press=self.show_progress_download)
项目:HeaTDV4A    作者:HeaTTheatR    | 项目源码 | 文件源码
def build(self):
            button = Button(text="Press me!")
            button.bind(on_release=self.show_dialog)

            return button
项目:HeaTDV4A    作者:HeaTTheatR    | 项目源码 | 文件源码
def build(self):
            return Button(text="Press me!", on_release=self.show_palette)
项目:HeaTDV4A    作者:HeaTTheatR    | 项目源码 | 文件源码
def build(self):
            return Button(text="Press me!", on_release=self.show_setting)
项目:HeaTDV4A    作者:HeaTTheatR    | 项目源码 | 文件源码
def build(self):
            button = Button(text="Press me!")
            button.bind(on_release=self.show_dialog)

            return button
项目:Kivy_practice    作者:okajun35    | 项目源码 | 文件源码
def build(self):
        return Button(text='Hello World')
项目:Wall-EEG    作者:neurotechuoft    | 项目源码 | 文件源码
def __init__(self):
        super(WallEEGApp, self).__init__()
        self.user = User()
        self.graph = Graph(xlabel='X', ylabel='Y', x_ticks_minor=5,
                           x_ticks_major=25, y_ticks_major=0.001,
                           y_grid_label=True, x_grid_label=True, padding=5,
                           x_grid=True, y_grid=True, xmin=-0, xmax=100,
                           ymin=-0.1,
                           ymax=0.1)
        self.plot = MeshLinePlot(color=[1, 0, 0, 1])
        self.counter = 0

    # def build(self):
    #     return InSenseView()



    # def build(self):
    #     g = Gui()
    #     point_collection = PointsCollection(1000, 1000, 0, 100, 0, 100)
    #
    #     for i in range(100):
    #         x_coord = random.randint(
    #             point_collection.x_min, point_collection.x_max)
    #         y_coord = random.randint(
    #             point_collection.y_min, point_collection.y_max)
    #
    #         point_collection.add_point_vals(x_coord, y_coord)
    #
    #     for point in point_collection.points_list:
    #         g.grid.add_widget(point)
    #     # for i in range(24):
    #     #     g.grid.add_widget(Button(text='test'))
    #
    #     return g
项目:FunUtils    作者:HoussemCharf    | 项目源码 | 文件源码
def __init__(self,**kwargs):
        super(WordUI, self).__init__(**kwargs)
        self.cols=2
        #adding text label
        self.add_widget(Label(text="insert the words:"))
        #adding text Input
        self.letttersinput = TextInput(multiline=False)
        self.add_widget(self.letttersinput)
        #adding the action button
        self.add_widget(Button(text="Generate", on_press=self.game , pos=(50, 100)))
项目:POS-System    作者:obernardovieira    | 项目源码 | 文件源码
def __init__(self, **kwargs):
        super(LoginScreen, self).__init__(**kwargs)
        '''self.orientation = 'vertical'
        ###
        self.grid = GridLayout()
        self.grid.cols = 2
        self.grid.add_widget(Label(text='User Name'))
        self.grid.username = TextInput(multiline=False)
        self.grid.add_widget(self.grid.username)
        self.grid.add_widget(Label(text='password'))
        self.grid.password = TextInput(multiline=False)
        self.grid.add_widget(self.grid.password)
        ###
        self.options = BoxLayout()
        self.options.size_hint_y = 0.5
        self.options.bt_cancel = Button(text='Cancel')
        self.options.add_widget(self.options.bt_cancel)
        self.options.bt_login = Button(text='Login')
        self.options.bt_login.bind(on_press=self.bt_login_clicked)
        self.options.add_widget(self.options.bt_login)
        ###
        self.add_widget(self.grid)
        self.add_widget(self.options)'''

    ###
项目:POS-System    作者:obernardovieira    | 项目源码 | 文件源码
def loadMainWindow(self, obj = None):

        self.atual_menu = 0
        op_n = 1
        mainOptions = [APPERTIZERS_NAME, MEAT_NAME, FISH_NAME, VEGAN_NAME, DRINKS_NAME, DESSERT_NAME]

        self.a_articles.clear_widgets()

        for op in mainOptions:
            button = Button(text=op)
            button.bind(on_press=self.openNewMenu)
            op_n = op_n + 1
            self.a_articles.add_widget(button)

        for a in range(op_n-1, 9):
            self.a_articles.add_widget(Label(text=''))

        self.bt_next.enabled = False
        self.bt_previous.enabled = False

        if(self.pos_system.getBuyList() == None):
            self.bt_newlist.enabled = True
            self.bt_clearlist.enabled = False
            self.bt_finishlist.enabled = False

        self.menu_page = 0

    ###
项目:POS-System    作者:obernardovieira    | 项目源码 | 文件源码
def loadBarOptions(self):
        self.a_baroptions.add_widget(Button(text='Close Session', on_press=self.userLogout))
        self.bt_newlist = ButtonEx(text = 'New List', on_press=self.startNewBuyList)
        self.a_baroptions.add_widget(self.bt_newlist)
        self.bt_clearlist = ButtonEx(text = 'Clear List', on_press=self.clearBuyList)
        self.a_baroptions.add_widget(self.bt_clearlist)
        self.bt_finishlist = ButtonEx(text = 'Finish List', on_press=self.finishBuyList)
        self.a_baroptions.add_widget(self.bt_finishlist)
        self.bt_next = ButtonEx(text = 'Next', on_press = self.changePage)
        self.a_baroptions.add_widget(self.bt_next)
        self.bt_previous = ButtonEx(text = 'Previous', on_press = self.changePage)
        self.a_baroptions.add_widget(self.bt_previous)
        self.a_baroptions.add_widget(Button(text = 'Menu', on_press = self.loadMainWindow))
    ###
项目:POS-System    作者:obernardovieira    | 项目源码 | 文件源码
def openNewMenu(self, obj):
        op_n = 1
        total_rows = 0
        if obj != self.bt_next and obj != self.bt_previous:
            self.menu_type = obj.text.lower()

        cursor = self.database.loadArticles(self.menu_type, self.menu_page)

        self.a_articles.clear_widgets()

        for row in cursor:
            total_rows = total_rows + 1
            if(total_rows > 9) : break
            button = Button(text=row[1])
            button.bind(on_press=self.addToBuyList)
            button.item = Item(id_p = row[0], name = row[1], price = row[2], tax = 0.2)
            op_n = op_n + 1
            self.a_articles.add_widget(button)

        for a in range(op_n-1, 9):
            self.a_articles.add_widget(Label(text=''))

        if(total_rows > 9):
            self.bt_next.enabled = True
        else:
            self.bt_next.enabled = False

        if(self.menu_page > 0):
            self.bt_previous.enabled = True
        else:
            self.bt_previous.enabled = False

    ###
项目:ninety_per_ten    作者:arruda    | 项目源码 | 文件源码
def _filter_layout(self):
        filter_box = BoxLayout(orientation='vertical', spacing=50)

        dropdown = DropDown()
        for filter_type in FILTERS.keys():
            filter_button = Button(
                text=filter_type,
                font_size=30,
                background_normal='',
                background_color=rgb_to_kivy(239, 93, 5, 1),
                size_hint_y=None,
                height=130
            )
            handle_filter_button_with_dropdown = partial(self.handle_filter_button, dropdown)
            filter_button.bind(on_release=handle_filter_button_with_dropdown)
            dropdown.add_widget(filter_button)

        filter_dropdown_btn = Button(
            text=ALL_FILTER,
            font_size=30,
            size_hint=(1, 1),
            background_normal='',
            background_color=rgb_to_kivy(239, 93, 5, 1)
        )
        filter_dropdown_btn.bind(on_release=dropdown.open)

        dropdown.bind(on_select=lambda instance, x: setattr(filter_dropdown_btn, 'text', x))
        filter_box.add_widget(filter_dropdown_btn)
        return filter_box
项目:ninety_per_ten    作者:arruda    | 项目源码 | 文件源码
def _build_main_box(self):
        main_box = BoxLayout(orientation='vertical')
        back_button = Button(
            text="Back",
            font_size=30,
            size_hint=(0.15, 0.15),
        )
        back_button.bind(on_release=self.handle_back_button)
        main_box.add_widget(back_button)
        main_box.add_widget(self._build_event_list())
        return main_box
项目:Python201    作者:bambil    | 项目源码 | 文件源码
def build(self):
        return Button(text='Hello World')
项目:cloud-clipboard    作者:krsoninikhil    | 项目源码 | 文件源码
def __init__(self, **kwargs):
        super(LoginScreen, self).__init__(**kwargs)
        self.username_w = TextInput(multiline=False)
        self.password_w = TextInput(password=True, multiline=False)
        self.login_btn = Button(text='Login')
        self.login_btn.bind(on_press=self.login)

        layout = GridLayout()
        layout.cols = 2
        layout.add_widget(Label(text='Username'))
        layout.add_widget(self.username_w)
        layout.add_widget(Label(text='Password'))
        layout.add_widget(self.password_w)
        layout.add_widget(self.login_btn)
        self.add_widget(layout)
项目:GAP    作者:Tileyon    | 项目源码 | 文件源码
def unibutton(self, params):
        self.unibuttons.append([])
        if len(params) == 6:
            function = params[5]
        else:
            function = nofunction
        if self.kivy:
            from kivy.uix.button import Button
            self.unibuttons[len(self.unibuttons) - 1] = Button(
            text = params[4],
            size_hint_y = None,
            size_hint_x = None,
            height = params[3] * self.yratio,
            width = params[2] * self.xratio,
            font_size = 17.5 * self.yratio,
            pos = (params[0] * self.xratio, params[1] * self.yratio),
            on_press = function )
            self.root.add_widget(self.unibuttons[len(self.unibuttons) - 1])
        else:
            import ui
            self.unibuttons[len(self.unibuttons) - 1] = ui.Button(frame= \
                (params[0] * self.xratio, (600 - params[1] - \
                params[3]) * self.yratio, \
                params[2] * self.xratio, params[3] * self.yratio), \
                title = params[4])
            self.unibuttons[len(self.unibuttons) - 1].background_color \
                = (0.4,0.4,0.4)
            self.unibuttons[len(self.unibuttons) - 1].action = function
            self.unibuttons[len(self.unibuttons) - 1].height = params[3] * \
                self.xratio
            self.unibuttons[len(self.unibuttons) - 1].width = params[2] * \
                self.yratio
            self.unibuttons[len(self.unibuttons) - 1].tint_color = 'white'
            self.root.add_subview(self.unibuttons[len(self.unibuttons) - 1])
项目:GAP    作者:Tileyon    | 项目源码 | 文件源码
def unibutton(self, params):
        self.unibuttons.append([])
        if len(params) == 6:
            function = params[5]
        else:
            function = nofunction
        if self.kivy:
            from kivy.uix.button import Button
            self.unibuttons[len(self.unibuttons) - 1] = Button(
            text = params[4],
            size_hint_y = None,
            size_hint_x = None,
            height = params[3] * self.yratio,
            width = params[2] * self.xratio,
            font_size = 17.5 * self.yratio,
            pos = (params[0] * self.xratio, params[1] * self.yratio),
            on_press = function )
            self.root.add_widget(self.unibuttons[len(self.unibuttons) - 1])
        else:
            import ui
            self.unibuttons[len(self.unibuttons) - 1] = ui.Button(frame= \
                (params[0] * self.xratio, (600 - params[1] - \
                params[3]) * self.yratio, \
                params[2] * self.xratio, params[3] * self.yratio), \
                title = params[4])
            self.unibuttons[len(self.unibuttons) - 1].background_color \
                = (0.4,0.4,0.4)
            self.unibuttons[len(self.unibuttons) - 1].action = function
            self.unibuttons[len(self.unibuttons) - 1].height = params[3] * \
                self.xratio
            self.unibuttons[len(self.unibuttons) - 1].width = params[2] * \
                self.yratio
            self.unibuttons[len(self.unibuttons) - 1].tint_color = 'white'
            self.unibuttons[len(self.unibuttons) - 1].font = ('<system>', \
                17.5 * self.yratio)
            self.root.add_subview(self.unibuttons[len(self.unibuttons) - 1])
项目:GAP    作者:Tileyon    | 项目源码 | 文件源码
def unibutton(self, params):
        self.unibuttons.append([])
        if len(params) == 6:
            function = params[5]
        else:
            function = nofunction
        if self.kivy:
            from kivy.uix.button import Button
            self.unibuttons[len(self.unibuttons) - 1] = Button(
            text = params[4],
            size_hint_y = None,
            size_hint_x = None,
            height = params[3] * self.yratio,
            width = params[2] * self.xratio,
            font_size = 17.5 * self.yratio,
            pos = (params[0] * self.xratio, params[1] * self.yratio),
            on_press = function )
            self.root.add_widget(self.unibuttons[len(self.unibuttons) - 1])
        else:
            import ui
            self.unibuttons[len(self.unibuttons) - 1] = ui.Button(frame= \
                (params[0] * self.xratio, (600 - params[1] - \
                params[3]) * self.yratio, \
                params[2] * self.xratio, params[3] * self.yratio), \
                title = params[4])
            self.unibuttons[len(self.unibuttons) - 1].background_color \
                = (0.4,0.4,0.4)
            self.unibuttons[len(self.unibuttons) - 1].action = function
            self.unibuttons[len(self.unibuttons) - 1].height = params[3] * \
                self.xratio
            self.unibuttons[len(self.unibuttons) - 1].width = params[2] * \
                self.yratio
            self.unibuttons[len(self.unibuttons) - 1].tint_color = 'white'
            self.unibuttons[len(self.unibuttons) - 1].font = ('<system>', \
                17.5 * self.yratio)
            self.root.add_subview(self.unibuttons[len(self.unibuttons) - 1])
项目:AssembleAudio    作者:The-White-Wolf    | 项目源码 | 文件源码
def create_grid(self, x_hint_list, rows_to_create):
        #x_hint_list is a list of ints, relating to the intended
        #width of each column in the grid.

        for row in range(rows_to_create):
            for x_hint in x_hint_list:
                grid_button = Button(text = '', valign = 'middle', shorten = True, size_hint_y = None,
                    height = 30,  size_hint_x = x_hint, background_color = cfg_primary_neutral,
                    background_normal = '', color = cfg_primary_dark)

                grid_button.bind(size=grid_button.setter('text_size'))
                grid_button.bind(on_touch_down=self.button_press)
                self.add_widget(grid_button)
        self._avail += rows_to_create
项目:krpc-library    作者:krpc    | 项目源码 | 文件源码
def __init__(self, **kwargs):
        super(DisplayManeuver, self).__init__(**kwargs)

        self.maneuvers = {"apoapsis" : "120000",
                          "periapsis": "100000"}


        self.dropdown = DropDown()
        self.input = FloatInput(size=(200, 30),
                                multiline=False,
                                size_hint=(None, None))

        for m in self.maneuvers.keys():
            btn = Button(text=m, size_hint_y=None, height=30)

            # Pass the text of the button as the data of the selection.
            btn.bind(on_release=lambda btn: self.dropdown.select(btn.text))
            self.dropdown.add_widget(btn)

        self.mainbutton = Button(text='Maneuver',
                                 size=(160, 50),
                                 size_hint=(None, None))

        self.mainbutton.bind(on_release=self.dropdown.open)

        def dropdown_action(instance, m):
            self.input.text = self.maneuvers[m]
            self.mainbutton.text = m

        self.dropdown.bind(on_select=dropdown_action)

        self.go_button = Button(text='Go',
                                size=(160, 50),
                                size_hint=(None, None))
        self.go_button.bind(on_press=self.go)

        self.add_widget(self.mainbutton)
        self.add_widget(self.input)
        self.add_widget(self.go_button)
项目:autopen    作者:autopen    | 项目源码 | 文件源码
def build(self):
        mainpage = FloatLayout()
        logo = Image(source='AutoPen.png', pos_hint={'center_x': 0.5, 'center_y': .6})
        spiderman = Label(
            text='[size=24][i]With Great Power comes Great Responsibility[/i][/size]',
            markup=True,
            pos_hint={'center_x': 0.5, 'center_y': .2})
        enter = Button(text='enter', size_hint=(0.2,0.1), pos_hint={'center_x': 0.5, 'center_y': .1})
        mainpage.add_widget(logo)
        mainpage.add_widget(spiderman)
        mainpage.add_widget(enter)
        return mainpage
#layout.add_widget(MainToolsScreen())