'Close me' button

Have you looked into CallLater (wxPython API Documentation — wxPython Phoenix 4.2.2 documentation)? It’s a convenience wrapper around the timer that lets you simply declare a time and a callable; you could use this to open a window after your period of time has passed.

Good luck!

···

On Tuesday, June 12, 2012 12:58:48 PM UTC-7, dryhay wrote:

Hi

How to reopen MyMiniFrame (after hitting ‘Close me’ button) with a diffrent popup time?
Problem visualized: http://pasteall.org/pic/show.php?id=33111
The code: http://pastebin.com/xbXnvXkg

dryhay

Thank you for your answer, BUT unfortunately my code is still not working and showing no IDLE errors.

I’ve checked CallLater class according to: http://wiki.wxpython.org/Change%20wxGrid%20CheckBox%20with%20one%20click
and later some changes were made according to that: http://stackoverflow.com/questions/3856413/call-class-method-from-another-class
and other changes I’ve tried as well, but nothing is working so far…

My current code is here: http://codepad.org/n3H8FVoH
and target is still the same, but never reached: http://pasteall.org/pic/show.php?id=33111

dryhay

Have you tried using a wx.Timer object to open a new mini frame?

  • Mike
···

On Wednesday, June 13, 2012 6:35:40 AM UTC-5, dryhay wrote:

Thank you for your answer, BUT unfortunately my code is still not working and showing no IDLE errors.

I’ve checked CallLater class according to: http://wiki.wxpython.org/Change%20wxGrid%20CheckBox%20with%20one%20click
and later some changes were made according to that: http://stackoverflow.com/questions/3856413/call-class-method-from-another-class
and other changes I’ve tried as well, but nothing is working so far…

My current code is here: http://codepad.org/n3H8FVoH
and target is still the same, but never reached: http://pasteall.org/pic/show.php?id=33111

dryhay

I’ve tried that as well until my ideas finished. My first frame is opening with wx.Timer, but so far I can’t find any solution to bind ‘Close me’ button from this mini frame to open the same mini frame but after different time.

Hi,

···

On Wed, Jun 13, 2012 at 9:58 AM, dryhay <dryhay@gmail.com> wrote:

I've tried that as well until my ideas finished. My first frame is opening
with wx.Timer, but so far I can't find any solution to bind 'Close me'
button from this mini frame to open the same mini frame but after different
time.

Not a 100% clear on what your trying but if you just want to show the
same window again after a fixed time then just call Hide in the
handler for the 'Close me' button, start a timer and then call Show
again in the timer handler.

Cody

Hi
I don’t want to hide it. I want to close my mini frame and reopen later (with different values inside) 5000ms after clicking the button.
Maybe I have some problems to start a timer from this ‘Close me’ button or maybe python is loosing some data - I don’t know, I’m not so experienced to see it. This is what I want to learn - this code is only for testing and educational purposes.
What I want to get - problem visualized: http://pasteall.org/pic/show.php?id=33111
and this is my code: http://codepad.org/n3H8FVoH
I’ve just stuck there, trying different solutions, but I can’t move forward, because I don’t know how should a working solution look.

dryhay

Simplifying the problem, here’s a sample script with a frame that, when closed, re-opens a few seconds later.

Note that wxPython normally exits its main loop when the last frame is closed. To avoid this happening, I first open a unrelated frame (“Other Frame”). Since this stays open when the timer-close frame is closed, the program keeps running.

If you don’t have another frame that would stay open the whole time, you could either:

  • not really close and destroy the frame when onClose is called; instead, you could Hide() it and change the showFrame() to show it if it already exists

  • or, change the setting in wxPython so that it doesn’t quit when all windows are closed (there’s some setting for this, but I forget what it’s called)

  • or, slightly ugly, keep the code for “Other Frame” and remove the Show() line – there will still be a frame, but users won’t see it.

Code attached. Works for me on OSX/wx2.9.

frame.py (473 Bytes)

···

On Wednesday, June 13, 2012 9:33:26 AM UTC-7, dryhay wrote:

Hi
I don’t want to hide it. I want to close my mini frame and reopen later (with different values inside) 5000ms after clicking the button.
Maybe I have some problems to start a timer from this ‘Close me’ button or maybe python is loosing some data - I don’t know, I’m not so experienced to see it. This is what I want to learn - this code is only for testing and educational purposes.
What I want to get - problem visualized: http://pasteall.org/pic/show.php?id=33111
and this is my code: http://codepad.org/n3H8FVoH
I’ve just stuck there, trying different solutions, but I can’t move forward, because I don’t know how should a working solution look.

dryhay

wx.App.SetExitOnFrameDelete

···

