Python kivy.uix.boxlayout.BoxLayout() Examples

The following are 30 code examples of kivy.uix.boxlayout.BoxLayout(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module kivy.uix.boxlayout , or try the search function .
Example #1
Source File: main.py    From launcher with GNU General Public License v2.0 9 votes vote down vote up
def __init__(self, *args, **kwargs):
		super(AddBlockButton, self).__init__(*args, **kwargs)
		self.bind(on_release=self.openPopup)
		box=BoxLayout(padding=10)
		self.Input=TextInput(text="New Block", multiline=False, font_size=18)
		self.Input.bind(on_text_validate=self.addBlock)
		b=Button(text="Add it")
		b.bind(on_release=self.addBlock)	
		box.add_widget(self.Input)
		box.add_widget(b)
		self.addPopup = Popup(title="Add A New Block",
					size_hint=(None,None),
					size=(400,115),
					separator_color=[.9,.4,.2,1],
					background_color=[0,0,0,.6],
					content=box
					) 
Example #2
Source File: main.py    From launcher with GNU General Public License v2.0 7 votes vote down vote up
def __init__(self, *args, **kwargs):
		super(AddBlockButton, self).__init__(*args, **kwargs)
		self.bind(on_release=self.openPopup)
		box=BoxLayout(padding=10)
		self.Input=TextInput(text="New Block", multiline=False, font_size=18)
		self.Input.bind(on_text_validate=self.addBlock)
		b=Button(text="Add it")
		b.bind(on_release=self.addBlock)	
		box.add_widget(self.Input)
		box.add_widget(b)
		self.addPopup = Popup(title="Add A New Block",
					size_hint=(None,None),
					size=(400,115),
					separator_color=[.9,.4,.2,1],
					background_color=[0,0,0,.6],
					content=box
					) 
Example #3
Source File: textinput.py    From Tickeys-linux with MIT License 7 votes vote down vote up
def build(self):

            Builder.load_string('''
<TextInput>
    on_text:
        self.suggestion_text = ''
        self.suggestion_text = 'ion_text'

''')
            root = BoxLayout(orientation='vertical')
            textinput = TextInput(multiline=True, use_bubble=True,
                                  use_handles=True)
            #textinput.text = __doc__
            root.add_widget(textinput)
            textinput2 = TextInput(multiline=False, text='monoline textinput',
                                   size_hint=(1, None), height=30)
            root.add_widget(textinput2)
            return root 
Example #4
Source File: main.py    From launcher with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, *args, **kwargs):
		super(TreeViewButton, self).__init__(*args, **kwargs)
		self.background_normal="images/button.png"
		self.background_down="images/button.png"
		self.background_color=[0,0,0,0]
		self.color=[.2,0.2,0.2,1]
		self.color_selected=[.9,.5,.3,.8]
		self.size_hint_y=None
		self.height=30
		self.bind(on_release=self.click)
		b = BoxLayout(orientation="vertical")
		l=Label(text="Keep or remove this item from the block.")
		b1=BoxLayout(padding=10)
		btn1=Button(text="Keep it",background_normal="images/button.png",background_color=[.3,.7,.3,1])
		btn1.bind(on_release=self.closePopup)
		btn2=Button(text="Remove it",background_normal="images/button.png",background_color=[.8,.2,.2,1])
		btn2.bind(on_release=self.removeItem)
		b1.add_widget(btn1)
		b1.add_widget(btn2)
		b.add_widget(l)
		b.add_widget(b1)
		self.popupWindow = Popup(title="Item: '{}'".format(self.text),
					size_hint=(None,None),
					size=(400,200),
					separator_color=[.9,.4,.2,1],
					background_color=[0,0,0,.6],
					content=b
					) 
Example #5
Source File: popups.py    From kivy-material-ui with MIT License 6 votes vote down vote up
def __init__( self, **kargs ) :

        super( AskTextPopup, self ).__init__( **kargs )
        self.input_field = flatui.FlatTextInput(
            focus     = True,
            hint      = self.text_hint,
            font_name = self.content_font_name,
            font_size = self.content_font_size,
            size_hint = [ .8, 1 ]
        )        
    
        b = BoxLayout()
        b.add_widget( Label( size_hint=[.1,1] ) )
        b.add_widget( self.input_field )
        b.add_widget( Label( size_hint=[.1,1] ) )

        self.content.add_widget( b, 1 )

        if not self.multiline :
            pass 
