Hello,

I am trying to create a container consisting of buttons with a single letter as a label on them to be used as an shortcut into a long alphabetized list of words.  The ButtonBox seemed a good widget for this purpose but I cannot get the look I want.  I want the buttons within the ButtonBox widget to be positioned much closer.  Right now I have something that looks like this:

'A   B   C'

When I want

'ABC' i.e., buttons shoulder to shoulder, so to speak

I've searched the various listservers but cannot find anything that shows if this can be done.  I've included code below which shows the work I've done so far.  I overrode the ButtonBox.insert method so I would have more control over the grid manager but it seemed to have made no difference.

Is there another, additional resource that can accomplish this effect?

Thanks!

mgo
-----
import Tkinter
import Pmw
class MyButtonBox(Pmw.ButtonBox):
    def __init__(self,parent,**kw):
        Pmw.ButtonBox.__init__(self,parent,**kw)

    def insert(self, componentName, beforeComponent = 0, **kw):
        if componentName in self.components():
            raise ValueError, 'button "%s" already exists' % componentName
        if not kw.has_key('text'):
            kw['text'] = componentName
        kw['default'] = 'normal'
        button = apply(self.createcomponent, (componentName,
                (), 'Button',
                Tkinter.Button, (self._buttonBoxFrame,)), kw)

        index = self.index(beforeComponent, 1)
        horizontal = self['orient'] == 'horizontal'
        numButtons = len(self._buttonList)

        # Shift buttons up one position.
        for i in range(numButtons - 1, index - 1, -1):
            widget = self._buttonList[i][1]
            pos = i * 2 + 3
            if horizontal:
                widget.grid(column = pos, row = 0)
            else:
                widget.grid(column = 0, row = pos)

        # Display the new button.
        if horizontal:
            print 'column=%d,gridcolumnconfigure=%d' % (index + 1,numButtons + 2)
            button.grid(column = index + 1, row = 0, sticky = 'ew',
                    padx = self['padx'], pady = self['pady'])
            self._buttonBoxFrame.grid_columnconfigure(
                    numButtons + 2, weight = 0)
        else:
            button.grid(column = 0, row = index * 2 + 1, sticky = 'ew',
                    padx = self['padx'], pady = self['pady'])
            self._buttonBoxFrame.grid_rowconfigure(
                    numButtons * 2 + 2, weight = 0)
        self._buttonList.insert(index, (componentName, button))
        return button

class Demo:
    def __init__(self,parent):
        self.buttonBox = MyButtonBox(parent,
                                     labelpos = 'nw',
                                     label_text = '',
                                     frame_borderwidth =0,
                                     padx=0,pady=0)

        # Add some buttons to the ButtonBox.
        w=self.buttonBox.add('A',highlightthickness=0,padx=0,pady=0,
                           borderwidth=1,height=0, width=0,command = self.ok)
        print w.grid_info()
        w=self.buttonBox.add('B',highlightthickness=0,padx=0,pady=0,
                           borderwidth=1,height=0, width=0,command = self.ok)
        print w.grid_info()
        w=self.buttonBox.add('C',highlightthickness=0,padx=0,pady=0,
                           borderwidth=1,height=0, width=0,command = self.ok)
        print w.grid_info()

        self.buttonBox.pack()
        parent.focus_set()

    def ok(self):
        print 'You clicked on OK'

if __name__ == '__main__':
    root = Tkinter.Tk()
    Pmw.initialise(root)
    root.title('Squeeze together please')
    exitButton = Tkinter.Button(root, text = 'Exit', command = root.destroy)
    exitButton.pack(side = 'bottom')

    widget = Demo(root)
    root.mainloop()