How to highlight Label/Text in tkinter ?

VGNU Linux vgnulinux at gmail.com
Wed Nov 3 07:32:04 CET 2010


Hi,
I am writing a program teach myself python and tkinter.
Below given is a program which displays label with different fonts and
sizes.
How to highlight text and change font size if the up/down arrow keys are
pressed ?
from Tkinter import *
import tkFont

class MyFrame(Frame):

    def __init__(self, root):
        Frame.__init__(self, root)
        self.txt = Label(self, text="Arial 10 bold",
font=("Arial",10,"bold"))
        self.txt.grid(row=1,column=1)
        self.txt = Label(self, text="Courier 12 bold",
font=("Courier",12,"bold"))
        self.txt.grid(row=2,column=1)
        self.txt = Label(self, text="Comic Sans MS 14 bold", font=("Comic
Sans MS",14,"bold"))
        self.txt.grid(row=3,column=1)
        self.txt = Label(self, text="Fixedsys 16 bold",
font=("Fixedsys",16,"bold"))
        self.txt.grid(row=4,column=1)
        self.txt = Label(self, text="MS Sans Serif 18 bold", font=("MS Sans
Serif",18,"bold"))
        self.txt.grid(row=5,column=1)
        self.txt = Label(self, text="MS Serif, Symbol 20 bold", font=("MS
Serif, Symbol",20,"bold"))
        self.txt.grid(row=6,column=1)
        self.txt = Label(self, text="System 22 bold",
font=("System",22,"bold"))
        self.txt.grid(row=7,column=1)
        self.txt = Label(self, text="Verdana 24 bold",
font=("Verdana",24,"bold"))
        self.txt.grid(row=8,column=1)

if __name__ == '__main__':
    root = Tk()
    c = MyFrame(root)
    c.pack(fill=BOTH, expand=1)
    root.mainloop()

any help?

Regards,
VGNU
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20101103/ce2e0c3f/attachment.html>


More information about the Python-list mailing list