Chapter6-3.py 文件源码

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

项目:Tkinter-By-Example 作者: Dvlv 项目源码 文件源码
def file_open(self, event=None):
        file_to_open = filedialog.askopenfilename()

        if file_to_open:
            self.open_file = file_to_open
            self.main_text.delete(1.0, tk.END)

            with open(file_to_open, "r") as file_contents:
                file_lines = file_contents.readlines()
                if len(file_lines) > 0:
                    for index, line in enumerate(file_lines):
                        index = float(index) + 1.0
                        self.main_text.insert(index, line)

        self.title(" - ".join([self.WINDOW_TITLE, self.open_file]))

        self.tag_all_lines()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号