Example #6
Source File: canconfigview.py    From RaceCapture_App with GNU General Public License v3.0 6 votes vote down vote up
def _update_can_settings(self, cfg):
        self.can_config = cfg.canConfig
        capabilities = cfg.capabilities
        can_settings = self.ids.can_settings
        can_settings.clear_widgets()
        can_channel_count = capabilities.channels.can

        for i in range(0, can_channel_count):
            can_settings.add_widget(FieldLabel(text=str(i + 1), halign='center'))

            baud_rate = CANBaudRateSpinner()
            baud_rate.channel_id = i
            baud_rate.bind(text=self.on_can_baud)
            baud_rate.setFromValue(self.can_config.baudRate[i])
            can_settings.add_widget(baud_rate)

            if capabilities.has_can_term:
                termination = CANTerminationSwitch()
                termination.channel_id = i
                termination.active = self.can_config.termination_enabled[i]
                termination.bind(active=self.on_can_termination)
                can_settings.add_widget(termination)
            else:
                can_settings.add_widget(BoxLayout()) 
Example #7
Source File: core.py    From pypercard with MIT License 6 votes vote down vote up
def _draw_buttons(self):
        """
        Encompasses the drawing of buttons onto the card.
        """
        button_layout = BoxLayout(orientation="horizontal", size_hint=(1, 0.2))
        for button in self.buttons:
            b = Button(text=button["label"])
            b.bind(on_press=self._button_click(button["target"]))
            if "text_size" in button:
                b.font_size = button["text_size"]
            else:
                b.font_size = 24
            if "text_color" in button:
                b.color = palette(button["text_color"])
            else:
                b.color = palette("white")
            if "background_color" in button:
                b.background_color = palette(button["background_color"])
            else:
                b.background_color = palette("grey")
            self.button_widgets.append(b)
            button_layout.add_widget(b)
        self.layout.add_widget(button_layout) 
Example #8
Source File: main.py    From centinel with MIT License 6 votes vote down vote up
def build(self):
        btn1 = Button(text="Start Tests")
        btn1.bind(on_press=self.start_tests)

        btn2 = Button(text="Show Results")
        btn2.bind(on_press=self.btn_pressed)

        buttons = BoxLayout(orientation='horizontal')
        buttons.add_widget(btn1)
        buttons.add_widget(btn2)

        label = Label(text="Test Results")
        labels = BoxLayout(orientation='horizontal')
        labels.add_widget(label)

        layout = BoxLayout(orientation="vertical")
        layout.add_widget(buttons)
        layout.add_widget(labels)

        return layout 
Example #9
Source File: textinput.py    From Tickeys-linux with MIT License 6 votes vote down vote up
def build(self):

            Builder.load_string('''
<TextInput>
    on_text:
        self.suggestion_text = ''
        self.suggestion_text = 'ion_text'

''')
            root = BoxLayout(orientation='vertical')
            textinput = TextInput(multiline=True, use_bubble=True,
                                  use_handles=True)
            #textinput.text = __doc__
            root.add_widget(textinput)
            textinput2 = TextInput(multiline=False, text='monoline textinput',
                                   size_hint=(1, None), height=30)
            root.add_widget(textinput2)
            return root 
Example #10
Source File: settings.py    From Tickeys-linux with MIT License 5 votes vote down vote up
def _create_popup(self, instance):
        # create popup layout
        content = BoxLayout(orientation='vertical', spacing=5)
        popup_width = min(0.95 * Window.width, dp(500))
        self.popup = popup = Popup(
            title=self.title, content=content, size_hint=(None, 0.9),
            width=popup_width)

        # create the filechooser
        self.textinput = textinput = FileChooserListView(
            path=self.value, size_hint=(1, 1), dirselect=True)
        textinput.bind(on_path=self._validate)
        self.textinput = textinput

        # construct the content
        content.add_widget(textinput)
        content.add_widget(SettingSpacer())

        # 2 buttons are created for accept or cancel the current value
        btnlayout = BoxLayout(size_hint_y=None, height='50dp', spacing='5dp')
        btn = Button(text='Ok')
        btn.bind(on_release=self._validate)
        btnlayout.add_widget(btn)
        btn = Button(text='Cancel')
        btn.bind(on_release=self._dismiss)
        btnlayout.add_widget(btn)
        content.add_widget(btnlayout)

        # all done, open the popup !
        popup.open() 
