I have written an editor for which I allow only one instance
(using win32api.CreateMutex) to be up and running. So far so good: I can tell if the app is already running and if so, I set the top window of the the already running instance to the foreground and show it, if iconified.
Now, consider the app is up and running, and the user pops up command shell to start the Editor with the name of a file to open. How can I pass that information to the already running app when all I have is the platform's window handle of its top window? IOW, how can I pass control to the running wx app and have it open the file?
I have written an editor for which I allow only one instance
(using win32api.CreateMutex) to be up and running. So far so good: I can tell if the app is already running and if so, I set the top window of the the already running instance to the foreground and show it, if iconified.
You can also use wxSingleInstanceChecker to see if the app is already running.
Now, consider the app is up and running, and the user pops up command shell to start the Editor with the name of a file to open. How can I pass that information to the already running app when all I have is the platform's window handle of its top window? IOW, how can I pass control to the running wx app and have it open the file?
You'll need to do some form of higher level IPC. Socket, named pipe, xmlrpc, etc.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
You can also use wxSingleInstanceChecker to see if the app is already
running.
Be very careful with that as it (in the example) only allows one
instance per user.
One of my pet peeves is programs that don't recognize that a
user can be logged in from multiple locations. For example
on Linux I am often running a gui session on the console
as well as via a VNC session. They have nothing to do
with each other. Similarly you can be logged into a Windows
box multiple times over RDP.
Nothing gets more annoying than being told in a session
than app is already running and you must bring it up
when it is displayed in another session. (Or the
web browsers that display links in an existing instance
of the browser displaying somewhere else).
In wx 2.5, you can also include wx.Display(0).GetName()
as part of the mutex name, thereby ensuring that people
like me don't have their peeves tickled
I was trying to help someone on this list, and their code kept segfaulting on me. That hasn't happened in a long time with wxPython, so I was quite surprised.
Anyway, I don't use wx.Dialog.Center, but his code did, and that's where the crash is.
Here's how it's used:
message = 'Button %d is %d wide by %d high' % (bid, bwide, bhigh)
# MessageDialog(parent, message, caption, flags, wx.Point(x,y)=defpos)
dlg = wx.MessageDialog(self, message, 'MessageDialog', wx.OK)
# Center puts dialog in center of screen, not center of window
dlg.Center()
dlg.ShowModal()
dlg.Destroy()
I've enclosed the complete program. click the "grow" button, and all works fine, click the other buttons, and it segfaults on my machine. The only difference is the dlg.Center() call has been commented out in the grow button handler.
Anyone else see this?
Gentoo Linux
Python 2.3.3
wxPython 2.5.1.5 ( compiled by me for GTK2 )
thanks, Chris
···
--
Christopher Barker, Ph.D.
Oceanographer
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
> I filed a bug report on this issue a couple weeks ago. It
> happens on GTK2 with any frame where the frame's parent
> isn't shown.
cool, except isn't the main frame the parent of the dialog in
this case?
Right, I had it wrong. Now that I'm trying to get it to work, I
can't get any of the Center() functions to not segfault no
matter what I do. CenterOnParent(), CenterOnScreen(), Center()
all cause:
Anyway, I don't use wx.Dialog.Center, but his code did, and
that's where the crash is.
I filed a bug report on this issue a couple weeks ago. It happens on GTK2 with any frame where the frame's parent isn't shown.
Isn't it just wx.MessageBox?
I think it is because on wxGTK2 a native message box API is used instead of a wx.Dialog, but some (most?) of the inherited methods don't know the difference. It's already on my todo list to investigate that.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
I think it is because on wxGTK2 a native message box API is used instead of a wx.Dialog, but some (most?) of the inherited methods don't know the difference. It's already on my todo list to investigate that.
Thanks, Robin.
Is there a list of GTK2 "gotchas" anywhere?
-Chris
···
--
Christopher Barker, Ph.D.
Oceanographer
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception