emulator.py 文件源码

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

项目:wireless-network-reproduction 作者: FinalTheory 项目源码 文件源码
def load_data_file(self):
        dir_name, file_name = os.path.split(__file__)
        dir_name = os.path.join(dir_name, 'examples')
        file_path = askopenfilename(title='Choose .json file', initialdir=dir_name)
        if file_path and os.path.isfile(file_path):
            try:
                _, fname = os.path.split(file_path)
                with open(file_path, 'r') as fid:
                    data = fid.read()
                    self.conf_dict[file_path] = json.loads(data)
                    fname_sec = fname.split('.')
                    if len(fname_sec) > 1:
                        fname = '.'.join(fname_sec[:-1])
                    tk.Radiobutton(self.conf_frame, text=fname,
                                   variable=self.conf_name,
                                   value=file_path).pack(side=tk.LEFT)
                    self.conf_name.set(file_path)
            except Exception as e:
                showerror(title='Open file',
                          message='Unable to load json: %s' % e.message)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号