Example #11
Source File: settings.py    From Tickeys-linux with MIT License 5 votes vote down vote up
def _create_popup(self, instance):
        # create popup layout
        content = BoxLayout(orientation='vertical', spacing='5dp')
        popup_width = min(0.95 * Window.width, dp(500))
        self.popup = popup = Popup(
            title=self.title, content=content, size_hint=(None, None),
            size=(popup_width, '250dp'))

        # create the textinput used for numeric input
        self.textinput = textinput = TextInput(
            text=self.value, font_size='24sp', multiline=False,
            size_hint_y=None, height='42sp')
        textinput.bind(on_text_validate=self._validate)
        self.textinput = textinput

        # construct the content, widget are used as a spacer
        content.add_widget(Widget())
        content.add_widget(textinput)
        content.add_widget(Widget())
        content.add_widget(SettingSpacer())

        # 2 buttons are created for accept or cancel the current value
        btnlayout = BoxLayout(size_hint_y=None, height='50dp', spacing='5dp')
        btn = Button(text='Ok')
        btn.bind(on_release=self._validate)
        btnlayout.add_widget(btn)
        btn = Button(text='Cancel')
        btn.bind(on_release=self._dismiss)
        btnlayout.add_widget(btn)
        content.add_widget(btnlayout)

        # all done, open the popup !
        popup.open() 
Example #12
Source File: settings.py    From Tickeys-linux with MIT License 5 votes vote down vote up
def _create_popup(self, instance):
        # create the popup
        content = BoxLayout(orientation='vertical', spacing='5dp')
        popup_width = min(0.95 * Window.width, dp(500))
        self.popup = popup = Popup(
            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() 
Example #13
Source File: form_parser.py    From deepdiy with MIT License 5 votes vote down vote up
def build(self):
		root=BoxLayout()
		window=ScrollView(scroll_type=["bars"],  bar_width=20)
		root.add_widget(window)

		form_parser=FormParser()
		window.add_widget(form_parser)
		form_parser.load_json('../model_zoo/mrcnn/config_form.json')

		from kivy.uix.button import Button
		root.add_widget(Button(text='reset',size_hint_x=None,width='100dp',on_release=form_parser.reset))
		root.add_widget(Button(text='export',size_hint_x=None,width='100dp',on_release=form_parser.export))

		return root 
Example #14
Source File: main.py    From deepdiy with MIT License 5 votes vote down vote up
def __init__(self,**kwargs):
        super(Sub, self).__init__(**kwargs)
        self.window2=BoxLayout()
        self.window2.add_widget(Button(id='btn_foo',text='foo'))
        self.window2.ids = {child.id:child for child in self.window2.children}
        self.window2.ids.btn_foo.bind(on_release=self.update) 
Example #15
Source File: main.py    From deepdiy with MIT License 5 votes vote down vote up
def __init__(self,**kwargs):
        super(MainWindow, self).__init__(**kwargs)
        self.window2=BoxLayout()
        self.window2.add_widget(Button(id='btn_foo',text='bar'))
        self.window2.ids = {child.id:child for child in self.window2.children}
        self.window2.ids.btn_foo.bind(on_release=self.update)

        # multiprocessing.Process(target=self.open_sub).start() 
Example #16
Source File: resource_tree.py    From deepdiy with MIT License 5 votes vote down vote up
def build(self):
        from kivy.uix.boxlayout import BoxLayout
        from kivy.uix.button import Button
        root=BoxLayout()
        window=ScrollView(scroll_type=["bars"],  bar_width=20)
        root.add_widget(window)
        window.add_widget(self.resource_tree)
        return root 
Example #17
Source File: main.py    From hexTap with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, **kwargs):
        super(HexTap, self).__init__(**kwargs)
        self.difficulty = 1
        self.first_run = True
        self.current_state = 'mainMenu'
        self.content = BoxLayout()
        self.main_menu = MainMenu()
        self.help_menu = HelpMenu()
        self.game_map = None
        self.content.add_widget(self.main_menu)
        self.music = SoundLoader.load('assets/audio/music.ogg')
        self.soundsOption = True
        self.musicOption = False
        self.hardcoreOption = False 
