I am having problems with redrawing a gridSizer.
Right now my frame is split up into two parts with two sizers. The bottom sizer
is split up into 3 parts horizontaly. The gridSizer is in the center. The gridSizer
is 3x3 and made up of bitmaps. Right now the gridSizer gets layered, when it is redrawn after the center bitmap changes, along with the rest of the frame.
The problem with having the frame just layer on top of itself over and over again is that every time i move the center bitmap with the arrow keys it shows me the previous layers. I think destroying the gridSizer and redrawing just the gridSizer would be ideal for the situation and i would appreciate it if someone showed me how to, but any other solutions are more than welcome.
The code snippets involve are the following:
#refresh function
self.gridSizer = wxGridSizer(3, 3, 2, 2) # rows, cols, hgap, vgap
self.gridSizer.AddMany([ (wxStaticBitmap(self, 1010, wxBitmap(self.blanksquare, wxBITMAP_TYPE_BMP)), 0, wxEXPAND),
(wxStaticBitmap(self, 1010, wxBitmap(self.blanksquare, wxBITMAP_TYPE_BMP)), 0, wxEXPAND),
(wxStaticBitmap(self, 1010, wxBitmap(self.blanksquare, wxBITMAP_TYPE_BMP)), 0, wxEXPAND),
(wxStaticBitmap(self, 1010, wxBitmap(self.blanksquare, wxBITMAP_TYPE_BMP)), 0, wxEXPAND),
(wxStaticBitmap(self, 1010, wxBitmap(self.center, wxBITMAP_TYPE_BMP)), 0, wxEXPAND), #center
(wxStaticBitmap(self, 1010, wxBitmap(self.blanksquare, wxBITMAP_TYPE_BMP)), 0, wxEXPAND),
(wxStaticBitmap(self, 1010, wxBitmap(self.blanksquare, wxBITMAP_TYPE_BMP)), 0, wxEXPAND),
(wxStaticBitmap(self, 1010, wxBitmap(self.blanksquare, wxBITMAP_TYPE_BMP)), 0, wxEXPAND),
(wxStaticBitmap(self, 1010, wxBitmap(self.blanksquare, wxBITMAP_TYPE_BMP)), 0, wxEXPAND),
])
self.topSizer = wxBoxSizer(wxVERTICAL) #Box that covers entire area
self.threebox = wxBoxSizer(wxHORIZONTAL) #box that holds 2 boxes
self.threebox.Add(self.statPanel, 1, wxEXPAND) #first box in Box2
self.threebox.Add(self.gridSizer, 1.5, wxEXPAND) #2nd box in Box2
self.threebox.Add(self.miscPanel, 1, wxEXPAND)
self.topSizer.Add(self.textPanel, 3.5, wxEXPAND) #assignment of other box
self.topSizer.Add(self.threebox, 2, wxEXPAND) #assignment of box that holds 2 boxes
self.SetAutoLayout(true)
self.SetSizer(self.topSizer)
self.Layout()
#and also what calls the refresh
def onKeyEvent(self, event):
""" Respond to a keypress event.
We make the arrow keys move the selected object(s) by one pixel in
the given direction.
"""
if event.GetKeyCode() == WXK_UP:
print "up"
self.center = self.north
self.refresh()
elif event.GetKeyCode() == WXK_DOWN:
print "down"
self.center = self.south
self.refresh()
elif event.GetKeyCode() == WXK_LEFT:
print "left"
self.center = self.west
self.refresh()
elif event.GetKeyCode() == WXK_RIGHT:
print "right"
self.center = self.east
self.refresh()
Thank you for your time.
···
_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963