Display problem with controls in a toolbar

(wxPython 2.4.2.4, Windows 2000)

  Hello,

I'm playing with the ToolBar demo. In this demo, the toolbar is
associated with the frame (self.CreateToolBar). What I'd like to do is
to have the toolbar as a child of the frame. In order to do that, I
slightly modified the source to have the toolbar on a panel. Everything
works great but the controls in the toolbar are hidden (not repainted
correctly?) when I slowly move the frame out of the screen. The icons
behave normally. What am I missing? Thanks in advance.

Here is the source:

from wxPython.wx import *
import images

···

#-----------------------------------------------------------------------
----
wxInitAllImageHandlers()

class TestToolBar(wxFrame):
    def __init__(self, parent=None, log=None):
        wxFrame.__init__(self, parent, -1, 'Test ToolBar', size=(500,
300))
        self.timer = None
        EVT_CLOSE(self, self.OnCloseWindow)

        self.SetBackgroundColour(wxNamedColour("WHITE"))

## tb = self.CreateToolBar( wxTB_HORIZONTAL
## | wxNO_BORDER
## | wxTB_FLAT
## | wxTB_TEXT
## )
        p = Panel(self)
        vsizer = wxBoxSizer(wxVERTICAL)
        p.SetSizer(vsizer)
        
        tb = wxToolBar(p, -1, wxDefaultPosition, wxDefaultSize,
                       style = wxTB_HORIZONTAL | wxNO_BORDER |
wxTB_FLAT)
## self.SetToolBar(tb)

        tb.AddSimpleTool(10, images.getNewBitmap(), "New", "Long help
for 'New'")
        #tb.AddLabelTool(10, "New", images.getNewBitmap(),
shortHelp="New", longHelp="Long help for 'New'")
        EVT_TOOL(self, 10, self.OnToolClick)
        EVT_TOOL_RCLICKED(self, 10, self.OnToolRClick)

        tb.AddSimpleTool(20, images.getOpenBitmap(), "Open", "Long help
for 'Open'")
        EVT_TOOL(self, 20, self.OnToolClick)
        EVT_TOOL_RCLICKED(self, 20, self.OnToolRClick)

        tb.AddSeparator()
        tb.AddSimpleTool(30, images.getCopyBitmap(), "Copy", "Long help
for 'Copy'")
        EVT_TOOL(self, 30, self.OnToolClick)
        EVT_TOOL_RCLICKED(self, 30, self.OnToolRClick)

        tb.AddSimpleTool(40, images.getPasteBitmap(), "Paste", "Long
help for 'Paste'")
        EVT_TOOL(self, 40, self.OnToolClick)
        EVT_TOOL_RCLICKED(self, 40, self.OnToolRClick)

        tb.AddSeparator()

        tool = tb.AddCheckTool(50, images.getTog1Bitmap(),
                               shortHelp="Toggle this")
        EVT_TOOL(self, 50, self.OnToolClick)

## tb.AddCheckTool(60, images.getTog1Bitmap(),
images.getTog2Bitmap(),
## shortHelp="Toggle with 2 bitmaps")
## EVT_TOOL(self, 60, self.OnToolClick)

        EVT_TOOL_ENTER(self, -1, self.OnToolEnter)
        EVT_TOOL_RCLICKED(self, -1, self.OnToolRClick) # Match all
        EVT_TIMER(self, -1, self.OnClearSB)

        tb.AddSeparator()
        cbID = wxNewId()
        control = wxComboBox(tb, cbID, "", choices=["", "This", "is a",
"wxComboBox"], size=(150,-1), style=wxCB_DROPDOWN)
        tb.AddControl(control)
        EVT_COMBOBOX(self, cbID, self.OnCombo)
        tb.AddControl(wxTextCtrl(tb, -1, "Toolbar controls!!",
size=(150, -1)))

        tb.Realize()
        vsizer.Add(tb, 1, wxEXPAND)
        
    def OnToolClick(self, event):
        tb = self.GetToolBar()
        tb.EnableTool(10, not tb.GetToolEnabled(10))

    def OnToolRClick(self, event):
        pass

    def OnCombo(self, event):
        pass

    def OnToolEnter(self, event):
        pass
        if self.timer is None:
            self.timer = wxTimer(self)
        if self.timer.IsRunning():
            self.timer.Stop()
        self.timer.Start(2000)
        event.Skip()

    def OnClearSB(self, event): # called for the timer event handler
        self.timer.Stop()
        self.timer = None

    def OnCloseWindow(self, event):
        if self.timer is not None:
            self.timer.Stop()
            self.timer = None
        self.Destroy()

class Panel(wxPanel):

    def __init__(self, parent):
        wxPanel.__init__(self, parent, -1)

#-----------------------------------------------------------------------
----
class MyApp(wxApp):

    def OnInit(self):
        win = TestToolBar()
        win.Show(True)
        return True
    
app = MyApp(0)
app.MainLoop()

M. Vernier wrote:

(wxPython 2.4.2.4, Windows 2000)

  Hello,

I'm playing with the ToolBar demo. In this demo, the toolbar is
associated with the frame (self.CreateToolBar). What I'd like to do is
to have the toolbar as a child of the frame. In order to do that, I
slightly modified the source to have the toolbar on a panel. Everything
works great but the controls in the toolbar are hidden (not repainted
correctly?) when I slowly move the frame out of the screen. The icons
behave normally. What am I missing? Thanks in advance.

The toolbar is drawing itself over the controls. Give it the wxCLIP_CHILDREN style to prevent this.

···

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

Robin may have given you an answer, but I've done what you're trying to do, and never needed wxCLIP_CHILDREN.

-- I couldn't run your example, because I don't have your images module

-- It's better to post an example as an attachment, and your mailer wraps lines, messing up the code

-- You have the toolbar in a sizer, on a panel, on the frame. YOu seem to have an extra layer here, unless you are intending to add more to that panel later, and just kept it out of this sample.

-- Take a look at my ample ion the Wiki:
http://wiki.wxpython.org/index.cgi/WorkingWithToolBars

and let me know if it doesn't work on your platform!

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov