473,395 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Tkinter Entry widgets 'font' property (API ?) changed in Python 2.5.2?

Hi,

The snippet :

entryFontDescr = Entry()["font"]
print self.entryFontDescr

On Windows XP it displays

{MS Sans Serif} 8

On Suse Linux 10.2 it used to display

TkTextFont 10

I upgraded to OpenSuse 11 and now it shows

TkTextFont

I used this snippet to obtain the default font size for an Entry
widget. Now with an OS upgrade, my code is broken.

The python version on the upgraded box is

~python
Python 2.5.2 (r252:60911, Jun 6 2008, 23:32:27)
[GCC 4.3.1 20080507 (prerelease) [gcc-4_3-branch revision 135036]] on
linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
I dont remember the exact version of Python on the earlier Suse 10.2
box

My questions:

1. Is this not an API change ? I looked up Python's release
documentation and didn't find any mention of the same.
2. How can I achieve what I want alternatively ?

Regards,
-- Atul
Aug 6 '08 #1
2 1967
On Wed, 06 Aug 2008 06:01:59 +0200, Atul <at*******@gmail.comwrote:
Hi,

The snippet :

entryFontDescr = Entry()["font"]
print self.entryFontDescr

On Windows XP it displays

{MS Sans Serif} 8

On Suse Linux 10.2 it used to display

TkTextFont 10

I upgraded to OpenSuse 11 and now it shows

TkTextFont

I used this snippet to obtain the default font size for an Entry
widget. Now with an OS upgrade, my code is broken.

The python version on the upgraded box is

~python
Python 2.5.2 (r252:60911, Jun 6 2008, 23:32:27)
[GCC 4.3.1 20080507 (prerelease) [gcc-4_3-branch revision 135036]] on
linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>>

I dont remember the exact version of Python on the earlier Suse 10.2
box

My questions:

1. Is this not an API change ? I looked up Python's release
documentation and didn't find any mention of the same.
Tkinter is a very thin wrapper over an embedded tcl/tk interpreter. So I
guess the API change is caused by a tcl/tk version change, not by a Python
one. You can check the version of the tcl/tk interpreter you're using from
Python via:

root = Tkinter.Tk()
root.tk.eval('puts $tcl_patchLevel')
root.tk.eval('puts $tk_patchLevel')
2. How can I achieve what I want alternatively ?
I'd use this way:

import tkFont
entryFontDescr = Entry()["font"]
entry_font = tkFont.Font(font=entryFontDescr)
print entry_font.actual()
Regards,
-- Atul
HTH
--
python -c "print ''.join([chr(154 - ord(c)) for c in
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"
Aug 6 '08 #2
Hi Eric,

Thanks for your response.
Tkinter is a very thin wrapper over an embedded tcl/tk interpreter. So I *
guess the API change is caused by a tcl/tk version change, not by a Python *
one. You can check the version of the tcl/tk interpreter you're using from *
Python via:

root = Tkinter.Tk()
root.tk.eval('puts $tcl_patchLevel')
root.tk.eval('puts $tk_patchLevel')
The Windows box reports 8.4.12 whereas the OpenSuze 11 box reports
8.5.2
I suppose the Suze 10.2 box had a lesser version and hence the API
change.
2. How can I achieve what I want alternatively ?

I'd use this way:

import tkFont
entryFontDescr = Entry()["font"]
entry_font = tkFont.Font(font=entryFontDescr)
print entry_font.actual()
This works very well, thank you :)

Regards,
-- Atul
Aug 9 '08 #3

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

Similar topics

25
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...
3
by: Harlin Seritt | last post by:
I've created a ghetto-ized ComboBox that should work nicely for Tkinter (unfortunately no dropdown capabilities yet). I've found why it's such a pain in the @ss to create one. You have to...
3
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...
3
by: William Gill | last post by:
Working with tkinter, I have a createWidgets() method in a class. Within createWidgets() I create several StringVars() and assign them to the textvariable option of several widgets. Effectively my...
5
by: H J van Rooyen | last post by:
Hi, I am struggling to get the pack method to do what I intend. I am trying to display user input in a seperate window, along with a little description of the field, something like this: ...
32
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....
3
by: rahulnag22 | last post by:
Hi, I have developed a GUI using tkinter (grid geometory manager). The structure is a top frame containing multiple subframes. Each subframe has a combination of widgets like(Entry, label,...
44
by: bg_ie | last post by:
Hi, I'm in the process of writing some code and noticed a strange problem while doing so. I'm working with PythonWin 210 built for Python 2.5. I noticed the problem for the last py file...
8
by: Lie | last post by:
Inspect the following code: --- start of code --- import Tkinter as Tk from Tkconstants import * root = Tk.Tk() e1 = Tk.Entry(root, text = 'Hello World') e2 = Tk.Entry(root, text = 'Hello...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.