python类BoxLayout()的实例源码

main.py 文件源码 项目:autopen 作者: autopen 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
def build(self):
        #with open("tips.txt", "r") as stream:
        #    labeltext = stream.read()
        label = Label(text="[size=50]hi[/size]", markup=True)
        box = BoxLayout()
        marvell = Marvel()
        box.add_widget(marvell)
        box.add_widget(label)
        return box
screens.py 文件源码 项目:Mobile-TetriNET 作者: Smug28 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def __init__(self, **kwargs):   # inicializace
        super(StatsScreen, self).__init__(**kwargs)
        self.root.insertStrings.append((self, "STR_STATS"))
        self.stats = BoxLayout(orientation='vertical', size_hint=(.77, .83), pos_hint={'center_x': .5, 'center_y': .49})
        self.title = BoxLayout(orientation='horizontal')
        self.title.add_widget(Label(font_name='font/Roboto-Bold.ttf', text=''))
        self.title.add_widget(Label(font_name='font/Roboto-Bold.ttf', text=''))
        self.title.add_widget(Label(font_name='font/Roboto-Bold.ttf', text=''))
        self.stats.add_widget(self.title)
        self.add_widget(self.stats)
        self.root.insertStrings.append((self.title.children[2], "STR_TYPE"))
        self.root.insertStrings.append((self.title.children[1], "STR_NAME"))
        self.root.insertStrings.append((self.title.children[0], "STR_SCORE"))
screens.py 文件源码 项目:Mobile-TetriNET 作者: Smug28 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def on_pre_enter(self, *args):
        # P?ed vstupem na obrazovku na?te seznam oblíbených server?
        if len(self.layout.children) == 0:
            bookmarks = self.root.Cfg[-1]
            if len(bookmarks) == 0:
                self.layout.add_widget(Label(text=self.STR_NO_BOOKMARKS, font_name='font/Roboto-Regular.ttf', font_size='18dp', size_hint_y = None, text_size=(self.width*3, None)))
            else:
                head = BoxLayout(size_hint=(1,None), height=50)
                head.add_widget(Label(text=self.STR_SERVER, font_name='font/Roboto-Bold.ttf', size_hint=(None,1), font_size="20dp", width = self.width*1.9, text_size=(self.width*1.9, None)))
                head.add_widget(Label(text=self.STR_MOD, font_name='font/Roboto-Bold.ttf', size_hint=(1,1), font_size="15dp", width = self.width, text_size=(self.width, None)))
                head.add_widget(DelButton(opacity=0, size_hint=(None, 1)))
                self.layout.add_widget(head)
                for y, server in enumerate(bookmarks):
                    srvr = Bookmark(size_hint=(1,None), height = 50)
                    for i, cell in enumerate(server):
                        if i == 0:
                            lbl = Label(text="[ref={0}]{1}[/ref]".format(y,cell), markup=True, font_name='font/Roboto-Regular.ttf', size_hint=(None,1), font_size="20dp", text_size=(None, None))
                            lbl.bind(on_ref_press=self.connectBookmark)
                            srvr.add_widget(lbl)
                        elif i == 1:
                            pass
                        elif i == 2:
                            lbl = Label(text="[ref={0}]{1}[/ref]".format(y,cell), markup=True, font_name='font/Roboto-Regular.ttf', size_hint=(1,1), font_size="20dp")
                            lbl.bind(on_ref_press=self.connectBookmark)
                            srvr.add_widget(lbl)
                    btn = DelButton(OBJ=srvr, ID=y, background_normal="crop/delete.png", background_down="crop/delete.png",size_hint=(None, 1))
                    btn.bind(on_press=self.removeBookmark)
                    srvr.add_widget(btn)
                    self.layout.add_widget(srvr)
