473,881 Members | 1,623 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Setting default option values for Tkinter widgets

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

Jul 18 '05 #1
11 2099
On 3 Mar 2005 03:02:48 -0800, Harlin Seritt <ha**********@y ahoo.com> wrote:
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 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.se lectColor: blue

HTH
--
python -c 'print "".join([chr(154 - ord(c)) for c in "U(17zX(%,5.z^5 (17l8(%,5.Z*(93-965$l7+-"])'
Jul 18 '05 #2
Eric, your tagline doesn't parse correctly on my Python 2.4 shell.

Jul 18 '05 #3
st************* **@gmail.com wrote:
Eric, your tagline doesn't parse correctly on my Python 2.4 shell.

So, are you using Windows?

sholden@bigboy /c/Python24/Lib/site-packages
$ python -c 'print "".join([chr(154 - ord(c)) for c in
"U(17zX(%,5.z5( 17l8(%,5.Z*(93-965$l7+-"])'
Eric Brunel er*********@pra gmadev.com

regards
Steve
--
Meet the Python developers and your c.l.py favorites March 23-25
Come to PyCon DC 2005 http://www.pycon.org/
Steve Holden http://www.holdenweb.com/
Jul 18 '05 #4
Steve Holden wrote:
st************* **@gmail.com wrote:
Eric, your tagline doesn't parse correctly on my Python 2.4 shell.

So, are you using Windows?


If you interchange single and double quotes it works on Windows too
python -c "print ''.join([chr(154 - ord(c)) for c in 'U(17zX(%,5.z^5 (17l8(%,5.Z*(93-965$l7+-'])"

Kent
Jul 18 '05 #5
yep, that works better under Windows. Pretty obscure use of Python,
though! :-)

S

Jul 18 '05 #6
I have
listA=[1,2,3,4,5,4,3,4 ,3,2,1]
and I want a list of only the unique members.

This seems inefficient, but works fine over my small sample lists:
listA=[a for a in set(listA)]

Is there a more efficient approach for cases where listA is large?


Eric Pederson
::::::::::::::: ::::::::::::::: :::::
domainNot="@som ething.com"
domainIs=domain Not.replace("s" ,"z")
ePrefix="".join ([chr(ord(x)+1) for x in "do"])
mailMeAt=ePrefi x+domainIs
::::::::::::::: ::::::::::::::: :::::

Jul 18 '05 #7
Eric Pederson wrote:
I have
listA=[1,2,3,4,5,4,3,4 ,3,2,1]
and I want a list of only the unique members.

This seems inefficient, but works fine over my small sample lists:
listA=[a for a in set(listA)]

Is there a more efficient approach for cases where listA is large?


No. But I doubt that that is what you actually want, as listA will lose its
order afterwards. Typically, something like that gets written like this:

inserted = set()
res = []
for e in listA:
if not e in inserted:
res.append(e)
inserted.add(e)
listA = res

Or, with a little helperfunction:

inserted = set()
def foo(e):
inserted.add(e)
return e
listA = [foo(e) for e in listA if not e in inserted]

But ist's not really much better.

--
Regards,

Diez B. Roggisch
Jul 18 '05 #8
Eric Pederson wrote:
I have

listA=[1,2,3,4,5,4,3,4 ,3,2,1]

and I want a list of only the unique members.

This seems inefficient, but works fine over my small sample lists:

listA=[a for a in set(listA)]
Is there a more efficient approach for cases where listA is large?

no. Even though the code can be a little simpler:

listA = list(Set(listA) )

You don't even need to convert it to a list. You can just iterate over
the set.
la = [1,2,3,4,3,2,3,4 ,5]
from sets import Set
sa = Set(la)
for itm in sa:

.... print itm
1
2
3
4
5

--

hilsen/regards Max M, Denmark

http://www.mxm.dk/
IT's Mad Science
Jul 18 '05 #9
"Diez B. Roggisch" <de*********@we b.de> wrote:
inserted = set()
res = []
for e in listA:
if not e in inserted:
res.append(e)
inserted.add(e)
listA = res


