Python kivy.lang.Builder 模块,load_file() 实例源码

我们从Python开源项目中,提取了以下13个代码示例,用于说明如何使用kivy.lang.Builder.load_file()

项目:Kivy-Dynamic-Screens-Template    作者:suchyDev    | 项目源码 | 文件源码
def __init__(self, **kwargs):
        '''
        if kv is not loaded the load it either from string or a file specified
        need to specify "kv_string" or "kv_file", as well as unique "name"
        '''
        if not self.kv_loaded:
            from kivy.lang import Builder
            if self.kv_string:
                Builder.load_string(self.kv_string)
            if self.kv_file:
                Builder.load_file(self.kv_file)
            self.kv_loaded = True
        super(DynamicScreen, self).__init__(**kwargs)
项目:pyusbwhiteboard    作者:abhigenie92    | 项目源码 | 文件源码
def build(self):
        self.reactor=reactor
        self.connection_details=ConnectionDetails()
        return Builder.load_file('style.kv')
项目:stigma    作者:Kzulfazriawan    | 项目源码 | 文件源码
def kivyBuilder(*args):
    '''
    this function is used to open builder language kivy.
    '''
    if args is not None:
        kivy_path = path.join(*args)

        if path.isfile(kivy_path):
            return Builder.load_file(kivy_path)
项目:high-quality-chat    作者:b6938236    | 项目源码 | 文件源码
def build(self):
        # Kivy is stubborn and overrides self.config with a built-in ConfigParser
        self.config = hqc_config.get_instance(file="conn.conf")
        # Give the web socket a reference to the app
        gui = Builder.load_file("HQC.kv")
        self.root = gui
        # Link application to Screen Manager
        self.root.app = self
        return gui
项目:kivy-irc    作者:manthansharma    | 项目源码 | 文件源码
def build(self):
        self.main_widget = Builder.load_file('kivy_irc.kv')
        self.scr_mngr = self.main_widget.ids.scr_mngr
        self.nav_drawer = NavDrawer()
        self.config = self.config
        self.channel = eval(self.config.get('irc', 'channel'))
        self.connect_irc()
        return self.main_widget
项目:DemoKivyContacts    作者:HeaTTheatR    | 项目源码 | 文件源码
def load_all_kv_files(self):
        directory_kv_files = '{}/libs/uix/kv'.format(self.directory)

        for kv_files in os.listdir(directory_kv_files):
            if kv_files == 'bugreporter.kv':
                continue
            Builder.load_file('{}/{}'.format(directory_kv_files, kv_files))
项目:KivyTrek    作者:peterLaurence    | 项目源码 | 文件源码
def __init__(self, default_reticule, **kwargs):
        super(MapBoard, self).__init__(**kwargs)

        # Create the map viewer
        self.mapviewer = MapViewer(**kwargs)
        self.add_widget(self.mapviewer)

        # Load the reticule
        self.load_reticule(default_reticule)

        # Create compass button
        self.compass_button = CompassButton()
        self.add_widget(self.compass_button)

        # Add a reticule for calibration
        self.reticule_calib = Builder.load_file('ui/ScatterReticule.kv')

        # Create center_on_pos button
        self.load_center_on_pos()

        # Create path button
        path_button = PathButton()
        path_button.bind(on_press=self.mapviewer.toggle_tracking_path)
        self.add_widget(path_button)

        # Create the distance to center button
        self.dist_to_center_widget = None
        self.dist_to_center_visible =False
        self._dist_to_center_update_trigger = Clock.create_trigger(
            lambda x: self.dist_to_center_widget.set_distance(self.mapviewer.get_dist_to_center()), timeout=0.1)
        self.load_dist_to_center_button()
项目:KivyTrek    作者:peterLaurence    | 项目源码 | 文件源码
def load_screen(screen_file):
        curdir = dirname(__file__)
        screen = Builder.load_file(join(curdir, 'ui', 'screens', screen_file.lower()))
        return screen
项目:mmplayer    作者:Bakterija    | 项目源码 | 文件源码
def main_loop():
    try:
        Builder.load_file('layouts/pc_layout.kv')
        Builder.load_file('layouts/screen_manager.kv')
        app = MMplayerApp()
        app.run()
    except Exception as e:
        traceback.print_exc()
项目:garden.notification    作者:kivy-garden    | 项目源码 | 文件源码
def build(self):
        if not self.notif_icon:
            self.notif_icon = self.get_application_icon()
        Clock.schedule_once(self._hide_window, 0)
        if KWARGS['timeout_close']:
            Clock.schedule_once(self.stop, KWARGS['timeout'])
        if KWARGS['kv']:
            path = dirname(abspath(__file__))
            kv = Builder.load_file(join(path, 'notification.kv'))
            kv.ids.container.clear_widgets()
            kv.ids.container.add_widget(
                Builder.load_string(KWARGS['kv'])
            )
            return kv
项目:stigma-game-demo    作者:Kzulfazriawan    | 项目源码 | 文件源码
def kivyBuilder(*args):
    '''
    this function is used to open builder language kivy.
    '''
    if args is not None:
        kivy_path = path.join(*args)

        if path.isfile(kivy_path):
            return Builder.load_file(kivy_path)
项目:VKBot    作者:Fogapod    | 项目源码 | 文件源码
def load_kv_files(self):
        directories = ['uix/kv/']

        for directory in directories:
            for f in os.listdir(directory):
                if f.endswith('.kv'):
                    Builder.load_file(directory + f)
                else:
                    continue
项目:PyConversations    作者:HeaTTheatR    | 项目源码 | 文件源码
def load_all_kv_files(self, directory_kv_files):
        for kv_file in os.listdir(directory_kv_files):
            if kv_file == 'bugreporter.kv' or os.path.isdir('{}/{}'.format(
                    directory_kv_files, kv_file)):
                continue
            Builder.load_file('{}/{}'.format(directory_kv_files, kv_file))