This is an os/platform dependent thing.
Prev. instance:
1.) In Windows:
Create Mutex with unique name (Win API), and check it.
When it is loaded, then you must send a message to the prev program.
This program is get message, and load the file.
2.) In Linux:
Create a Locked file (PID), and check the lock.
If locked, then same application is runnning.
But I don't know in the linux how to send a signal to a process to
refresh it's view...
Try this: the new application is create the showthisfiles.txt file in
bin directory, and send a signal to the prev app.
The prev app is load this file, and check the files in it.
Thanks, this is the first way i tryed, but i stop when i have to send the
message to the previous application..
this is the code i was using, but i don't know how to send this message
and which parameter to use in the message...
# ------------
# Main loop
# ------------
class App(wxApp):
def OnInit(self):
if wxPlatform == '__WXMSW__':
hName = win32gui.WNDCLASS()
wxInitAllImageHandlers()
self.dlg = Preview()
self.dlg.Show(True)
self.timer = StartMainAppTimer(self, self.dlg.text, 2500)
return True
if wxPlatform == '__WXMSW__':
myMutex = win32event.CreateMutex(None,-1,'sepy_mutex')
print win32event.WaitForSingleObject(myMutex, 0)
if win32event.WaitForSingleObject(myMutex, 0) == 0:
app = App(0)
app.MainLoop()
else:
exeName = win32api.GetModuleFileName(0)
sepyWindow = win32gui.FindWindow(0,exeName)
if not(win32gui.IsWindowVisible(sepyWindow)):
win32gui.PostMessage(sepyWindow, win32con.WM_USER, 0, 0)
win32gui.SetForegroundWindow(sepyWindow)
if len(sys.argv) > 1:
try:
// here i should send the message to the previous app
except:
print "Errore"
for line in sys.exc_info():
print line
time.sleep(10)
sys.exit()
else:
app = App(0)
app.MainLoop()