Exemplo n.º 1
0
def emulate_file(filename):
    root=None

    dirname=os.path.dirname(filename)
    sys.path.append(dirname)
    resource_add_path(dirname)

    emulator_area().screen_display.screen.clear_widgets()    

    if os.path.splitext(filename)[1] =='.kv':    # load the kivy file directly
        try:    # cahching error with kivy files
            Builder.unload_file(filename)
            root = Builder.load_file(filename)
        except:
            traceback.print_exc()
            print("You kivy file has a problem")

    elif os.path.splitext(filename)[1] =='.py':
        load_defualt_kv(filename)

        try:    # cahching error with python files
            root = load_py_file(filename)
        except:
            traceback.print_exc()
            print("You python file has a problem")

    if root:
        emulator_area().screen_display.screen.add_widget(root)
    else:
        pass

    sys.path.pop()
    resource_remove_path(dirname)
Exemplo n.º 2
0
def start_emulation(filename, threaded=False):
    root = None
    if os.path.splitext(filename)[1] == '.kv':  # load the kivy file directly
        try:  # cahching error with kivy files
            Builder.unload_file(filename)
            root = Builder.load_file(filename)
        except:
            traceback.print_exc()
            print("You kivy file has a problem")

    elif os.path.splitext(filename)[1] == '.py':
        load_defualt_kv(filename)

        try:  # cahching error with python files
            root = load_py_file(filename)
        except:
            traceback.print_exc()
            print("You python file has a problem")

    if root:
        if threaded:
            emulation_done(root, filename)
        else:
            emulator_area().screen_display.screen.add_widget(root)

    dirname = os.path.dirname(filename)
    sys.path.pop()
    resource_remove_path(dirname)
Exemplo n.º 3
0
Arquivo: main.py Projeto: brussee/AT3
 def on_stop(self):
     """
     Unload the kivy language file when the application stops
     """
     Builder.unload_file(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'anontunnel.kv'))
     resource_remove_path(os.path.dirname(os.path.abspath(__file__)))
     osc.dontListen(self.oscid)
     return True
Exemplo n.º 4
0
 def on_stop(self):
     """
     Unload the kivy language file when the application stops
     """
     Builder.unload_file(
         os.path.join(os.path.dirname(os.path.realpath(__file__)),
                      'anontunnel.kv'))
     resource_remove_path(os.path.dirname(os.path.abspath(__file__)))
     osc.dontListen(self.oscid)
     return True
Exemplo n.º 5
0
def start_emulation(filename, file_content, threaded=False):
    root = None
    has_error = False
    if os.path.splitext(filename)[1] == '.kv':  # load the kivy file directly
        try:  # cacthing error with kivy files
            Builder.unload_file(filename)
            root = Builder.load_file(filename)
        except:
            has_error = True
            trace = traceback.format_exc()
            Logger.error("Emulator: {}".format(trace))

    elif os.path.splitext(filename)[1] == '.py':
        load_defualt_kv(filename, file_content)
        try:  # cahching error with python files
            root = load_py_file(filename, file_content)
        except:
            has_error = True
            trace = traceback.format_exc()
            Logger.error("Emulator: {}".format(trace))
    else:
        Logger.warning(
            "KivyStudio: can't emulate file type {}".format(filename))

    if not root and not has_error:
        Logger.error('Emulator: No root widget found.')
    elif not isinstance(root, Widget) and not has_error:
        Logger.error(
            "KivyStudio: root instance found = '{}' and is not a widget".
            format(root))
    elif root:
        if threaded:
            emulation_done(root, filename)
        else:
            get_emulator_area().screen_display.screen.add_widget(root)

    dirname = os.path.dirname(filename)
    sys.path.pop()
    resource_remove_path(dirname)
Exemplo n.º 6
0
    def start_emulation(self, filename, threaded=False):
        print("___________________________________")
        print("Starting thread")
        root = None
        # print(os.path.splitext(filename))
        if os.path.splitext(
                filename)[1] == '.kv':  # load the kivy file directly
            try:  # cahching error with kivy files
                Builder.unload_file(filename)
                # print("unloaded the kv")
                root = Builder.load_file(filename)
            except:
                traceback.print_exc()
                print("You kivy file has a problem")

        elif os.path.splitext(filename)[1] == '.py':
            print("its a py")
            self.load_defualt_kv(filename)

            try:  # cahching error with python files
                root = self.load_py_file(filename)
            except:
                traceback.print_exc()
                print("You python file has a problem")

        if root:
            print("this is the root", root)
            if threaded:
                self.emulation_done(root, filename)
            else:
                print("not threaded")
                self.root.ids.emulator_screen.clear_widgets()
                self.root.ids.emulator_screen.add_widget(root)

        dirname = os.path.dirname(filename)
        sys.path.pop()
        resource_remove_path(dirname)
Exemplo n.º 7
0
 def stop(self):
     Builder.unload_file(join(dirname(__file__), 'map.kv'))
     resource_remove_path(dirname(__file__))
Exemplo n.º 8
0
 def stop(self):
     Builder.unload_file(join(dirname(__file__), "fresco.kv"))
     resource_remove_path(dirname(__file__))
Exemplo n.º 9
0
 def stop(self):
     Builder.unload_file(join(dirname(__file__), 'fresco.kv'))
     resource_remove_path(dirname(__file__))
Exemplo n.º 10
0
from ui.ui import UserInterface
from kivy.garden.iconfonts import iconfonts
from kivy import resources

from kivy.config import Config

Config.set('graphics', 'width', '800')
Config.set('graphics', 'height', '480')

resources.resource_add_path(
    '/home/zandemax/coding/pcms/img/defaulttheme-0.png')
resources.resource_remove_path(
    '/usr/lib/python3.6/site-packages/kivy/data/images/defaulttheme-0.png')
print(resources.resource_find('defaulttheme-0'))

iconfonts.register('weather', 'img/weathericons-regular-webfont.ttf',
                   'img/weather_icons.fontd')
UserInterface().run()