How to use the kivy.uix.button.Button function in Kivy

To help you get started, we’ve selected a few Kivy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kivy-garden / garden.particlesystem / demo / main.py View on Github external
def build(self):
        root = GridLayout(cols=2)
        paint = DemoParticle(size_hint_x=None, width=600)
        root.add_widget(paint)
        buttons = BoxLayout(orientation='vertical')
        root.add_widget(buttons)

        sun = Button(text='Sun')
        sun.bind(on_press=paint.show_sun)
        buttons.add_widget(sun)

        drugs = Button(text='Drugs')
        drugs.bind(on_press=paint.show_drugs)
        buttons.add_widget(drugs)

        jellyfish = Button(text='JellyFish')
        jellyfish.bind(on_press=paint.show_jellyfish)
        buttons.add_widget(jellyfish)

        fire = Button(text='Fire')
        fire.bind(on_press=paint.show_fire)
        buttons.add_widget(fire)

        return root
github AndreMiras / KivyMD / kivymd / settings / formats.py View on Github external
content=content, title=self.title, size_hint=(None, None),
            size=(popup_width, '400dp'))
        popup.height = len(self.options) * dp(55) + dp(150)

        # add all the options
        content.add_widget(Widget(size_hint_y=None, height=1))
        uid = str(self.uid)
        for option in self.options:
            state = 'down' if option == self.value else 'normal'
            btn = ToggleButton(text=option, state=state, group=uid)
            btn.bind(on_release=self._set_option)
            content.add_widget(btn)

        # finally, add a cancel button to return on the previous panel
        content.add_widget(SettingSpacer())
        btn = Button(text='Cancel', size_hint_y=None, height=dp(50))
        btn.bind(on_release=popup.dismiss)
        content.add_widget(btn)

        # and open the popup !
        popup.open()
github kivy / kivy / kivy / uix / accordion.py View on Github external
child.content_size = w, display_space
                child.width = w
                child.height = child_space
                y += child_space

if __name__ == '__main__':
    from kivy.base import runTouchApp
    from kivy.uix.button import Button
    from kivy.uix.boxlayout import BoxLayout
    from kivy.uix.label import Label

    acc = Accordion()
    for x in range(10):
        item = AccordionItem(title='Title %d' % x)
        if x == 0:
            item.add_widget(Button(text='Content %d' % x))
        elif x == 1:
            l = BoxLayout(orientation='vertical')
            l.add_widget(Button(text=str(x), size_hint_y=None, height=35))
            l.add_widget(Label(text='Content %d' % x))
            item.add_widget(l)
        else:
            item.add_widget(Label(text='This is a big content\n' * 20))
        acc.add_widget(item)

    def toggle_layout(*l):
        o = acc.orientation
        acc.orientation = 'vertical' if o == 'horizontal' else 'horizontal'
    btn = Button(text='Toggle layout')
    btn.bind(on_release=toggle_layout)

    def select_2nd_item(*l):
github overfl0 / Bulletproof-Arma-Launcher / src / view / modsearchbox.py View on Github external
from kivy.lang import Builder
from kivy.uix.button import Button
from utils.paths import is_dir_writable
from view.chainedpopup import ChainedPopup
from view.behaviors import BubbleBehavior, HoverBehavior, DefaultButtonBehavior, HighlightBehavior
from view.filechooser import FileChooser

default_title = ''


class HButton(HighlightBehavior, HoverBehavior, BubbleBehavior, Button):
    pass


class DefaultHoverButton(HighlightBehavior, HoverBehavior, BubbleBehavior, DefaultButtonBehavior, Button):
    pass


Builder.load_file('kv/modsearchbox.kv')


class ModSearchBox(ChainedPopup):
    def resize_box(self, container, la, size):
        container.height = sum(child.height for child in container.children)

    def is_directory_ok(self, path):
        return os.path.isdir(path)

    def _fbrowser_success(self, path):
        if not self.is_directory_ok(path):
            return 'Not a directory or unreadable:\n{}'.format(path)
github danhitchcock / nano_brewed / NanoBrewed.py View on Github external
self.clear_widgets(self.children)
        #self.size = (800, 480)
        global beer_list
        global flow_meter
        global flow_pin_was_on
        flow_pin_was_on = False
        flow_meter = -1
        self.add_widget(Image(source='images/button_background.png'))
        #splash = Image(source='images/splash.png', pos_hint={'x': 0, 'y': 0}, size_hint=(1, 1))
        #self.add_widget(splash)

        main_grid = GridLayout()
        main_grid.cols = 2

        tap_num = 1
        btn1 = Button(background_color=(51 / 255, 51 / 255, 51 / 255, 0),
                      background_normal='',
                      background_down='',
                      markup=True,
                      halign='center',
                      text="[size=50][font=fonts/BEER.TTF]" + beer_list[tap_num]['Name'] +'[/font][/size]\n' +
                            '[size=25]' + beer_list[tap_num]['Style'] + '\n' +
                           'ABV: %s%% | IBU: %s' % (beer_list[tap_num]['ABV'], beer_list[tap_num]['IBU']) +'[/size]',
                      font_name="fonts/Clicker - Regular.ttf",
                      color=(51 / 255, 51 / 255, 51 / 255),

                      )
        btn1.props = beer_list[tap_num]
        btn1.bind(on_release=self.BeerDescript)

        #splash = Image(source='images/splash.png', pos_hint={'x': 0, 'y': 0}, size_hint=(4, 4))
        #btn1.add_widget(splash)
