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.

Recommended Answers

not too sure what you meant mate but has a great documentation for Tkinter, here's a link to a page on the site that may or may not help you:

Jump to Post

All 3 Replies

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)


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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.