main.py 文件源码 项目:Mobile-TetriNET 作者: Smug28 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def _key_handler(self, instance, KEY, *args):   # Reakce na stisk systémové klávesy OS Android
        print "Key: {0}".format(KEY)
        if KEY == 1001:
            if self.sm.current not in ('MainMenuScreen', 'GameScreen'):
                if self.sm.current == "SettingsScreen":
                    self.sm.get_screen("SettingsScreen").dropdown.dismiss()
                self.sm.current_screen.prev()
            else:
                if self.sm.current == 'MainMenuScreen':
                    text = self.L.STR_POPUP_EXIT
                    title = self.L.STR_POPUP_EXIT_TITLE
                    yes_callback = self.popupStop
                else:
                    text = self.L.STR_POPUP_DISCONNECT
                    title = self.L.STR_POPUP_DISCONNECT_TITLE
                    yes_callback = self.popupDisconnect
                content = BoxLayout(orientation='vertical')
                content.add_widget(Label(text=text, font_name='font/Roboto-Regular.ttf', font_size='14dp'))
                buttons = GridLayout(cols=2, rows=1, spacing=10, size_hint=(1, .3))
                yes = Button(text=self.L.STR_YES)
                yes.bind(on_press=yes_callback)
                no = Button(text=self.L.STR_NO)
                buttons.add_widget(yes)
                buttons.add_widget(no)
                content.add_widget(buttons)
                self.popupExit = Popup(title=title, size_hint=(.7,.3), content=content, auto_dismiss=False)
                no.bind(on_press=self.popupExit.dismiss)
                self.popupExit.open()
        elif KEY == 1002:
            self.dispatch('on_pause')
        elif KEY == 1004:
            self.dispatch('on_pause')
03_01_building_gui.py 文件源码 项目:kivy-tutorials 作者: inclement 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def build(self):
        layout = BoxLayout(orientation='vertical')
        b1 = Button(text='button 1')
        b2 = Button(text='button 2')

        layout.add_widget(b1)
        layout.add_widget(b2)

        return layout
main.py 文件源码 项目:KivyMdDemo 作者: captainbupt 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self, **kwargs):
        super(MyScreen, self).__init__(**kwargs)
        scrollView = ScrollView()
        self.add_widget(scrollView)

        boxLayout = BoxLayout(orientation='vertical', height=dp(1000), padding=dp(48))
        scrollView.add_widget(boxLayout)
        textField = SingleLineTextField(id='text_filed', size_hint=(0.8, None), height=dp(48))
        textField.hint_text='This is a pretty text filed'
        boxLayout.add_widget(textField)
        buttonContainer = BoxLayout(orientation='horizontal', height=dp(48))
        flatButton = MDFlatButton(text='FlatButton')
        # size is not working somehow
        # flatButton.size = (3*dp(48), dp(48))
        buttonContainer.add_widget(flatButton)
        raiseButton = MDRaisedButton(text='RaiseButton')
        # raiseButton.size = (3*dp(48), dp(48))
        buttonContainer.add_widget(raiseButton)
        boxLayout.add_widget(buttonContainer)

        switchContainer = BoxLayout(orientation='horizontal')
        checkbox1 = MDCheckbox(group='test')
        # checkbox1.size=(dp(48), dp(48))
        switchContainer.add_widget(checkbox1)
        checkbox2 = MDCheckbox(group='test')
        # checkbox2.size=(dp(48), dp(48))
        switchContainer.add_widget(checkbox2)
        boxLayout.add_widget(switchContainer)
tabs.py 文件源码 项目:Blogs-Posts-Tutorials 作者: kiok46 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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'


