当前位置: 首页>>代码示例>>Python>>正文


Python Builder.load_string方法代码示例

本文整理汇总了Python中kivy.lang.Builder.load_string方法的典型用法代码示例。如果您正苦于以下问题:Python Builder.load_string方法的具体用法?Python Builder.load_string怎么用?Python Builder.load_string使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kivy.lang.Builder的用法示例。


在下文中一共展示了Builder.load_string方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: build

# 需要导入模块: from kivy.lang import Builder [as 别名]
# 或者: from kivy.lang.Builder import load_string [as 别名]
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 
开发者ID:BillBillBillBill,项目名称:Tickeys-linux,代码行数:20,代码来源:textinput.py

示例2: build

# 需要导入模块: from kivy.lang import Builder [as 别名]
# 或者: from kivy.lang.Builder import load_string [as 别名]
def build(self):
        self.log('start of log')
        if KIVYLAUNCHER_PATHS:
            self.paths.extend(KIVYLAUNCHER_PATHS.split(","))
        else:
            from jnius import autoclass
            Environment = autoclass('android.os.Environment')
            sdcard_path = Environment.getExternalStorageDirectory().getAbsolutePath()
            self.paths = [
                sdcard_path + "/kivy",
            ]

        self.root = Builder.load_string(KV)
        self.refresh_entries()

        if platform == 'android':
            from android.permissions import request_permissions, Permission
            request_permissions([Permission.READ_EXTERNAL_STORAGE]) 
开发者ID:kivy,项目名称:kivy-launcher,代码行数:20,代码来源:app.py

示例3: __init__

# 需要导入模块: from kivy.lang import Builder [as 别名]
# 或者: from kivy.lang.Builder import load_string [as 别名]
def __init__(self, **kwargs):
        self._win = None
        if 'container' not in kwargs:
            c = self.container = Builder.load_string(_grid_kv)
        else:
            c = None
        kwargs.setdefault('do_scroll_x', False)
        if 'size_hint' not in kwargs:
            kwargs.setdefault('size_hint_x', None)
            kwargs.setdefault('size_hint_y', None)
        super(DropDown, self).__init__(**kwargs)
        if c is not None:
            super(DropDown, self).add_widget(c)
            self.on_container(self, c)
        Window.bind(on_key_down=self.on_key_down)
        self.bind(size=self._reposition) 
开发者ID:BillBillBillBill,项目名称:Tickeys-linux,代码行数:18,代码来源:dropdown.py

示例4: btn_new_on_press

# 需要导入模块: from kivy.lang import Builder [as 别名]
# 或者: from kivy.lang.Builder import load_string [as 别名]
def btn_new_on_press(self):# callback; Add a new Tab
		panel = self.ids.tab_panel
		#create a tab by KV string
		tab_str = '''
TabbedPanelItem:
	id: tab_%d
	text: 'Tab %d'
	BoxLayout:
		Button:
			id: btn_new
            text: 'New Tab'
        Button:
            id: btn_close
            text: 'Close tab'
		'''
		self.max_id += 1 #max tab id
		tab = Builder.load_string(tab_str %(self.max_id, self.max_id)) #create a widget by string
		tab.ids.btn_new.on_press = self.btn_new_on_press #set events
		tab.ids.btn_close.on_press = self.btn_close_on_press
		panel.add_widget(tab) # add the tab 
开发者ID:aron-bordin,项目名称:Kivy-Tutorials,代码行数:22,代码来源:main.py

示例5: __init__

