Add action to toolbar buttons : ToolBar « GUI Tk « Python






Add action to toolbar buttons

from Tkinter import *

root = Tk()

def callback():
    print "called the callback!"


toolbar = Frame(root)  # create a toolbar

b = Button(toolbar, text="new", width=6, command=callback)
b.pack(side=LEFT, padx=2, pady=2)

b = Button(toolbar, text="open", width=6, command=callback)
b.pack(side=LEFT, padx=2, pady=2)

toolbar.pack(side=TOP, fill=X)

mainloop()


           
       








Related examples in the same category

1.Creating a simple toolbarCreating a simple toolbar