Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

How to plot line in a panel embedded in a frame using wxPython?

30 views
Skip to first unread message

Ibraheem Khan

unread,
Feb 18, 2015, 1:50:47 AM2/18/15
to wxpytho...@googlegroups.com
I have a frame with an embedded panel and want to draw line plot in it (using example) but not getting there. Any suggestions would be appreciative. Script is attached.
frame_panel_plot.py

Tim Roberts

unread,
Feb 18, 2015, 12:35:58 PM2/18/15
to wxpytho...@googlegroups.com
Ibraheem Khan wrote:
I have a frame with an embedded panel and want to draw line plot in it (using example) but not getting there. Any suggestions would be appreciative.

It would have been a lot easier to help you if you had included a complete example.  What you sent was fairly confused, and it's not clear whether the confusion is innate or just because of the code you omitted.

However, there are some things that stand out.  You say you have an embedded panel, but there are no panels here.  If you meant for there to be a panel instead of the Plot frame window, then you should create a panel in Plot.__init__.

Plus, look at LinePlot.  This is declared as being derived from wx.Frame, but you never call wx.Frame.__init__.  Instead, you create a brand new wx.Frame and do things with it.  Thus, LinePlot never gets properly initialized.

Why don't you describe what you were trying to do, in detail, and perhaps we can direct you to an implementation?
-- 
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.

Ibraheem Khan

unread,
Feb 18, 2015, 2:48:35 PM2/18/15
to wxpytho...@googlegroups.com
Ah, i realize my question is confusing. I have a dialog box with a button (and some other buttons) to plot a line. Once I click 'Plot' button then I want to get a line plot in a frame/panel. The main thing here is to have a panel or even a frame embedded in a main frame which is opened upon clicking a button to show a line plot. Please let me know if questions is clear now.

--
You received this message because you are subscribed to a topic in the Google Groups "wxPython-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/wxpython-users/mEmiQbWadis/unsubscribe.
To unsubscribe from this group and all its topics, send an email to wxpython-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tim Roberts

unread,
Feb 21, 2015, 1:50:45 PM2/21/15
to wxpytho...@googlegroups.com
On Feb 18, 2015, at 11:48 AM, Ibraheem Khan <ibrahee...@gmail.com> wrote:
>
> Ah, i realize my question is confusing. I have a dialog box with a button (and some other buttons) to plot a line. Once I click 'Plot' button then I want to get a line plot in a frame/panel. The main thing here is to have a panel or even a frame embedded in a main frame which is opened upon clicking a button to show a line plot. Please let me know if questions is clear now.

So, you have a wx.Dialog, and clicking a button in that dialog should bring up a separate wx.Frame, which should contain a wx.Panel, and you want to do drawing in that panel. Is that the principle?

That’s not quite what you are doing. You need to create a class derived from wx.Frame, and that class should call wx.Frame.__init__. That brings up an empty window. You might want to do just that, to prove that it works. Then, you can add a wx.Panel in that frame. Then, you can do your drawing.

You do have to think about timing for a bit, especially if you plan on drawing directly to the panel. Remember that the window does not actually exist yet during __init__. The initialization process sends messages that will eventually make the window visible. If you intend to do manual drawing, you’ll have to do that in an EVT_PAINT handler or using CallAfter.

Reply all
Reply to author
Forward
0 new messages