How can I put 2 buttons with images Vertically in a frame

156 views Asked by At

Im using tkinter and trying to create a toolbar located on the left side going vertically, I already have a toolbar on the top of the frame filled in going horizontaly however can't figure out how to make a second one on the left, with all the buttons.

This is the code that I have:

    infobar = Frame(master, bg="#ecf0f1", bd=1, relief=GROOVE)
    infobar.pack(side=LEFT, fill=BOTH, expand=None)
    infobarr = Label(toolbar, bg="#ecf0f1", text='           ')
    infobarr.pack(side=LEFT, fill=Y)     
    poundToKgButton = Button(infobar, highlightbackground="#ecf0f1", image=eimg20, relief=FLAT, command=self.scale)
    poundToKgButton.image = eimg20
    createToolTip(poundToKgButton, "Conversion - Pound To KG")
    poundToKgButton.pack(side=LEFT)       
    calculatorButton = Button(infobar, highlightbackground="#ecf0f1", image=eimg19, bd=1, relief=FLAT, command=self.calc)
    calculatorButton.image = eimg19
    createToolTip(calculatorButton, "Calculator")
    calculatorButton.pack(side=LEFT, anchor="sw")
1

There are 1 answers

0
Bryan Oakley On BEST ANSWER

Use side=TOP if you want things stacked vertically. The containing widget has empty space. When you use pack, you're telling tkinter which side of that empty space to put the widget.

Here is a good example of exactly what happens when you call pack: http://tcl.tk/man/tcl8.5/TkCmd/pack.htm#M26