[Tkinter-discuss] ttk style dilema
Sorin Schwimmer
sxn02 at yahoo.com
Mon Apr 27 23:07:40 CEST 2009
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)? Or, even better, where can I find some docs regarding the names
of all these elements, and their expected values?
Best regards,
SxN
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
More information about the Tkinter-discuss
mailing list