how to add a seperating line between menubar and toolbar in Python using Tkinter. is that possible using Tkinter. also how to add vertical seperating line to seperate toolbar buttons in toolbar.

please help me out from this problem.

11 Years
Discussion Span
Last Post by katharnakh

The toolbar in Tkinter is usually a frame with buttons added below the menubar. Depending how you configure the frame there should be a visible separation. If you want to separate the toolbar, you could use two frames properly packed. Here is an example ...

# the toolbar is a frame with buttons and is usally put right below the menubar

from Tkinter import *

def callback(what=None):
    print "callback =", what
    if what == 'red':
    if what == 'blue':

class Curry:
    """handles arguments for callback functions"""
    def __init__(self, callback, *args, **kwargs):
        self.callback = callback
        self.args = args
        self.kwargs = kwargs

    def __call__(self):
        return apply(self.callback, self.args, self.kwargs)

root = Tk()

# create the menubar
menubar = Menu(root)

filemenu = Menu(menubar)
filemenu.add_command(label="Open", command=Curry(callback, "open"))
filemenu.add_command(label="Save", command=Curry(callback, "save"))
filemenu.add_command(label="Save as", command=Curry(callback, "saveas"))
filemenu.add_command(label="Quit", command=root.destroy)  # better than root.quit (at least in IDLE)

menubar.add_cascade(label="File", menu=filemenu)


# create a toolbar with two buttons
# use Frame(root, borderwidth=2, relief='raised') for more separation
toolbar = Frame(root)

b1 = Button(toolbar, text="red", width=6, command=Curry(callback, "red"))
b1.pack(side=LEFT, padx=2, pady=2)
b2 = Button(toolbar, text="blue", width=6, command=Curry(callback, "blue"))
b2.pack(side=LEFT, padx=2, pady=2)

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


Edited by vegaseat: fixed code tags, old php tags stopped working


thank u.. i appreciate ur helping nature.... thank u. i might need more help in the future too. about the GUI of Python, so help me . thank u.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.