Radiobuttons demonstration set Font in Text,,from Tkinter
Radiobuttons demonstration set Font in Text,,from Tkinter
from Tkinter import *class RadioFont( Frame ): def __init__( self ): Frame.__init__( self ) self.pack( expand = YES, fill = BOTH ) self.master.title( 'Radiobutton Demo' ) self.frame1 = Frame( self ) self.frame1.pack() self.text = Entry( self.frame1, width = 40, font = 'Arial 10' ) self.text.insert( INSERT, 'Font Font Font' ) self.text.pack( padx = 5, pady = 5 ) self.frame2 = Frame( self ) self.frame2.pack() fontSelections = [ 'Plain', 'Bold', 'Italic', 'Bold/Italic' ] self.chosenFont = StringVar() self.chosenFont.set( fontSelections[ 0 ] ) for style in fontSelections: aButton = Radiobutton( self.frame2, text = style, variable = self.chosenFont, value = style, command = self.changeFont ) aButton.pack( side = LEFT, padx = 5, pady = 5 ) def changeFont( self ): desiredFont = 'Arial 10' if self.chosenFont.get() == 'Bold': desiredFont += ' bold' elif self.chosenFont.get() == 'Italic': desiredFont += ' italic' elif self.chosenFont.get() == 'Bold/Italic': desiredFont += ' bold italic' self.text.config( font = desiredFont )def main(): RadioFont().mainloop()if __name__ == '__main__': main()
- Storing Non-ASCII Characters,storingnon-ascii,s = u'La
- List Comprehensions in buildConnectionString, Step by St
- deque() object: faster appends and pops from the left si
- Use else in exception handle,exceptionhandle,import sy
- Add new entry to a dictionary,entrydictionary,d2 = {'s
- Output Formatting: repr,formattingrepr,#The repr mo
热门文章:
相关内容
- Storing Non-ASCII Characters,storingnon-ascii,s = u'La Pe\
- List Comprehensions in buildConnectionString, Step by Step,,params
- deque() object: faster appends and pops from the left side but slower
- Use else in exception handle,exceptionhandle,import sysfo
- Add new entry to a dictionary,entrydictionary,d2 = {'spam'
- Output Formatting: repr,formattingrepr,#The repr mo
- Variables in a list,variablesinlist,X = [1, 2, 3
- List insert(i, x),listinsert,#Insert an i
- More than one format in the string,formatstring,#If there is
- Find symbolic links and show where they point to,symboliclinks,'''P
评论关闭