Dear all
I have 2 question here
I’m creating desktop application using wxruby and encounter some problem
I need my application to be able to open only one for each frame
is there any way to do this?
I tried to include singleton but then my frame lost its contact with its
parent
(my frame class is inherited from WxFrame and I use initialize method to
assign parent)
also, I need to catch OnClose event
how can I do that? I need to do something (delete temporary file) before
the
frame closed
code example will be appreciated
Thank you
Hi
hendra kusuma wrote:
I’m creating desktop application using wxruby and encounter some problem
I need my application to be able to open only one for each frame
is there any way to do this?
I tried to include singleton but then my frame lost its contact with
its parent
(my frame class is inherited from WxFrame and I use initialize method
to assign parent)
I’m not sure what you mean here - do you mean that only a single
instance of the application should be running at one time? If so, the
way would probably be to create some kind of lockfile on application
start: if the lockfile already exists, then the application is already
running.
If you want to have only one frame per file document, just keep a hash
as an instance variable of the Wx::App object, with the keys being the
file paths, and the values being the Wx::Frame objects. Then you can
check this hash to see if a Frame is already opened for a given file.
also, I need to catch OnClose event
how can I do that? I need to do something (delete temporary file)
before the frame closed
code example will be appreciated
Use evt_close, something like:
class MyFrame < Wx::Frame
def initialize
super
evt_close do | e |
delete_temp_file …
e.skip
end
note that calling ‘skip’ is important here, to allow normal processing
to continue and the window to actually close
hth
alex
On Sat, Jun 20, 2009 at 6:54 PM, Alex F. [email protected] wrote:
assign parent)
evt_close do | e |
delete_temp_file …
e.skip
end
note that calling ‘skip’ is important here, to allow normal processing to
continue and the window to actually close
Thank you, it’s very helpful
I solve the first problem by intercepting close event and call hide()
instead
therefore I don’t need to create an instance when I call the frame
since the frame is only hide when it’s closed, I only need to show() it
again
anyway, there is some good ideas you show me up there about making
single
instance and so on
thanks, perhaps I would end up using one of those