On Mon, Apr 27, 2009 at 6:07 PM, Sorin Schwimmer <sx...@yahoo.com> wrote:
>
> Hi Guilherme,
>
> First of all, *I thank you* for providing pyttk.
>
> Next, your suggestions are exactly what I was looking for. The following
> prototype is showing what am I after (ugly, no classes, but take it as a
> prototype):
>
> #! /usr/bin/env python
> # -*- coding: iso-8859-1 -*-
>
> import ttk
> from ttk import Tkinter as tk
> import tkFont
>
> r=tk.Tk()
>
> vPcode=tk.StringVar()
> vPcode.set('Postal code')
> st=ttk.Style()
> st.configure('I.TEntry',foreground='gray',background='white')
> st.map('I.TEntry',selectforeground=[('!disabled','gray')],selectbackground=[('!d
> isabled','white')])
> ePcode=ttk.Entry(r,textvariable=vPcode,style='I.TEntry',width=12)
> efn=tkFont.Font(font=str(ePcode['font']))
> fn=tkFont.Font(font=str(ePcode['font']))
> fn['slant']='italic'
> ePcode['font']=fn
> ePcode.grid()
>
> def postal(ev):
>  global r,vPcode,ePcode
>  if ev.keysym=='Return':
>    ttk.Label(r,text='Done successfully').grid()
>  elif vPcode.get()=='Postal code':
>    ePcode['style']='I.TEntry'
>    ePcode['font']=fn
>  else:
>    ePcode['style']='TEntry'
>    ePcode['font']=efn
>
> ePcode.select_range(0,tk.END)
> ePcode.bind('<KeyRelease>',lambda ev: postal(ev))
> ePcode.focus()
>
> r.mainloop()
>
> It works beautifully, thanks to your advice. How can I get rid of the
> rectangle surrounding the selected text (I suppose another style.map
> option)?

Yes, but in this specific case you could use style.configure which is
a bit simpler to use:

style.configure('TEntry', selectborderwidth=0)

You could also uso style.map for this, but you have to specify the
state(s) where the option applies for that style. Since the
selectborderwidth is very likely to be the same in all the states, it
is fine to use style.configure.

> Or, even better, where can I find some docs regarding the names
> of all these elements, and their expected values?
>

Actually the tk source is the best place for this, the C code.
Documentation for ttk/tile is lacking, the widget introspection is not
very nice too, so either Google can help you or you need to look into
its code.

> Best regards,
> SxN
>



-- 
-- Guilherme H. Polo Goncalves
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to