Checkbuttons demonstration: set font,,from Tkinter
文章由Byrx.net分享于2019-03-23 06:03:33
Checkbuttons demonstration: set font,,from Tkinter
from Tkinter import *class CheckFont( Frame ): def __init__( self ): Frame.__init__( self ) self.pack( expand = YES, fill = BOTH ) self.master.title( 'Checkbutton Demo' ) self.frame1 = Frame( self ) self.frame1.pack() self.text = Entry( self.frame1, width = 40, font = 'Arial 10' ) self.text.insert( INSERT, 'font style' ) self.text.pack( padx = 5, pady = 5 ) self.frame2 = Frame( self ) self.frame2.pack() # create boolean variable self.italicOn = BooleanVar() # create 'Italic' checkbutton self.checkItalic = Checkbutton( self.frame2, text = 'Italic', variable = self.italicOn, command = self.changeFont ) self.checkItalic.pack( side = LEFT, padx = 5, pady = 5 ) def changeFont( self ): desiredFont = 'Arial 10' if self.italicOn.get(): desiredFont += ' italic' self.text.config( font = desiredFont )def main(): CheckFont().mainloop()if __name__ == '__main__': main()
相关内容
- Using Python as a Calculator,pythoncalculator,print 2+2# T
- Compare two strings,comparetwostrings,guess = 'a'c
- List equivalent?, same object?,equivalentobject,L1 = [1, ('a
- Complex Numbers: two complex numbers,complexnumberstwo,print 1j * 1
- Mathematics: cos,mathematicscos,import mathp
- print command,print,print 'HI'ra
- Print out dashes in an easy way,dasheseasy,print '-'*80
- Use print as c printf: %s,printf%s,exclamation
- Make a copy of a directory tree with symbolic links to all files in t
- Loop through header information in a ZIP file,loopheader,import str
评论关闭