I'm using WinXP, wxPython 2.4.2.4, and Python 2.3.
(Well, at the moment, since I'm having problem with McMillan installer I might change these.)
Actually I'm really new when it comes to GUI programming so I would tend to assume it is my design problem. I have no idea how to perperly structure all these widgets and panels. And good design like MVC is just beyond me. Python Demo and a couple of wxPython tutorials are all my mentors as far as GUI programming goes.
This is how I structure it.
Frame--Panel--Notebook--(via AddPage())--Panel1--ListPanel1--ListCtrl
> >
> >--PlotWindows(wxScrolledWindow)
> > >
> > >--PlotCanvas
> >
> >--SubPanel
>
>-(via AddPage())--Panel2--ListPanel2--ListCtrl
>
>--PlotWindows(wxScrolledWindow)
> >
> >--PlotCanvas
>
>--SubPanel
Note:
* The line means, for example, PlotWindows, a child class of wxScrolledWindow, is declared inside Panel1 and (usually also means that it) has Panel1 as its parent.
* The PlotCanvas is from wxPyPlot.
So the notebook, Panel1 and Panel2 are coded like this:
self.notebook = wxNotebook(self, -1, wxDefaultPosition, wxDefaultSize)
self.itp = Panel1(self, -1)
self.notebook.AddPage(self.itp, "Tab1")
self.ptp = Panel2(self, -1)
self.notebook.AddPage(self.ptp, "Tab2")
Question1: What does it mean to put a wxPanel in a notebook?
Question2: I currently have PlotCanvas lay way inside a chain of panels. But it seems to expect its parent to be a frame. So what I did was I had a parent reference along each of these class, and PlotWindows just gave PlotCanvas a reference to the main frame of the application. i.e. self.parent.parent.parent... (ok no I did not do that, I hacked PlotCanvas instead.) It seems a bit messy. Is that a correct way to do it?
Question3: The frame has a print menu item, print preview that I want to it to be disabled when there is no plot. The function to do that is self._enablePrintCtrls() inside the Frame. When user select proper item and press the Plot button, Panel1 or Panel2's self.OnPlot() will be called. It needs to tell the frame to enable those menu items. So I have in self.OnPlot() something like "self.parent.parent._enablePrintCtrls()" to access the Frame's member function. Is that a good way to do it? Again it seems like the self.parent.parent is messy.
I probably need a guideline or tutorials on the issue, any reference would be appreciated. Thanks.
Timothy
Robin Dunn wrote:
···
Is this with wxGTK? If so there is an old bug that nobody knows how to fix yet that is causing this and any custom control derived from wxScrolledWindow (on wxGTK that's wxListCtrl, wxTreeCtrl, wxHtmlWIndow, etc.) has the same problem. The workaround is to put a wxPanel in the notebook and then put your listctrl on that panel, giving it a sizer or something to resize the listctrl to entirely cover the panel.