4834_lecture_25_ho

4834_lecture_25_ho - EEL 4834: Lecture 25 EEL 4834: Lecture...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: EEL 4834: Lecture 25 EEL 4834: Lecture 25 GUI Programming 4 Professor O. Boykin University of Florida, Department of Electrical and Computer Engineering October 29, 2009 EEL 4834: Lecture 25 Widgets Radio Button Radio buttons allow you to select one of a few options. Clicking one unclicks the others. Radio buttons share a single StringVar The value stored in the StringVar is set by the value option in the Radiobutton constructor. To initialize a button, set the variable to the value of the button. EEL 4834: Lecture 25 Widgets #!/usr/bin/env python import Tkinter as TK root = TK.Tk(); root.title( radio ) frame = TK.Frame() frame.pack() label = TK.Label(frame, text= Tk radio buttons: ) label.pack() var = TK.StringVar() #var.set(radiobutton no. 1) var.set( none set in this case ) def update radio(): print var.get() for radio in range(4): r = TK.Radiobutton(frame, text=( radio%i % radio), variable=var, value = ( radiobutton no. %i % radio), command = update radio) r.pack(side= left ) root.mainloop() EEL 4834: Lecture 25 Widgets Multiple sets of Radio buttons To add multiple sets of radio buttons, just create new buttons tied to a different variable. EEL 4834: Lecture 25 Widgets #!/usr/bin/env python import Tkinter as TK root = TK.Tk(); root.title( radio ) frame = TK.Frame(root) frame.pack() label = TK.Label(frame, text= Tk radio buttons: ) label.pack() var = TK.StringVar() var.set( radiobutton no. 0 ) #initialize def update radio(): print var.get() for radio in range(4): r = TK.Radiobutton(frame, text=( radio%i % radio), variable=var, value = ( radiobutton no. %i % radio), command = update radio) r.pack(side= left ) #second set: frame2 = TK.Frame(root) frame2.pack() var2 = TK.StringVar() def update radio2(): print var2.get() for radio in range(4): r = TK.Radiobutton(frame2, text=( radio2%i % radio), variable=var2, value = ( radiobutton2 no. %i % radio), command = update radio2) r.pack(side= left ) root.mainloop() EEL 4834: Lecture 25...
View Full Document

This note was uploaded on 02/11/2010 for the course EEL 4834 taught by Professor Staff during the Fall '08 term at University of Florida.

Page1 / 10

4834_lecture_25_ho - EEL 4834: Lecture 25 EEL 4834: Lecture...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online