Example #18
Source File: dialogs.py    From CreatorKivyProject with MIT License 5 votes vote down vote up
def card(content, title=None, background_color=None, size=(0.7, 0.5)):
    """Вывод диалоговых окон с кастомным контентом."""

    if not background_color:
        background_color = [1.0, 1.0, 1.0, 1]

    card = MDCard(size_hint=(1, 1), padding=5)  # , background_color=background_color)

    if title:
        box = BoxLayout(orientation="vertical", padding=dp(8))
        box.add_widget(
            MDLabel(
                text=title,
                theme_text_color="Secondary",
                font_style="Title",
                size_hint_y=None,
                height=dp(36),
            )
        )
        box.add_widget(MDSeparator(height=dp(1)))
        box.add_widget(content)
        card.add_widget(box)
    else:
        card.add_widget(content)

    dialog = ModalView(size_hint=size, background_color=[0, 0, 0, 0.2])
    dialog.add_widget(card)
    # dialog.open()

    return dialog 
Example #19
Source File: tabs.py    From Blogs-Posts-Tutorials with MIT License 5 votes vote down vote up
def build(self):
            from kivy.core.window import Window
            Window.size = (540, 720)
            # self.theme_cls.theme_style = 'Dark'

            return Builder.load_string("""
#:import Toolbar kivymd.toolbar.Toolbar
BoxLayout:
    orientation:'vertical'
    Toolbar:
        id: toolbar
        title: 'Page title'
        background_color: app.theme_cls.primary_color
        left_action_items: [['menu', lambda x: '']]
        right_action_items: [['search', lambda x: ''],['more-vert',lambda x:'']]
    MDTabbedPanel:
        id: tab_mgr
        tab_display_mode:'icons'
        
        MDTab:
            name: 'music' 
            text: "Music" # Why are these not set!!!
            icon: "playlist-audio"
            MDLabel:
                font_style: 'Body1'
                theme_text_color: 'Primary'
                text: "Here is my music list :)"
                halign: 'center'
        MDTab:
            name: 'movies'
            text: 'Movies'
            icon: "movie"
             
            MDLabel:
                font_style: 'Body1'
                theme_text_color: 'Primary'
                text: "Show movies here :)"
                halign: 'center'
     
        
""") 
Example #20
Source File: bubble.py    From Tickeys-linux with MIT License 5 votes vote down vote up
def __init__(self, **kwargs):
        self._prev_arrow_pos = None
        self._arrow_layout = BoxLayout()
        self._bk_img = Image(
            source=self.background_image, allow_stretch=True,
            keep_ratio=False, color=self.background_color)
        self.background_texture = self._bk_img.texture
        self._arrow_img = Image(source=self.arrow_image,
                                allow_stretch=True,
                                color=self.background_color)
        self.content = content = BubbleContent(parent=self)
        super(Bubble, self).__init__(**kwargs)
        content.parent = None
        self.add_widget(content)
        self.on_arrow_pos() 
Example #21
Source File: backend_kivy.py    From garden.matplotlib with MIT License 5 votes vote down vote up
def __init__(self, canvas, **kwargs):
        self.actionbar = ActionBar(pos_hint={'top': 1.0})
        super(NavigationToolbar2Kivy, self).__init__(canvas)
        self.rubberband_color = (1.0, 0.0, 0.0, 1.0)
        self.lastrect = None
        self.save_dialog = Builder.load_string(textwrap.dedent('''\
            <SaveDialog>:
                text_input: text_input
                BoxLayout:
                    size: root.size
                    pos: root.pos
                    orientation: "vertical"
                    FileChooserListView:
                        id: filechooser
                        on_selection: text_input.text = self.selection and\
                        self.selection[0] or ''

                    TextInput:
                        id: text_input
                        size_hint_y: None
                        height: 30
                        multiline: False

                    BoxLayout:
                        size_hint_y: None
                        height: 30
                        Button:
                            text: "Cancel"
                            on_release: root.cancel()

                        Button:
                            text: "Save"
                            on_release: root.save(filechooser.path,\
                            text_input.text)
            ''')) 
