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


Python Loader.loader方法代码示例

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


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

示例1: AllApp

# 需要导入模块: from loader import Loader [as 别名]
# 或者: from loader.Loader import loader [as 别名]
class AllApp(Gtk.Application):
    # constructor of the Gtk Application

    def __init__(self):
        Gtk.Application.__init__(self)
        self.shell_ui = Gtk.Builder()
        self.shell_ui.add_from_file("shell.glade")
        self.handler_dict = {
            "on_start_file_chooser_button_clicked": self.on_start_file_chooser_button_clicked,
            "on_start_button_clicked": self.on_start_button_clicked,
            "on_simulator_open_file_button_clicked": self.on_simulator_open_file_button_clicked,
            "on_simulate_pass_button_clicked": self.on_simulate_pass_button_clicked,
            "on_run_button_clicked": self.on_run_button_clicked,
            "on_quit_image_menu_item_activate": self.on_quit_activate,
            "on_offset_button_clicked": self.on_offset_button_clicked
        }
        self.shell_ui.connect_signals(self.handler_dict)
        self.x = []
        self.z = []
        self.assembler_instance = None
        self.loader_instance = None
        self.linker_instance = None
        self.simulator_instance = None
        # self.simulator=Simulator()

    def on_offset_button_clicked(self, widget):
        self.loader_instance.loader2(self.x)

    def do_activate(self):
        window = self.shell_ui.get_object("all_window")
        self.add_window(window)
        window.show_all()

    def on_start_file_chooser_button_clicked(self, widget):
        window = self.shell_ui.get_object("all_window")
        dialog = Gtk.FileChooserDialog(title="Please choose a file", parent=window, action=Gtk.FileChooserAction.OPEN,
                                       buttons=(
                                           Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN,
                                           Gtk.ResponseType.OK))
        response = dialog.run()
        if response == Gtk.ResponseType.OK:
            selected_file_path = dialog.get_filename()
            relative_path = os.path.basename(selected_file_path)
            inputfile = open(relative_path, "r")
            code = inputfile.read()
            lines = code.split('\n')
            finalfile = lines[0].split('.')[0] + '.8085'
            print(lines[0].split('.')[0])
            print(finalfile)

            entries_box = self.shell_ui.get_object("start_entries_box")
            wids = entries_box.get_children()
            for widget in wids:
                widget.destroy()
            i = 0
            print (lines)
            for line in lines:
                if line != '':
                    self.z.append(line)
                    label = Gtk.Label("Code" + str(i))
                    tv = Gtk.TextView()
                    tb = tv.get_buffer()
                    entries_box.add(label)
                    entries_box.add(tv)
                    i += 1
                    with open(line, "r") as file:
                        s = file.read()
                        tb.set_text(s)
                        print(s)
            self.shell_ui.get_object("start_entry_number_entry").set_text(str(i))
            entries_box.show_all()
            self.x = preprocess(self.z)
            processed_box = self.shell_ui.get_object("processed_box")
            i = 0
            for file_name in self.x:
                if file_name != '':
                    label = Gtk.Label("Code" + str(i))
                    tv = Gtk.TextView()
                    tb = tv.get_buffer()
                    processed_box.add(label)
                    processed_box.add(tv)
                    i += 1
                    with open(file_name, "r") as file:
                        s = file.read()
                        tb.set_text(s)
                        print(s)
            processed_box.show_all()
        elif response == Gtk.ResponseType.CANCEL:
            print("Cancel clicked")
        dialog.destroy()

    def on_start_button_clicked(self, widget):
        finalfile = self.x[0].split('.')[0] + '.8085'
        info = self.shell_ui.get_object("start_info_label")
        # str1 = ''
        # str1 += 'Interpreting...........\nRunning Assembler \n'
        # info.set_text(str1)
        self.assembler_instance = Assembler(self.shell_ui)
        self.assembler_instance.test(self.x)
        # str1 = str1 + 'Assembler Completed \n' + 'Running Linker \n'
#.........这里部分代码省略.........
开发者ID:theawless,项目名称:PALLS-8085,代码行数:103,代码来源:__init__.py


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