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

Discussion in 'Python' started by Atul, Aug 6, 2008.

  1. Atul

    Atul Guest

    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
    Atul, Aug 6, 2008
    #1
    1. Advertising

  2. Atul

    Eric Brunel Guest

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

    On Wed, 06 Aug 2008 06:01:59 +0200, Atul <> wrote:

    > 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+-'])"
    Eric Brunel, Aug 6, 2008
    #2
    1. Advertising

  3. Atul

    Atul Guest

    Re: Tkinter Entry widgets 'font' property (API ?) changed in Python2.5.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
    Atul, Aug 9, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?ISO-8859-1?Q?Mickel_Gr=F6nroos?=

    Placing entry widgets on a canvas in Tkinter

    =?ISO-8859-1?Q?Mickel_Gr=F6nroos?=, Jun 30, 2003, in forum: Python
    Replies:
    0
    Views:
    409
    =?ISO-8859-1?Q?Mickel_Gr=F6nroos?=
    Jun 30, 2003
  2. =?ISO-8859-1?Q?Mickel_Gr=F6nroos?=

    Re: Placing entry widgets on a canvas in Tkinter

    =?ISO-8859-1?Q?Mickel_Gr=F6nroos?=, Jun 30, 2003, in forum: Python
    Replies:
    0
    Views:
    949
    =?ISO-8859-1?Q?Mickel_Gr=F6nroos?=
    Jun 30, 2003
  3. mttc
    Replies:
    2
    Views:
    2,368
    Roedy Green
    Jul 3, 2009
  4. Chris Hare
    Replies:
    2
    Views:
    524
    Chris Hare
    Aug 16, 2010
  5. Arnaud Delobelle

    Tkinter bug in Entry widgets on OS X

    Arnaud Delobelle, Aug 31, 2012, in forum: Python
    Replies:
    7
    Views:
    255
    Arnaud Delobelle
    Sep 1, 2012
Loading...

Share This Page