Python B选项是什么?

Python B选项是什么?,python,python-3.x,user-interface,tkinter,Python,Python 3.x,User Interface,Tkinter,我想在tkinter中创建一个top-level小部件,但运行程序时它会给我一个错误。回溯将引导我指向optionDB,表明它不在我的目录中——这是真的。我在哪里可以下载或找到选项db,具体是什么?我也在网上搜索过,但没有找到一个好的答案。我希望有人能帮我 创建顶级小部件可能还有其他方法,但我也想知道optionDB是什么。对不起,我还是个初学者,我还不太了解 from tkinter import * root = Tk() root.option_readfile("optionD

我想在
tkinter
中创建一个
top-level小部件
,但运行程序时它会给我一个错误。回溯将引导我指向optionDB,表明它不在我的目录中——这是真的。我在哪里可以下载或找到
选项db
,具体是什么?我也在网上搜索过,但没有找到一个好的答案。我希望有人能帮我

创建顶级小部件可能还有其他方法,但我也想知道optionDB是什么。对不起,我还是个初学者,我还不太了解

from tkinter import *
root = Tk()
root.option_readfile("optionDB")
root.title("Toplevel")
回溯:

_tkinter.TclError: couldn't open "optionDB": no such file or directory

顾名思义,optionDB存储字体等所有选项。通常加载方式如下:要么没有文件,要么文件不在路径中。 现在,您可以在路径中创建一个空文件,并查看它是否进一步移动

其他与选项相关的可用方法

 |  option_add(self, pattern, value, priority=None)
 |      Set a VALUE (second parameter) for an option
 |      PATTERN (first parameter).
 |
 |      An optional third parameter gives the numeric priority
 |      (defaults to 80).
 |
 |  option_clear(self)
 |      Clear the option database.
 |
 |      It will be reloaded if option_add is called.
 |
 |  option_get(self, name, className)
 |      Return the value for an option NAME for this widget
 |      with CLASSNAME.
 |
 |      Values with higher priority override lower values.
 |
 |  option_readfile(self, fileName, priority=None)
 |      Read file FILENAME into the option database.
 |
 |      An optional second parameter gives the numeric
 |      priority.

天哪!非常感谢你。实际上我刚刚创建了一个optionDB.txt文件;将我的代码更改为root.option\u readfile('optionDB.txt'),它成功了!