Exemplo n.º 1
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.º 2
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.º 3
0
def emulate_file(filename, threaded=False):
    root = None

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

    emulator_area().screen_display.screen.clear_widgets()

    if threaded:
        Thread(target=partial(start_emulation, filename,
                              threaded=threaded)).start()
    else:
        start_emulation(filename, threaded=threaded)
Exemplo n.º 4
0
 def check_settings(self):
     # import kivystudio app to not confuse it with current emulating app
     from kivystudio import get_kivystudio_app
     app = get_kivystudio_app()
     auto_save = app.user_settings.get('file-settings')['auto_save']
     auto_emulate = app.user_settings.get(
         'emulator-settings')['auto_emulate']
     if auto_save:
         self.parent.parent.save_file(auto_save=True)
     if auto_emulate:
         from kivystudio.parser import emulate_file
         from kivystudio.components.emulator_area import emulator_area
         if emulator_area().emulation_file == self.parent.filename:
             emulate_file(self.parent.filename)
Exemplo n.º 5
0
 def set_for_emulation(self, remove=False):
     if not remove:
         emulator_area().emulation_file = self.tab.filename
     else:
         emulator_area().emulation_file = ''
Exemplo n.º 6
0
    print(a)


def key_down(self, *args):
    if args[0] == 114 and args[3] == ['ctrl']:     # emulate file Ctrl+R
        Clock.schedule_once(lambda dt: emulate_file(emulator_area.emulation_file))

    elif args[0] == 107 and args[3] == ['ctrl']:    # Ctrl K pressed
        pass

    elif args[0] == 111 and args[3] == ['ctrl']:    # open file Ctrl+O
        filemanager.open_file(path='/root',callback=add_new_tab)

    elif args[0] == 110 and args[3] == ['ctrl']:    # new file Ctrl+N
        code_place.add_code_tab(tab_type='new_file')



Window.bind(on_key_down=key_down)


code_place = CodePlace()
code_place.add_code_tab(tab_type='welcome')

emulator_area = emulator_area()
Assembler = Assembly()

Assembler.ids.box.add_widget(SideBar())
Assembler.ids.box.add_widget(code_place)
Assembler.ids.box.add_widget(emulator_area)
Exemplo n.º 7
0
 def set_for_emulation(self):
     emulator_area().emulation_file = self.tab.filename
Exemplo n.º 8
0
def emulation_done(root, filename):
    if root:
        emulator_area().screen_display.screen.add_widget(root)