Tkinter Qs 
Author Message
 Tkinter Qs

question 1:
what form of measurement does Tkinter use? Pixels or DIB?

question 2:
why doesnt this work? (text not being colored)

t = Text(frame, width=50, height=15)
t.pack()
t.tag_config("test", foreground="red")
t.insert(END, "test")

* have looked into Tkinter documentation and am using examples directly
as-is, textbox is bein drawna nd text is present but color not being
shown.

thanks in advance,

Adonis



Thu, 27 Nov 2003 01:07:03 GMT  
 Tkinter Qs


Quote:
>what form of measurement does Tkinter use? Pixels or DIB?

Sometimes it uses pixels, sometimes it uses lines, and sometimes
it uses characters.

b=Button(root,text="Test",width=10) # 10 characters wide
t=Text(root,width=20,height=2) # 20 characters wide, 2 lines high
f=Frame(root,width=25,height=35,bg="green") # 25 by 35 dots

This is often maddening.

Fredrik Lundh mentions a way of working around this odd use of
multiple units of measure at (wrapped for line length):

http://www.pythonware.com/library/tkinter/
  introduction/x1309-patterns.htm

That's from his excellent An Introduction to Tkinter. I recommend
it highly.

Quote:
>why doesnt this work? (text not being colored)
>t = Text(frame, width=50, height=15)
>t.pack()
>t.tag_config("test", foreground="red")
>t.insert(END, "test")

The first argument to tag_config() is a user-defined tag name. The tag
needs to be added to specific characters or character ranges:

t=Text(root, width=50, height=15)
t.pack()
t.tag_config("mytag", foreground="red")
t.insert(END, "test")
t.tag_add("mytag","1.0","1.4")

You can also specify the tag name when you're inserting text:

Quote:
>>> t.insert(END,"wibble","mytag")

Regards,
Matt


Thu, 27 Nov 2003 01:40:10 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Extensions/tkinter/* vs Modules/tkinter* (was: Python 1.1 w/ tkinter for AIX)

2. several Qs

3. Qs on CLUBMGR, Template BUG ???

4. Qs

5. Qs about language nomenclature

6. New newbies Qs on Ruby

7. Newbie Qs: startup time, Module.constants, chdir, Ruby distro's library

8. Qs on Ruby and DbC/Smalltalk

9. 2 Qs: IndexedFaceSets & browsers

10. Qs re 'Write & 'Read

11. newbie obj files Qs

12. NASM Qs

 

 
Powered by phpBB® Forum Software