On 6/13/12 10:28 AM, Joel Burton wrote:

- or, change the setting in wxPython so that it doesn't quit when all
windows are closed (there's some setting for this, but I forget what
it's called)

--
Robin Dunn
Software Craftsman

Thx, it helped me.
I’ve improved my script and I’ve fixed some problems, but I stuck on this one:

Traceback (most recent call last):
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/_misc.py”, line 1357, in Notify
self.notify()
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/_core.py”, line 14738, in Notify
self.result = self.callable(*self.args, **self.kwargs)
File “/home/dry/Dokumenty/pyt/37.py”, line 73, in showFrame
var_MyMiniFrame=MyMiniFrame(“Mini frame”, wx.ID_ANY, style=wx.DEFAULT_FRAME_STYLE | wx.TINY_CAPTION_HORIZ)
File “/home/dry/Dokumenty/pyt/37.py”, line 48, in init
wx.MiniFrame.init(self, parent, -1, title, pos, size, style)
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/_windows.py”, line 772, in init
windows.MiniFrame_swiginit(self,windows.new_MiniFrame(*args, **kwargs))
TypeError: in method ‘new_MiniFrame’, expected argument 1 of type ‘wxWindow *’

I’ve tried to fix it according to googled solutions, but nothing helps so far.

Target - problem visualized: http://pasteall.org/pic/show.php?id=33111
and this is my current code: http://codepad.org/4V1DVcTO

In your script, at:

var_MyMiniFrame=MyMiniFrame("Mini frame", wx.ID_ANY, style=wx.DEFAULT_FRAME_STYLE | wx.TINY_CAPTION_HORIZ)

You’re calling MyMiniFrame with the first argument being “Mini frame” (which I’m guessing you want to be the title of the frame).

But in the definition for your class, you have:

def __init__(self, parent, title, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE):
        # parent.y='two'
        wx.MiniFrame.__init__(self, parent, -1, title, pos, size, style)

So that first argument becomes "parent", not "title"--and the parent of a Frame (or MiniFrame) needs to be either a
Frame or None if it's a top-level frame.

- j.

···

On Wednesday, June 13, 2012 12:22:29 PM UTC-7, dryhay wrote:

Thx, it helped me.
I’ve improved my script and I’ve fixed some problems, but I stuck on this one:

Traceback (most recent call last):
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/_misc.py”, line 1357, in Notify
self.notify()
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/_core.py”, line 14738, in Notify
self.result = self.callable(*self.args, **self.kwargs)
File “/home/dry/Dokumenty/pyt/37.py”, line 73, in showFrame
var_MyMiniFrame=MyMiniFrame(“Mini frame”, wx.ID_ANY, style=wx.DEFAULT_FRAME_STYLE | wx.TINY_CAPTION_HORIZ)
File “/home/dry/Dokumenty/pyt/37.py”, line 48, in init
wx.MiniFrame.init(self, parent, -1, title, pos, size, style)
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/_windows.py”, line 772, in init
windows.MiniFrame_swiginit(self,windows.new_MiniFrame(*args, **kwargs))
TypeError: in method ‘new_MiniFrame’, expected argument 1 of type ‘wxWindow *’

I’ve tried to fix it according to googled solutions, but nothing helps so far.

Target - problem visualized: http://pasteall.org/pic/show.php?id=33111
and this is my current code: http://codepad.org/4V1DVcTO

Also: you’re also trying to pass the ID in your call to MyMiniFrame (the “wx.ID_ANY”), but your init signature doesn’t take an ID (when you call the superclass wx.MiniFrame.init, you use -1 as the ID).

···

On Wednesday, June 13, 2012 12:26:51 PM UTC-7, Joel Burton wrote:

In your script, at:

var_MyMiniFrame=MyMiniFrame("Mini frame", wx.ID_ANY, style=wx.DEFAULT_FRAME_STYLE | wx.TINY_CAPTION_HORIZ)

You’re calling MyMiniFrame with the first argument being “Mini frame” (which I’m guessing you want to be the title of the frame).

But in the definition for your class, you have:

def __init__(self, parent, title, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE):
        # parent.y='two'
        wx.MiniFrame.__init__(self, parent, -1, title, pos, size, style)


So that first argument becomes "parent", not "title"--and the parent of a Frame (or MiniFrame) needs to be either a
Frame or None if it's a top-level frame.


- j.


On Wednesday, June 13, 2012 12:22:29 PM UTC-7, dryhay wrote:

Thx, it helped me.
I’ve improved my script and I’ve fixed some problems, but I stuck on this one:

Traceback (most recent call last):
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/_misc.py”, line 1357, in Notify
self.notify()
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/_core.py”, line 14738, in Notify
self.result = self.callable(*self.args, **self.kwargs)
File “/home/dry/Dokumenty/pyt/37.py”, line 73, in showFrame
var_MyMiniFrame=MyMiniFrame(“Mini frame”, wx.ID_ANY, style=wx.DEFAULT_FRAME_STYLE | wx.TINY_CAPTION_HORIZ)
File “/home/dry/Dokumenty/pyt/37.py”, line 48, in init
wx.MiniFrame.init(self, parent, -1, title, pos, size, style)
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/_windows.py”, line 772, in init
windows.MiniFrame_swiginit(self,windows.new_MiniFrame(*args, **kwargs))
TypeError: in method ‘new_MiniFrame’, expected argument 1 of type ‘wxWindow *’

I’ve tried to fix it according to googled solutions, but nothing helps so far.

Target - problem visualized: http://pasteall.org/pic/show.php?id=33111
and this is my current code: http://codepad.org/4V1DVcTO

I’m trying and trying and trying every possible combination (because the first one is not working)…

When I do it step, by step starting from:

var_MyMiniFrame=MyMiniFrame("Mini frame", -1, style=wx.DEFAULT_FRAME_STYLE | wx.TINY_CAPTION_HORIZ)

So that first argument becomes “parent”

var_MyMiniFrame=MyMiniFrame(parent, "Mini frame", -1, style=wx.DEFAULT_FRAME_STYLE | wx.TINY_CAPTION_HORIZ)

and the parent of a Frame needs to be either Frame…

parent.var_MyMiniFrame=MyMiniFrame(parent, "Mini frame", -1, style=wx.DEFAULT_FRAME_STYLE | wx.TINY_CAPTION_HORIZ)

I’m not sure about the last one, but I’ve checked also other scripts/codes I’ve seen before. But the most common Error I receive is:

in method ‘new_miniframe’, expected argument 1 of type ‘xwindow *’
or that this 'parent is not defined.
My solutions have finished. I don’t know what else I could do.

Is it difficult, not intuitive? I don’t have any problems with php, javascript, ajax though…

Maybe I need more of short and simple expamples, like frame.py (which I haven’t seen before) - has anyone got a *.zip file containing lot’s of them (I have a demo.py already), please?

dryhay

I'm trying and trying and trying every possible combination (because the
first one is not working)...

