[Tutor] Question about the FONT in Tkinter
Mohannad Mohammad
mohannadmohammad at hotmail.com
Sat Aug 1 18:12:49 CEST 2009
Hello all,
Kindly refer to the attached photo.
There are two sentences appearing when the user checked two checkbutton, I make it as a practice.
ok
I want to change the font of these two sentences. how?
This is the code I use to make this simple application:
from Tkinter import *
class Application(Frame):
def __init__(self, master):
Frame.__init__(self, master)
self.grid()
self.create_widgets()
self.font = ("tahoma", 10)
def create_widgets(self):
self.lbl1 = Label(self, text = "Choose your favorite movie types")
self.lbl1.grid(row = 0, column = 0, columnspan = 2, sticky = W)
self.lbl2 = Label(self, text = "Select all that apply:")
self.lbl2.grid(row = 1, column = 0, columnspan = 2, sticky = W)
self.likes_drama = BooleanVar()
Checkbutton(self, text = "Drama", variable = self.likes_drama, command = self.update_text).grid(row = 2, column = 0, sticky = W)
self.likes_comedy = BooleanVar()
Checkbutton(self, text = "Comedy", variable = self.likes_comedy, command = self.update_text).grid(row = 3, column = 0, sticky = W)
self.likes_sport = BooleanVar()
Checkbutton(self, text = "Sport", variable = self.likes_sport, command = self.update_text).grid(row = 4, column = 0, sticky = W)
self.box = Text(self, width = 400, height = 10, wrap = WORD)
self.box.grid(row = 5, column = 0, columnspan = 2, sticky = W)
def update_text(self):
likes = ""
if self.likes_drama.get():
likes += "You like Drama movies\n"
if self.likes_comedy.get():
likes += "You like Comedy movies\n"
if self.likes_sport.get():
likes += "You like Sport movies\n"
self.box.delete(0.0, END)
self.box.insert(0.0, likes)
win = Tk()
win.title("Choose any one..")
win.geometry("400x300")
app = Application(win)
win.mainloop()
_________________________________________________________________
Celebrate a decade of Messenger with free winks, emoticons, display pics, and more.
http://clk.atdmt.com/UKM/go/157562755/direct/01/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090801/f083de06/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: font.gif
Type: image/gif
Size: 11429 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/tutor/attachments/20090801/f083de06/attachment-0001.gif>
More information about the Tutor
mailing list