Hello
I have an application that has a TextCtrl & when I drag & drop a file
onto it I want to create a wx.Event object (or wx.CommandEvent) , set
the wxEvent's event object to the file dropped in the TextCtrl
( event.SetEventObject( file )) then send that Event object in a
function.
I know that I should not create my own wxEvent objects but right now
its the best way to do it.
But I get an error when I go to set the wxEvent's event object which
says it expects an wxObject as the parameter. Can you tell me how to
fix this?
Background info:
My app architecture is the MVC model. So when my FileDrop object(an
extended wx.FileDropTarget object) has a file dropped into it, I call
the 'View' class's/component's on_file_drop_command( self, event )
function. Therefore you can see the need to create an event object &
pass it to the 'View' class.
My code:
class FileDrop( wx.FileDropTarget ):
def __init__( self, _window, _parent_frame ):
""" """
wx.FileDropTarget.__init__( self )
self.window = _window
self.parent_frame = _parent_frame
def OnDropFiles( self, x, y, fileNames ):
""" """
file_list = []
for file in fileNames:
event = wx.CommandEvent( wx.wxEVT_DROP_FILES )
event.SetEventObject( wx.wxObject( file ) ) # fails here
self.parent_frame.on_input_change( event )
My view class:
class ApplicationView:
def on_input_file_change_command( self, event ):
""" """
evt_type = event.GetEventType()
if evt_type == wx.EVT_TEXT:
file_name = self.input_tf.GetValue()
else: # this will be when I get the file drop occurence
file_name = event.GetEventObject()
self.controller.window_proc( GS_INPUT_FILE_CHANGE, file_name )