""")
main.py 文件源码 项目:iotdm-pyclient 作者: peterchauyw 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def open_message_popup(self):
        if self.response is not None:
            content = BoxLayout(orientation='vertical', spacing=5)
            content.add_widget(PopupButton(text='Add bookmark',on_release=self.add_bookmark))
            if self.response.opt.content_format is coap.media_types_rev['application/link-format']:
                content.add_widget(PopupButton(text='Process link format',on_release=self.process_link_format))
            self.controller.popup.content = content
            self.controller.popup.open()
main.py 文件源码 项目:iotdm-pyclient 作者: peterchauyw 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def open_node_label_popup(self, link_node, value):
        if value=='node' and self.level == 1:
            content = BoxLayout(orientation='vertical', spacing=5)
            content.add_widget(PopupButton(text='Repeat discovery',on_release=self.open_link))
            content.add_widget(PopupButton(text='Remove discovery result',on_release=self.remove_node))
            self.controller.popup.content = content
            self.controller.popup.open()
        elif value=='uri':
            content = BoxLayout(orientation='vertical', spacing=5)
            content.add_widget(PopupButton(text='Open bookmark',on_release=self.open_link))
            content.add_widget(PopupButton(text='Remove bookmark',on_release=self.remove_bookmark))
            self.controller.popup.content = content
            self.controller.popup.open()
logviewer.py 文件源码 项目:mobileinsight-mobile 作者: mobile-insight 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
def onSearch(self):
        popup = BoxLayout(orientation='vertical', size=self.size, pos=self.pos)
        self.search_popup = Popup(
            title='Search', content=popup, size_hint=(
                0.9, 0.25), auto_dismiss=False)
        self.search_textinput = TextInput()
        cancel = Button(text='Cancel', on_release=self.dismiss_search_popup)
        ok = Button(text='Ok', on_release=self.search_ok)
        buttons = BoxLayout(size_hint_y=None, height=self.height / 20)
        buttons.add_widget(cancel)
        buttons.add_widget(ok)
        popup.add_widget(self.search_textinput)
        popup.add_widget(buttons)
        self.search_popup.open()
__init__.py 文件源码 项目:garden.touchgraph 作者: kivy-garden 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def build(self):
            box = BoxLayout()
            graph = DemoGraph(points=[0, .2, 1, 0.25, 2, .4, 5, .5, 10, .6, 30, .5],
                              font_size=30,
                              line_width=5,
                              x_labels=['A', 'B', 'C', 'D'],
                              x_ticks=[0, 10, 20, 30],
                              y_ticks=[.1, .2, .5, .9],
                              max_y=1)
            box.add_widget(graph)
            return box
show_banners.py 文件源码 项目:Easy 作者: HeaTTheatR 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def show_banners(self, interval):
        if self.screen.ids.screen_manager.current == '':
            name_banner = self.choice(self.banner_list)

            box_banner = BoxLayout()
            new_banner = ImageButton(
                id=name_banner.split('.')[0],
                source='Data/Images/banners/{}'.format(name_banner),
                on_release=self.press_banner
            )
            box_banner.add_widget(new_banner)

            name_screen = name_banner
            banner = self.Screen(name=name_screen)
            banner.add_widget(box_banner)
            self.screen.ids.banner_manager.add_widget(banner)
            effect = self.choice(self.effects_transition)
            direction = self.choice(self.directions)
            if effect != self.SwapTransition:
                self.screen.ids.banner_manager.transition = effect(
                    direction=direction
                )
            else:
                self.screen.ids.banner_manager.transition = effect()
            self.screen.ids.banner_manager.current = name_screen
            self.screen.ids.banner_manager.screens.pop()
pdialog.py 文件源码 项目:Easy 作者: HeaTTheatR 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def __init__(self, **kvargs):
        super(PDialog, self).__init__(**kvargs)

        self.box = BoxLayout(orientation='vertical')
        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 = Progress()
        self.button_cancel = Button(
            text='Cancel', on_press=self.events_callback, size_hint=(1, .1),
            background_normal=self.background_image_buttons[0],
            background_down=self.background_image_shadows[0]
        )

        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.box.add_widget(self.label_one)
        self.box.add_widget(self.label_two)
        self.box.add_widget(Widget(size_hint=(None, .02)))
        self.box.add_widget(SettingSpacer())
        self.box.add_widget(Widget(size_hint=(None, .02)))
        self.box.add_widget(self.progress_load)
        self.box.add_widget(Widget(size_hint=(None, .3)))
        self.box.add_widget(SettingSpacer())
        self.box.add_widget(Widget(size_hint=(None, .02)))
        self.box.add_widget(self.button_cancel)

        self.progress_load.min = 0
        self.progress_load.max = 100
        self.progress_load.bar_value = 0
        self.progress_load.height_widget = self.dp(self.progress_line_height)
        self.progress_load.color = self.progress_line_color
        self.progress_load.border_color = self.progress_border_color
notification.py 文件源码 项目:garden.xpopup 作者: kivy-garden 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def _get_body(self):
        layout = BoxLayout(orientation='vertical')
        layout.add_widget(super(XProgress, self)._get_body())
        layout.add_widget(self._progress)
        return layout
file.py 文件源码 项目:garden.xpopup 作者: kivy-garden 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def _get_body(self):
        from kivy.lang import Builder
        import textwrap
        self.browser = Builder.load_string(textwrap.dedent('''\
        FileChooser:
            FileChooserIconLayout
            FileChooserListLayout
        '''))

        self.browser.path = self.path
        self.browser.multiselect = self.multiselect
        self.browser.dirselect = self.dirselect
        self.browser.filters = self.filters
        self.browser.bind(path=self.setter('path'),
                          selection=self.setter('selection'))
        self.bind(view_mode=self.browser.setter('view_mode'),
                  multiselect=self.browser.setter('multiselect'),
                  dirselect=self.browser.setter('dirselect'),
                  filters=self.browser.setter('filters'))

        lbl_path = Factory.XLabel(
            text=self.browser.path, valign='top', halign='left',
            size_hint_y=None, height=metrics.dp(25))
        self.browser.bind(path=lbl_path.setter('text'))

        layout = BoxLayout(orientation='vertical')
        layout.add_widget(self._ctrls_init())
        layout.add_widget(lbl_path)
        layout.add_widget(self.browser)
        return layout
file.py 文件源码 项目:garden.xpopup 作者: kivy-garden 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def _ctrls_init(self):
        pnl_controls = BoxLayout(size_hint_y=None, height=metrics.dp(25))
        pnl_controls.add_widget(Factory.XButton(
            text=_('Icons'), id=self.CTRL_VIEW_ICON,
            on_release=self._ctrls_click))
        pnl_controls.add_widget(Factory.XButton(
            text=_('List'), id=self.CTRL_VIEW_LIST,
            on_release=self._ctrls_click))
        pnl_controls.add_widget(Factory.XButton(
            text=_('New folder'), id=self.CTRL_NEW_FOLDER,
            on_release=self._ctrls_click))
        return pnl_controls
form.py 文件源码 项目:garden.xpopup 作者: kivy-garden 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def _get_form(self):
        layout = BoxLayout(orientation='vertical', spacing=5)
        text_input = TextInput(id='text', multiline=False, text=self.text,
                               on_text_validate=self._on_text_validate,
                               # DON`T UNCOMMENT OR FOUND AND FIX THE ISSUE
                               # if `focus` set to `True` - TextInput will be
                               # inactive to edit
                               # focus=True,
                               size_hint_y=None, height=metrics.dp(33))
        layout.add_widget(Widget())
        layout.add_widget(text_input)
        layout.add_widget(Widget())
        return layout
form.py 文件源码 项目:garden.xpopup 作者: kivy-garden 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def _get_form(self):
        layout = BoxLayout(orientation='vertical', spacing=5)
        layout.add_widget(Widget())

        pnl = BoxLayout(size_hint_y=None, height=metrics.dp(28), spacing=5)
        pnl.add_widget(
            Factory.XLabel(text=_('Login:'), halign='right',
                           size_hint_x=None, width=metrics.dp(80)))
        pnl.add_widget(TextInput(id='login', multiline=False,
                                 font_size=metrics.sp(14), text=self.login))
        layout.add_widget(pnl)

        pnl = BoxLayout(size_hint_y=None, height=metrics.dp(28), spacing=5)
        pnl.add_widget(
            Factory.XLabel(text=_('Password:'), halign='right',
                           size_hint_x=None, width=metrics.dp(80)))
        pnl.add_widget(TextInput(id='password', multiline=False, font_size=14,
                                 password=True, text=self.password))
        layout.add_widget(pnl)

        if self.autologin is not None:
            pnl = BoxLayout(size_hint_y=None, height=metrics.dp(28), spacing=5)
            pnl.add_widget(CheckBox(
                id='autologin', size_hint_x=None, width=metrics.dp(80),
                active=self.autologin))
            pnl.add_widget(
                Factory.XLabel(text=_('Login automatically'), halign='left'))
            layout.add_widget(pnl)

        layout.add_widget(Widget())
        return layout
example.py 文件源码 项目:SuperOcto 作者: mcecchi 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def build(self):
        f = FloatLayout()
        s = Scatter()
        l = Label(text='Hello!', font_size=150)
        b = BoxLayout(orientation='vertical')
        t = TextInput(font_size=150)

        f.add_widget(s)
        s.add_widget(l)

        b.add_widget(f)
        b.add_widget(t)

        return b
wizard.py 文件源码 项目:SuperOcto 作者: mcecchi 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def _generate_layout(self, l_text, btn_text, f):
        """
        Layouts are similar in fashion: Text and Call to Action button
        creates layout with text and button and  binds f to button
        """
        layout = BoxLayout(orientation='vertical')
        btn = Button(text=btn_text, font_size=30)
        l = Label(text=l_text, font_size=30)
        btn.bind(on_press=f)
        layout.add_widget(l)
        layout.add_widget(btn)
        return layout


问题


面经


文章

微信
公众号

扫码关注公众号