Example #22
Source File: main.py    From launcher with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
		super(TreeViewButton, self).__init__(*args, **kwargs)
		self.background_normal="images/button.png"
		self.background_down="images/button.png"
		self.background_color=[0,0,0,0]
		self.color=[.2,0.2,0.2,1]
		self.color_selected=[.9,.5,.3,.8]
		self.size_hint_y=None
		self.height=30
		self.bind(on_release=self.click)
		b = BoxLayout(orientation="vertical")
		l=Label(text="Keep or remove this item from the block.")
		b1=BoxLayout(padding=10)
		btn1=Button(text="Keep it",background_normal="images/button.png",background_color=[.3,.7,.3,1])
		btn1.bind(on_release=self.closePopup)
		btn2=Button(text="Remove it",background_normal="images/button.png",background_color=[.8,.2,.2,1])
		btn2.bind(on_release=self.removeItem)
		b1.add_widget(btn1)
		b1.add_widget(btn2)
		b.add_widget(l)
		b.add_widget(b1)
		self.popupWindow = Popup(title="Item: '{}'".format(self.text),
					size_hint=(None,None),
					size=(400,200),
					separator_color=[.9,.4,.2,1],
					background_color=[0,0,0,.6],
					content=b
					) 
Example #23
Source File: screen.py    From RPi-InfoScreen-Kivy with GNU General Public License v3.0 5 votes vote down vote up
def checkscreen(self):
        """Updates the screen depending on the state of the league object."""
        # If there are league matches, clear the screen
        if self.leagueobject:
            self.leaguename = self.leagueobject.LeagueName
            if self.newbox:
                self.newbox.clear_widgets()
            else:
                self.newbox = BoxLayout(orientation="vertical",
                                        size_hint_y=0.8)
                self.leaguebox.add_widget(self.newbox)

            # Get the stack of league matches
            self.leaguestack = self.createStack()

            # And work out how to place it in the middle of the screen.
            if self.spacer:
                sph = ((self.parent.height * .8) - self.h) / 2.0
                self.newbox.add_widget(Widget(size_hint=(1, None), height=sph))

            self.newbox.add_widget(self.leaguestack)

            if self.spacer:
                self.newbox.add_widget(Widget(size_hint=(1, None), height=sph))

        # No league matches
        else:
            if self.newbox:
                self.leaguebox.remove_widget(self.newbox)
            self.leaguename = "No league matches found." 
Example #24
Source File: screen.py    From RPi-InfoScreen-Kivy with GNU General Public License v3.0 5 votes vote down vote up
def build_tides_list(self):
        if self.tides == None:
            return
        self.tides_list.clear_widgets()

        w = (len(self.tides['extremes']) - 1) * 150
        tl = BoxLayout(orientation="horizontal", size=(w, 60),
                    size_hint=(None, 1), spacing=5)
        sv = ScrollView(size_hint=(1, 1.1), bar_margin = -5, do_scroll_y = False)
        sv.add_widget(tl)
        for tide in self.tides['extremes']:
            if self.next_t["dt"] < tide["dt"]:
                uptide = Tide(summary = tide, language = self.language)
                tl.add_widget(uptide)
        self.tides_list.add_widget(sv) 
Example #25
Source File: datamodel.py    From modbus-simulator with Apache License 2.0 5 votes vote down vote up
def __init__(self, **kwargs):
        # print kwargs
        super(ErrorPopup, self).__init__()
        # super(ErrorPopup, self).__init__(**kwargs)
        content = BoxLayout(orientation="vertical")
        content.add_widget(Label(text=kwargs['text'], font_size=20))
        mybutton = Button(text="Dismiss", size_hint=(1,.20), font_size=20)
        content.add_widget(mybutton)
        self.content = content
        self.title = kwargs["title"]
        self.auto_dismiss = False
        self.size_hint = .7, .5
        self.font_size = 20
        mybutton.bind(on_release=self.exit_popup)
        self.open() 