I'm going to go off on a tangent here and put in a plea for better variable
naming. I'm looking at the above code, and can't figure out what "res" is
supposed to be. Is it short for "rest", as in "the rest of the items"?
Residual? Result? Restore? Any of these seems plausable. Not knowing
which makes it much harder to understand what the code does. When you say
"res.append(e)" , are you building up the result that you're going to
return, or are you building up a list of elements that got eliminated (i.e.
residual) because they are duplicates?

Yes, I did eventually figure it out. It didn't even take that long, but
this is a trivial little piece of code; it shouldn't have taken any time at
all to figure it out. All you saved by using "res" instead of "result" was
9 keystrokes ("ult", in three places), but it cost every one of your
readers extra brainpower to figure out what you meant. To quote one of
Aahz's better signatures, "Typing is cheap. Thinking is expensive." :-)
Jul 18 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
7045
by: srijit | last post by:
Hello, Any idea - why the following code crashes on my Win 98 machine with Python 2.3? Everytime I run this code, I have to reboot my machine. I also have Win32all-157 installed. from Tkinter import * class App:
3
2082
by: rick.lawson | last post by:
I, like a lot of developers, have collected a homegrown set of widgets for Tkinter. Any thoughts on a central repository for Tkinter widgets or widget extensions? Stuff that's not in Tkinter or standard extensions like Pmw. It would be nice if you could go to sourceforge and download a package instead of hunting the Vaults, the Activestate cookbook, googling, etc. If there's enough interest I'd be willing to set the project up on
2
2334
by: Adonis | last post by:
I am creating some widgets by inheriting from Tkinter.Frame and populating the frame with whatever the widget will be then creating certain attributes/methods to be accessed later. My question is, is this a poper way to create widgets or should I take a different approach? Any help is greatly appreciated. Adonis
25
3370
by: BJörn Lindqvist | last post by:
See: http://www.wxpython.org/quotes.php. especially: "wxPython is the best and most mature cross-platform GUI toolkit, given a number of constraints. The only reason wxPython isn't the standard Python GUI toolkit is that Tkinter was there first." - Guido van Rossum Guess, that answers my question, but isn't "Tkinter was there first" a very bad answer? :) It is kinda ugly too, so I wonder why it can't be replaced? Or maybe another GUI...
3
2153
by: Matt Hammond | last post by:
Here's a strange one in Tkinter that has me stumped: (I'm running python 2.4 on Suse Linux 9.3 64bit) I'm trying to make a set of Entry widgets with Label widgets to the left of each one, using the grid layout. If I make and grid the Label *before* the Entry then the Entry widget doesn't seem to work - it lets me put the cursor in it, but I can't type! See example code below. Is this just me doing something really really silly, or is...
1
6525
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting" setting to be "E_ALL", notices are still not getting reported. The perms on my file are 664, with owner root and group root. The php.ini file is located at /usr/local/lib/php/php.ini. Any ideas why the setting does not seem to be having an effect? ...
32
7519
by: Kevin Walzer | last post by:
I'm a Tcl/Tk developer who has been working, slowly, at learning Python, in part because Python has better support for certain kinds of applications that I want to develop than Tcl/Tk does. Naturally, I thought that I would use Tkinter as the GUI for these programs. However, in doing research into GUI development techniques, sample code, and showcase applications, what has struck me is how little sophisticated GUI development seems to be...
0
1311
by: Unnamed One | last post by:
First question - is it possible to set font to default OS font for window text? It would be preferable, while on my Windows XP system Tkinter sets small Helvetica-style font by default. Secondly, can I set font globally (or specify "default" font for widgets)? In fact, all I want is to get default OS font unless (rarely) I need to specify another. Thanks
3
3924
by: J-Burns | last post by:
Hello. Im a bit new to using Tkinter and im not a real pro in programming itself... :P. Need some help here. Problem 1: How do I make something appear on 2 separate windows using Tkinter? By this I mean that the format would be something like this: You have Page1 : This has 2-3 buttons on it. Clicking on each button opens up a new window respectively having
0
9928
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9776
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10718
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10816
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7953
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5781
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4597
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4196
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3225
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.