github Fogapod / VKBot / uix / widgets.py View on Github external
def on_touch_up(self, touch):
        self.redraw_all()
        super(ButtonWithShadow, self).on_touch_up(touch)


class RoundedButtonWithShadow(ButtonWithShadow):
    def __init__(self, **kwargs):
        super(RoundedButtonWithShadow, self).__init__(**kwargs)
        self.drawing_shape = RoundedRectangle


class BlueButton(RoundedButtonWithShadow):
    pass


class FontelloButton(Button):
    pass


class ColoredScreen(Screen):
    pass


class LowerTextInput(TextInput):
    lower_mode = False

    def insert_text(self, s, from_undo=False):
        if self.lower_mode:
            s = s.lower()
        return super(LowerTextInput, self).insert_text(s, from_undo=from_undo)
github kivy-garden / garden.rotabox / Rotabox0.9(Legacy) / rotaboxer.py View on Github external
saved at the project's (or image's) location, as:
    '_RESCUED_ON_EXIT_.rbx'.

{0}{6}Help{7}{4}:
    {0}Click{4} {2}{6}[?]{7}{4} button {0}|{4} Press {0}F1{4} key.
     ___________________________________________________________________________
  {0}*{4} Rotabox is a kivy widget, that has rotatable, fully
    customizable 2D colliding bounds.
    To understand the concept of the Rotabox collision detection,
    you can refer to its module's documentation.
        '''.format('[color=#ffffff]', '[color=#cc9966]', '[color=#9999ff]',
                   '[color=#729972]', '[/color]', '[size=25]', '[size=20]',
                   '[/size]', __version__)
        content.add_widget(scrl_label)

        ok_btn = Button(background_color=(.3, .4, .3, 1), size_hint=(1, .1),
                        on_press=self.dismiss_popup)
        ok_btn.text = 'OK'
        content.add_widget(ok_btn)

        self.popup = Popup(title_align='center', content=content,
                           size_hint=(1, 1),
                           title_size='18sp')
        self.popup.title = 'Help'
        self.popup.open()
        with self.popup.content.canvas.before:
            Color(.3, .2, .1, .3)
            Rectangle(pos=self.popup.pos, size=self.popup.size)
github pnpranavrao / kivy-designer / ins_mod.py View on Github external
dtype = 'list'

        if isinstance(prop, NumericProperty) or dtype == 'numeric':
            content = TextInput(text=str(value) or '', multiline=False)
            content.bind(text=partial(
                self.save_property_numeric, widget, key, index))
        elif isinstance(prop, StringProperty) or dtype == 'string':
            content = TextInput(text=value or '', multiline=True)
            content.bind(text=partial(
                self.save_property_text, widget, key, index))
        elif isinstance(prop, ListProperty) or isinstance(prop,
                ReferenceListProperty) or dtype == 'list':
            content = GridLayout(cols=1, size_hint_y=None)
            content.bind(minimum_height=content.setter('height'))
            for i, item in enumerate(value):
                button = Button(text=repr(item), size_hint_y=None, height=44)
                if isinstance(item, Widget):
                    button.bind(on_release=partial(self.highlight_widget, item,
                        False))
                else:
                    button.bind(on_release=partial(self.show_property, widget,
                        item, key, i))
                content.add_widget(button)
        elif isinstance(prop, OptionProperty):
            content = GridLayout(cols=1, size_hint_y=None)
            content.bind(minimum_height=content.setter('height'))
            for option in prop.options:
                button = ToggleButton(text=option,
                    state='down' if option == value else 'normal',
                    group=repr(content.uid), size_hint_y=None,
                    height=44)
                button.bind(on_press=partial(
github jwinterm / lightWallet / lightWallet.py View on Github external
if not address:
            address = self.address_input_textinput.text
        if not mixin:
            mixin = self.mixin_input_textinput.text
        if not amount:
            amount = self.amount_input_textinput.text
        if not paymentid:
            paymentid = self.paymentid_input_textinput.text
        print(address, mixin, amount, paymentid)
        print(len(paymentid), hex_match(paymentid))
        """Initiate transfer of funds to new address"""
        address_error_content = Button(text="Address must be 95 characters long\nand start with a '4'.\nClick to start over.",
                                       halign="center")
        address_error_popup = Popup(title="Address error", content=address_error_content, size_hint=(0.75, 0.75))
        address_error_content.bind(on_press=address_error_popup.dismiss)
        mixin_error_content = Button(text="Mixin must be an integer between 0 and 99.\nClick to start over.",
                                     halign="center")
        mixin_error_popup = Popup(title="Mixin error", content=mixin_error_content, size_hint=(0.75, 0.75))
        mixin_error_content.bind(on_press=mixin_error_popup.dismiss)
        if self.unlocked_balance > 0.01:
            amount_error_content = Button(text="Amount must be a number between 0.01 and {0:.3f} XMR.\nClick to start over.".format(self.unlocked_balance),
                                          halign="center")
        else:
            amount_error_content = Button(text="Amount must be a number greater than 0.01 XMR.\nClick to start over.".format(self.unlocked_balance),
                                          halign="center")
        amount_error_popup = Popup(title="Amount error", content=amount_error_content, size_hint=(0.75, 0.75))
        amount_error_content.bind(on_press=amount_error_popup.dismiss)
        paymentid_error_content = Button(text="Payment ID must be 0 or 64 hex characters long.\nClick to start over.",
                                         halign="center")
        paymentid_error_popup = Popup(title="Payment ID error", content=paymentid_error_content, size_hint=(0.75, 0.75))
        paymentid_error_content.bind(on_press=paymentid_error_popup.dismiss)
        try: