Thomas wrote:
Hi Robin,
I wrote a small application
import sys, os
import wxclass MyApp(wx.App):
def OnInit(self):
print "app initial"
#do init stuff here
return True
def MacOpenFile(self, filename):
print filename #code to load filename goes here.app = MyApp(0)
app.MainLoop()and tried drag drop a file holding the option key.. it looks to me like the app module is not catching the drag and drop event..
should i have to do what described in
Since you are launching the app via the DnD my guess is that you are not looking in the right place for your print message. Is it showing up in the console.log (viewable with the Console app) ?
Also, since your sample app is not ever creating any UI objects, it may simply be exiting before it gets the Apple Event. You need to either have a frame, or a wx.TaskbarIcon, in order to keep the MainLoop from exiting because there are no top-level windows. Or you can call the app's SetExitOnFrameDelete to turn off this behavior.
Try this sample instead:
import sys, os
import wx
class MyApp(wx.App):
def OnInit(self):
f = wx.Frame(None, title="Hello World")
f.Show()
return True
def MacOpenFile(self, filename):
# code to load filename goes here.
wx.MessageBox(
"You requested to open this file:\n\"%s\"" % filename)
app = MyApp()
app.MainLoop()
ยทยทยท
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!