var_MyMiniFrame=MyMiniFrame(parent, "Mini frame", -1,
style=wx.DEFAULT_FRAME_STYLE | wx.TINY_CAPTION_HORIZ)

Is it difficult, not intuitive?

No.

I don't have any problems with php, javascript, ajax though...

I don't think it's a problem with Python or wxPython.

What happens if you try this?:

var_MyMiniFrame=MyMiniFrame(None, wx.ID_ANY)
var_MyMiniFrame.Show()

Che

···

On Wed, Jun 13, 2012 at 5:49 PM, dryhay <dryhay@gmail.com> wrote:

What happens if you try this?:

var_MyMiniFrame=MyMiniFrame(None, wx.ID_ANY)

var_MyMiniFrame.Show()

Che

After that IDLE returns message the one below:

Traceback (most recent call last):
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/_misc.py”, line 1357, in Notify
self.notify()
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/_core.py”, line 14738, in Notify
self.result = self.callable(*self.args, **self.kwargs)
File “/home/dry/Dokumenty/pyt/37.py”, line 73, in showFrame
var_MyMiniFrame=MyMiniFrame(None, wx.ID_ANY)
File “/home/dry/Dokumenty/pyt/37.py”, line 48, in init
wx.MiniFrame.init(self, parent, -1, title, pos, size, style)
File “/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode/wx/_windows.py”, line 772, in init
windows.MiniFrame_swiginit(self,windows.new_MiniFrame(*args, **kwargs))
TypeError: String or Unicode type required

I’ve checked different combinations of arguments and google answers as well, but errors still appear.

dryhay

One issue that you might have missed is that IDLE and wx don’t
always play nicely together so try running your code from the
command prompt - your problem above looks to be that you are not
supplying a title for your new mini-Frame.

Gadget/Steve
···

wxPython-users+unsubscribe@googlegroups.com
http://groups.google.com/group/wxPython-users?hl=en

One issue that you might have missed is that IDLE and wx don't

always play nicely together so try running your code from the
command prompt - your problem above looks to be that you are not
supplying a title for your new mini-Frame.

That has been checked as well with different combinations:

TypeError: init() got multiple values for keyword argument ‘title’

Target - problem visualized: http://pasteall.org/pic/show.php?id=33111
and this is my script: http://codepad.org/4V1DVcTO

dryhay