Check box menu

Submitted by:Jhon Smith

Date added:04 July, 2011

Category:Python

Here are the Python code Checkbox menu

Tags: checkbox

Code Snippet:

from Tkinter import *

class TestMenu:
def __init__(self, master):
self.master = master
self.menubar = Menu(self.master)

self.chkmenu = Menu(self.menubar)
self.chkmenu.add_checkbutton(label='A')
self.chkmenu.add_checkbutton(label='B')
self.chkmenu.add_checkbutton(label="C")
self.chkmenu.add_checkbutton(label='D')
self.chkmenu.add_checkbutton(label='E')
self.chkmenu.invoke(self.chkmenu.index('C'))

self.menubar.add_cascade(label="Checkbutton Menu", menu=self.chkmenu)

self.top = Toplevel(menu=self.menubar, width=500, relief=RAISED,
borderwidth=2)

def main():
root = Tk()
root.withdraw()
app = TestMenu(root)
root.mainloop()

if __name__ == '__main__':
main()
 
 

Comments