gui.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:maze-pathfinder 作者: ivan-ristovic 项目源码 文件源码
def btn_import_on_click(self):
        # Loading image from file...
        loading_time_start = time.time()
        self.perform_process(lambda: self.load_from_file(self.ent_filename.get()), "Loading image...")
        if self.img is None:
            return

        # Creating graph
        graph_time_start = time.time()
        try:
            self.perform_process(lambda: self.create_graph(), "Creating graph...")
            if self.grp.nodes_num is None:
                raise Exception
        except:
            tkMessageBox.showerror("Error",
                "Invalid image!\n" +
                "Image must have a black border and only one entry and exit point\n" +
                "Also, the exit point must not have a black square above it."
            )
            return
        graph_time_end = time.time()

        self.exec_time = graph_time_end - loading_time_start

        tkMessageBox.showinfo("Info",
            "Maze successfully imported!\n\n" +
            "File loading time:\t\t%.5lfs\n" % (graph_time_start - loading_time_start) +
            "Graph creation time:\t\t%.5lfs\n" % (graph_time_end - graph_time_start) +
            "Nodes created:\t\t%u\n" % self.grp.nodes_num +
            "Elapsed time:\t\t%.5lfs" % self.exec_time
        )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号