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

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 (1.07 KB)

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?

···

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.

-- Tim Roberts, Providenza & Boekelheide, Inc.

timr@probo.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.

···

On Wed, Feb 18, 2015 at 12:35 PM, Tim Roberts timr@probo.com wrote:

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.

-- Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
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?

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-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

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.

···

On Feb 18, 2015, at 11:48 AM, Ibraheem Khan <ibraheem.khan99@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.


Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.