Dialog's Showmodal() Won't Send Evt_paint
Solution 1:
You've bound your paint event handler to the dialog, but the dialog has a panel that completely covers the dialog. Since the dialog's surface is never exposed (because it is under the panel) then it never needs painted, so it never recieves a paint event from the system.
In most cases you do not need a panel as the top element in a dialog, so you may want to remove it and replace all the self.panel
in that part of the code with just self
.
Solution 2:
Following the hint on Drawing To Panel Inside of Frame:
I got wrong the bind of the Paint Event
self.panel.Bind(wx.EVT_PAINT, self.OnPaint) self.panel.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
For some reason I still don't fully get (examples at self.Bind vs self.button.Bind) why the panel won't
Skip()
the Paint Event; leading toself
never getting aware of the Paint Event.And the parenthood of the canvas:
dc = wx.BufferedPaintDC(self.panel)
After playing a little bit subclassing from
wx.PopupWindow
(which resulted in a badly sized Window that I couldn't properly center in the frame) I realized that the DC was being rendered below the panel. It makes sence sinceself.panel
is a child ofself
, so onlyself
was being painted.
Not an Error but on the Paint Event, it seems the panel or dialog gets back to their default size. If the panel is fit, the dialog is resized, and the window is centered again in the Paint Event, then new Paint Events will be raised and a flicker will appear. Since this is an parameterized static dialog, the dimensions can be fixed with this at the end of self._layout()
:
self.panel.Fit()
minSize = self.panel.GetSize()
self.SetMinSize(minSize)
self.SetMaxSize(minSize)
Post a Comment for "Dialog's Showmodal() Won't Send Evt_paint"