Example #26
Source File: screensettings.py    From Snu-Photo-Manager with GNU Lesser General Public License v3.0 5 votes vote down vote up
def _create_popup(self, *_):
        app = App.get_running_app()
        if app.database_scanning:
            return
        content = BoxLayout(orientation='vertical')
        popup_width = min(0.95 * Window.width, dp(500))
        self.popup = popup = NormalPopup(title=self.title, content=content, size_hint=(None, 0.9), width=popup_width)
        if not self.value:
            content.add_widget(ShortLabel(height=app.button_scale * 3, text="You must set at least one database directory.\n\nThis is a folder where your photos are stored.\nNew photos will be imported to a database folder."))
            content.add_widget(BoxLayout())
        else:
            folders = filter(None, self.value.split(';'))
            folderdata = []
            for folder in folders:
                folderdata.append({'text': folder})
            self.folderlist = folderlist = FolderSettingsList(size_hint=(1, .8), id='folderlist')
            folderlist.data = folderdata
            content.add_widget(folderlist)
        buttons = BoxLayout(orientation='horizontal', size_hint=(1, None), height=app.button_scale)
        addbutton = NormalButton(text='+')
        addbutton.bind(on_release=self.add_path)
        removebutton = NormalButton(text='-')
        removebutton.bind(on_release=self.remove_path)
        okbutton = WideButton(text='OK')
        okbutton.bind(on_release=self._dismiss)
        buttons.add_widget(addbutton)
        buttons.add_widget(removebutton)
        buttons.add_widget(okbutton)
        content.add_widget(buttons)
        popup.open() 
Example #27
Source File: bubble.py    From Tickeys-linux with MIT License 5 votes vote down vote up
def __init__(self, **kwargs):
        self._prev_arrow_pos = None
        self._arrow_layout = BoxLayout()
        self._bk_img = Image(
            source=self.background_image, allow_stretch=True,
            keep_ratio=False, color=self.background_color)
        self.background_texture = self._bk_img.texture
        self._arrow_img = Image(source=self.arrow_image,
                                allow_stretch=True,
                                color=self.background_color)
        self.content = content = BubbleContent(parent=self)
        super(Bubble, self).__init__(**kwargs)
        content.parent = None
        self.add_widget(content)
        self.on_arrow_pos() 
Example #28
Source File: settings.py    From Tickeys-linux with MIT License 5 votes vote down vote up
def _create_popup(self, instance):
        # create popup layout
        content = BoxLayout(orientation='vertical', spacing='5dp')
        popup_width = min(0.95 * Window.width, dp(500))
        self.popup = popup = Popup(
            title=self.title, content=content, size_hint=(None, None),
            size=(popup_width, '250dp'))

        # create the textinput used for numeric input
        self.textinput = textinput = TextInput(
            text=self.value, font_size='24sp', multiline=False,
            size_hint_y=None, height='42sp')
        textinput.bind(on_text_validate=self._validate)
        self.textinput = textinput

        # construct the content, widget are used as a spacer
        content.add_widget(Widget())
        content.add_widget(textinput)
        content.add_widget(Widget())
        content.add_widget(SettingSpacer())

        # 2 buttons are created for accept or cancel the current value
        btnlayout = BoxLayout(size_hint_y=None, height='50dp', spacing='5dp')
        btn = Button(text='Ok')
        btn.bind(on_release=self._validate)
        btnlayout.add_widget(btn)
        btn = Button(text='Cancel')
        btn.bind(on_release=self._dismiss)
        btnlayout.add_widget(btn)
        content.add_widget(btnlayout)

        # all done, open the popup !
        popup.open() 
Example #29
Source File: settings.py    From Tickeys-linux with MIT License 5 votes vote down vote up
def _create_popup(self, instance):
        # create popup layout
        content = BoxLayout(orientation='vertical', spacing=5)
        popup_width = min(0.95 * Window.width, dp(500))
        self.popup = popup = Popup(
            title=self.title, content=content, size_hint=(None, 0.9),
            width=popup_width)

        # create the filechooser
        self.textinput = textinput = FileChooserListView(
            path=self.value, size_hint=(1, 1), dirselect=True)
        textinput.bind(on_path=self._validate)
        self.textinput = textinput

        # construct the content
        content.add_widget(textinput)
        content.add_widget(SettingSpacer())

        # 2 buttons are created for accept or cancel the current value
        btnlayout = BoxLayout(size_hint_y=None, height='50dp', spacing='5dp')
        btn = Button(text='Ok')
        btn.bind(on_release=self._validate)
        btnlayout.add_widget(btn)
        btn = Button(text='Cancel')
        btn.bind(on_release=self._dismiss)
        btnlayout.add_widget(btn)
        content.add_widget(btnlayout)

        # all done, open the popup !
        popup.open() 
Example #30
Source File: settings.py    From Tickeys-linux with MIT License 5 votes vote down vote up
def _create_popup(self, instance):
        # create the popup
        content = BoxLayout(orientation='vertical', spacing='5dp')
        popup_width = min(0.95 * Window.width, dp(500))
        self.popup = popup = Popup(
            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()