# 需要导入模块: from kivy.lang import Builder [as 别名]
# 或者: from kivy.lang.Builder import load_string [as 别名]
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)
            ''')) 
开发者ID:kivy-garden,项目名称:garden.matplotlib,代码行数:37,代码来源:backend_kivy.py

示例6: build

# 需要导入模块: from kivy.lang import Builder [as 别名]
# 或者: from kivy.lang.Builder import load_string [as 别名]
def build(self):
        return Builder.load_string(TESTAPP_KV) 
开发者ID:kivy-garden,项目名称:garden.modernmenu,代码行数:4,代码来源:__init__.py

示例7: bottom_touch

# 需要导入模块: from kivy.lang import Builder [as 别名]
# 或者: from kivy.lang.Builder import load_string [as 别名]
def bottom_touch(self, widget, touch):
        size = widget.size
        touch_pos = touch.pos
        center = [size[0] / 2, size[1] / 2]
        #g_pos = self.space_editor.node_helper.pos[:]
        g_scale = self.space_editor.node_helper.pos[:]
        
        box = Builder.load_string(dedent(self.box_str.format(0, 0, 0, 0, "box" if self.layout3d.f_type == 0 else "sphere")))
        self.set_mesh(box, self.layout3d.look_at[3:6][:], g_scale)
        self.space_editor.node_helper.save_command(3, self.layout3d) 
开发者ID:kpiorno,项目名称:kivy3dgui,代码行数:12,代码来源:editor3d.py

示例8: restore

# 需要导入模块: from kivy.lang import Builder [as 别名]
# 或者: from kivy.lang.Builder import load_string [as 别名]
def restore(self, *args):
        
        node = Node(**self.c_dict)
        float = dedent("""
                FloatLayout:
                    Button:
                        size_hint: (1., 1.)
                        id: a_button""")
        selector = Builder.load_string(float)
        node.add_widget( selector )   
        for e in args[0][:-1]:
            if e.obj == self.obj:
                e.obj = node
        self.callback(node, node.translate, node.scale, selector.ids.a_button, [node.pitch, node.yaw, node.roll])        
        #self.layout.add_widget(node) 
开发者ID:kpiorno,项目名称:kivy3dgui,代码行数:17,代码来源:editor_manager.py

示例9: __init__

# 需要导入模块: from kivy.lang import Builder [as 别名]
# 或者: from kivy.lang.Builder import load_string [as 别名]
def __init__(self, layout, parent, editor_manager):
        self.layout = layout
        self.parent = parent
        self.node_helper = NodeHelper()
        self.node_helper.editor_manager = editor_manager
        axis = '''
            Node:
                translate: (0, 0, 0)
                scale: (0.05, 0.05, 0.05)
                min_light_intensity: 0.8
                alpha: 0.5
                always_on_top: True
                receive_shadows: False
                meshes: ("{0}",)
                Button:
                    id: c_button
                    text: "Hello"
                    background_normal: "{1}"
            '''
        
        meshes = ["./editor/meshes/x-rot-axis.obj", "./editor/meshes/y-rot-axis.obj", "./editor/meshes/z-rot-axis.obj",
                  "./editor/meshes/x-scale-axis.obj", "./editor/meshes/z-scale-axis.obj", "./editor/meshes/y-scale-axis.obj",
                  "./editor/meshes/x-axis.obj", "./editor/meshes/z-axis.obj", "./editor/meshes/y-axis.obj"]
                  
        colors = ["./editor/images/red.png", "./editor/images/green.png", "./editor/images/blue.png",
                  "./editor/images/green.png", "./editor/images/blue.png", "./editor/images/red.png",
                  "./editor/images/red.png", "./editor/images/green.png", "./editor/images/blue.png"]
                  
        for i, e in enumerate(meshes):
            node = Builder.load_string(dedent(axis.format(e, colors[i])))
            node.ids.c_button.bind(on_touch_down=parent.on_button_touch_down)
            node.ids.c_button.bind(on_touch_up=parent.on_button_touch_up)
            node.ids.c_button.bind(on_touch_move=parent.on_button_touch_move)
            node.ids.c_button.c_id = i
            layout.add_widget(node)
            self.node_helper.add_mesh(node) 
开发者ID:kpiorno,项目名称:kivy3dgui,代码行数:38,代码来源:space_editor.py

示例10: build

# 需要导入模块: from kivy.lang import Builder [as 别名]
# 或者: from kivy.lang.Builder import load_string [as 别名]
def build(self):
		main_widget = Builder.load_string(main_widget_kv)
		# self.theme_cls.theme_style = 'Dark'

		main_widget.ids.text_field.bind(
				on_text_validate=self.set_error_message,
				on_focus=self.set_error_message)
		return main_widget 
开发者ID:kivymd,项目名称:KivyMD,代码行数:10,代码来源:main.py

示例11: show_file_chooser

# 需要导入模块: from kivy.lang import Builder [as 别名]
# 或者: from kivy.lang.Builder import load_string [as 别名]
def show_file_chooser(self):
        # update data_file_dir here
        pop = Builder.load_string('''
Popup
    title: 'Select data flie dir'
    BoxLayout
        padding: dp(9)
        spacing: dp(20)
        orientation: 'vertical'
        FileChooserIconView
            id: fl
            filters: ['*.']
            path: '/mnt/sdcard/'
            # dirselect: True
            #filter_dirs: True
        BoxLayout
            spacing: dp(9)
            size_hint_y: None
            height: dp(36)
            ActiveButton
                text: 'Select'
                on_release:
                    app.screenregister.data_file_dir = fl.path
                    root.dismiss()
            ActiveButton
                text: 'Cancel'
                on_release: root.dismiss()
''')
        pop.ids.fl.path = self.data_file_dir
        pop.open() 
开发者ID:pythonindia,项目名称:PyCon-Mobile-App,代码行数:32,代码来源:screenregister.py

示例12: build

# 需要导入模块: from kivy.lang import Builder [as 别名]
# 或者: from kivy.lang.Builder import load_string [as 别名]
def build(self):
        self.root = Builder.load_string(KV)
        rv = self.root.ids.rv
        rv.key_viewclass = "viewclass"
        rv.key_size = "height"
        self.generate_new_data() 
开发者ID:kivy-garden,项目名称:garden.recycleview,代码行数:8,代码来源:main.py

示例13: build

# 需要导入模块: from kivy.lang import Builder [as 别名]
# 或者: from kivy.lang.Builder import load_string [as 别名]
def build(self):

            Builder.load_string(kvdemo)
            android_tabs = AndroidTabs()

            for n in range(1, 6):
                tab = MyTab(text='TAB %s' % n)
                android_tabs.add_widget(tab)

            return android_tabs 
开发者ID:autosportlabs,项目名称:RaceCapture_App,代码行数:12,代码来源:__init__.py

示例14: build

# 需要导入模块: from kivy.lang import Builder [as 别名]
# 或者: from kivy.lang.Builder import load_string [as 别名]
def build(self):
        main_widget = Builder.load_string(main_widget_kv)
        self.nav_drawer = Navigator()
        return main_widget 
开发者ID:kiok46,项目名称:Blogs-Posts-Tutorials,代码行数:6,代码来源:main.py

示例15: build

# 需要导入模块: from kivy.lang import Builder [as 别名]
# 或者: from kivy.lang.Builder import load_string [as 别名]
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'
     
        
""") 
开发者ID:kiok46,项目名称:Blogs-Posts-Tutorials,代码行数:43,代码来源:tabs.py


注:本文中的kivy.lang.Builder.load_string方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。