Welcome~~~


Another blog:
http://fun-st.blogspot.com/

It is easier to write an incorrect program than understand a correct one.

Wednesday, June 22, 2011

python histogram one-liner - Stack Overflow

python histogram one-liner - Stack Overflow

Thursday, June 9, 2011

Advanced WxPython Nuts and Bolts Presentation

Advanced WxPython Nuts and Bolts Presentation

wxPython-users - PyNoAppError: The wx.App object must be created first!

wxPython-users - PyNoAppError: The wx.App object must be created first!

PyNoAppError when coding wxpython in IDEL (ubuntu)

When Using the wxpython, Ubuntu, and IDEL, sometimes, I have the following problem:

PyNoAppError: The wx.App object must be created first!

Check about this, and it seems that IDEL (since it's build on wx...) has some conflict when using wxpython. I tried Drpython, which seems good for now. 


--

♥ ¸¸.•*¨*•♫♪♪♫•*¨*•.¸¸♥
"Stay hungry, stay foolish" -  Steve Jobs

Wednesday, June 8, 2011

About the wxPython: Exit, Destroy, Close


Robin Dunn wrote:

I assume that by "Exit" here you are still talking about the menu item above.

No, I was referring to wx.Exit, which I think is a global call.

It is a way to forcibly kill the app, without any opportunity for the application objects to clean up after themselves. Most of the time you wouldn't want to use it.

You use Close() when you want to programatically tell the frame to go close itself, and is functionally the same as the user telling it to close itself with the "X" button.

Destroy() tells wx to delete the C++ object instance that corresponds to the frame. Normally it will destroy itself when it closes in the default EVT_CLOSE event handler, but if you catch the EVT_CLOSE yourself you either need to call Destroy in your handler, or call event.Skip so the default handler will still run. The EVT_CLOSE handler is where you would normally put the code that checks for open files, asks the user if she wants to save them or cancel, etc. Based on the user's response you can veto the close if you want.

I don't understand. So Close() does nothing more than make the window disappear?

No, it tells the window to close itself. That is a lot different than just hiding it.

Does Close() then automatically call Destroy()?

No, Close causes a EVT_CLOSE event to be sent. The default handler for that event calls Destroy().

What happens if I catch the wx.EVT_CLOSE event and make it call self.frame.Close()?

Then you'll get an endless loop.

Does it get destroyed also, or is the application still running somehow?

According to you and Andrea, I think this is what I need:

self.frame.Bind(wx.EVT_CLOSE, self.OnExitApp)

def OnExitApp(self, event): self.frame.Destroy()

Right? Or do I just use Close() still?

You use Close() from your menu event handler, or wherever you want to programatically cause the frame to be closed. You only need to provide a handler for EVT_CLOSE if you want to have more control over the closing of the frame than the default automatic destroy.

Friday, June 3, 2011

Thursday, June 2, 2011

Limit the border size on a matplotlib graph

fig = pylab.figure()
ax_size = [0,0,1,1]
ax = fig.add_axes(ax_size)
ax.scatter(x[showd[0],:]-min(x[showd[0],:]),x[showd[1],:]-min(x[showd[1],:]),s=50,c=tc,cmap=pylab.cm.jet)