设置Tkinter小部件的默认选项值 [英] Setting default option values for Tkinter widgets

查看:99
本文介绍了设置Tkinter小部件的默认选项值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Tkinter小部件的某些选项有默认值

,我不太关心(边界宽度,字体浮现在脑海中)和

不断变化当我正在构建接口时。稍微调整一下

我已经能够给小部件一个可以与其中最好的相媲美的外观。但是,当我正在编写代码时,我厌倦了这样做。我希望能在我的系统上普遍改变它们。

我试过找到类文件中的哪个位置(Tkinter.py)我可以更改这些并且无法找到它们。在某些文件/模块/类中是否有某些

行我可以更改

的值,如字体,边框等等?


谢谢,


Harlin

There are certain options for Tkinter widgets that have default values
that I don''t much care for (borderwidth, font come to mind) and
continuously change when I''m building interfaces. With a bit of
tweaking I have been able to give the widgets a look that rivals the
best of them. However, I get tired of doing this when I''m writing code
and would like a way that I could universally change them on my system.
I have tried to find where in the class files (Tkinter.py) that I can
change these and haven''t been able to find them. Are there certain
lines in certain files/modules/classes that I can change the values for
these things like font, border, etc.?

Thanks,

Harlin

推荐答案

2005年3月3日03:02:48 -0800,Harlin Seritt< ha ********** @ yahoo.com>写道:
On 3 Mar 2005 03:02:48 -0800, Harlin Seritt <ha**********@yahoo.com> wrote:
Tkinter小部件的某些选项具有默认值
我不太关心(borderwidth,字体浮现在脑海中)和
在构建界面时不断变化。通过一些调整,我已经能够给小部件一个可以与其中最好的相媲美的外观。但是,当我编写代码时,我厌倦了这样做,并且想要一种可以在我的系统上普遍改变它们的方式。
我试图找到类文件中的位置(Tkinter) .py)我可以改变它们并且无法找到它们。在某些文件/模块/类中是否有某些
行我可以更改
这些东西的值,如字体,边框等?
There are certain options for Tkinter widgets that have default values
that I don''t much care for (borderwidth, font come to mind) and
continuously change when I''m building interfaces. With a bit of
tweaking I have been able to give the widgets a look that rivals the
best of them. However, I get tired of doing this when I''m writing code
and would like a way that I could universally change them on my system.
I have tried to find where in the class files (Tkinter.py) that I can
change these and haven''t been able to find them. Are there certain
lines in certain files/modules/classes that I can change the values for
these things like font, border, etc.?




tk允许将您的优先选项写入选项文件,并通过应用程序中的方法option_readfile加载它。


有关如何设置选项的示例,请参阅:
http://mini.net/tcl/10424
该文件应包含传递给option add的参数。命令。


有关可用选项以及如何在选项文件中指定它们的参考,请参阅此处的tk手册页:
http://www.tcl.tk/man/tcl8.4/TkCmd/contents .htm

小部件的名称通常是相应Tkinter类的名称;该选项的名称是在手册页中的标准和小部件特定选项部分中找到的第二个名称(在部分文本中命名为数据库名称)。因此,例如,如果要为支票按钮设置默认选择颜色,您将在选项文件中添加一行:


* Checkbutton.selectColor:blue


HTH

-

python -c''print"" .join([chr(154 - ord(c))对于c中的U(17zX(%,5.z ^ 5(1718(%,5.Z *(93-965



tk allows to write your preffered options to an option file and to load it via the method option_readfile in your application.

For an example on how the options can be set, see:
http://mini.net/tcl/10424
The file should contain the arguments passed to "option add" commands.

For a reference on what options are available and how to specify them in an option file, see the tk manual pages here:
http://www.tcl.tk/man/tcl8.4/TkCmd/contents.htm
The name for the widget is usually the name of the corresponding Tkinter class; the name for the option is the second name found in the standard and widget-specific options sections in the man pages (named "Database name" in the section text). So for example, if you want to set the default select color for checkbuttons, you''ll put in your option file a line:

*Checkbutton.selectColor: blue

HTH
--
python -c ''print "".join([chr(154 - ord(c)) for c in "U(17zX(%,5.z^5(17l8(%,5.Z*(93-965


17 + - ))''br />
l7+-"])''


Eric,你的标语在我的Python 2.4 shell上没有正确解析。

Eric, your tagline doesn''t parse correctly on my Python 2.4 shell.


这篇关于设置Tkinter小部件的默认选项值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