How do I resize a control within a toolbar?

Hi folks,

I have a combobox inside a toolbar. when I resize the main application window, I would like to resize the combobox as well. ( this is a feature we can see in browsers, e.g. location bar)
the first step is to hook the EVT_SIZE event.

but how do I actually resize the combobox? As far as I know, sizers cannot be used with a toolbar. How do I accomplish this? Is it possible?
I already did a workaround by creating my own toolbar from a panel, but I would like to know if/how it is possible to do with a wx.TooBar widget.

thanks,

jan bodnar

here is some code

#!/usr/bin/python

import wx

class MyFrame(wx.Frame):
def init(self, parent, id, title):

    wx.Frame.__init__(self, parent, id, title, size=(450, 400))

    tb = self.CreateToolBar(wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_FLAT | wx.TB_TEXT)
    self.tb = tb
    self.cb = wx.ComboBox

(tb, 1, size=(250, -1))
tb.AddControl(self.cb)
tb.Realize()

    self.Bind(wx.EVT_SIZE, self.OnSize)

    self.Centre()
    self.Show(True)

def OnSize(self, event):

    x, y = self.GetSize()

    self.cb.SetSize((int(x/1.8), y))

    #self.cb.Show()
    #self.cb.Layout()
    #self.cb.Refresh()
    #self.tb.Layout()
    #self.tb.Realize()

app = wx.App(0)
MyFrame(None, -1, ‘’)
app.MainLoop()

vronskij wrote:

Hi folks,

I have a combobox inside a toolbar. when I resize the main application window, I would like to resize the combobox as well. ( this is a feature we can see in browsers, e.g. location bar)
the first step is to hook the EVT_SIZE event.

but how do I actually resize the combobox? As far as I know, sizers cannot be used with a toolbar. How do I accomplish this? Is it possible?
I already did a workaround by creating my own toolbar from a panel, but I would like to know if/how it is possible to do with a wx.TooBar widget.

No, our current toolbar API doesn't allow for controls to do any resizing.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!