Hi everyone,

I'm new in this forum.
By the way it's not longtime since I started learning python. After a couple o months of studying and tutorialing I'm now nearly finished with my first application.
I've used Tkinter as GUI and there's one thing that's making me nervous: I want to create a sort of toolbar but can't align the button widget one beside the other using the grid method.
I've already tried to place them in different cells and that works but it doesn't really give the feel of a toolbar as there's space between the buttons.
So I tried this way using one single cell and placing the buttons inside, but the always form in rows when I launch the application (see attachment)..

Any advice to solve this problem?

Thank you very much

Gab

This is just an excerpt


frameToolbar = Frame(master, bd=0, bg="white", relief=SUNKEN)
frameToolbar.grid(column=0, row=0, columnspan=10, sticky=NW)
######################################################################################################################################

self.button2 = Button(frameToolbar, text="PRINT", bg="light green", width=5, relief=RAISED, font=("Verdana", "9", "bold"), command=self.print_)
self.button2.grid(sticky=NW)

self.button = Button(frameToolbar, text="CLOSE", bg="red", width=5, relief=RAISED, font=("Verdana", "9", "bold"), command=self.destrparent)
self.button.grid(sticky=NW)

self.button1 = Button(frameToolbar, text="SUM", bg="light blue", width=5, relief=RAISED, font=("Verdana", "9", "bold"), command=self.mult)
self.button1.grid(sticky=NW)

Use something like this:

self.button2 = Button(frameToolbar, text="PRINT", bg="light green", width=5, 
    relief=RAISED, font=("Verdana", "9", "bold"), command=self.print_)
self.button2.grid(row=0, column=0) 

self.button = Button(frameToolbar, text="CLOSE", bg="red", width=5, 
    relief=RAISED, font=("Verdana", "9", "bold"), command=self.destrparent)
self.button.grid(row=0, column=1) 

self.button1 = Button(frameToolbar, text="SUM", bg="light blue", width=5, 
    relief=RAISED, font=("Verdana", "9", "bold"), command=self.mult)
self.button1.grid(row=0, column=2)

Please use code tags -->
[code=python]
your Python code here

[/code]

Thank you so much for your help, that perfectly do what I need.
For some reason it haven't come to my mind to use the "row/column" setting directly on the widget. I did assume they were only to arrange Frame widgets not also other widgets..

I will keep in mind the format for code posting.
Thank you so much!


Gab

Be a part of the DaniWeb community

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