wxPython DnD stops working after SetSizeHints
Emiliano Molina
nothanks at nothere.com
Mon Jun 7 06:34:20 EDT 2004
This has been driving me crazy for a couple of days and I have finally
narrowed it down to the following code. If the commented section is
uncommented the drag and drop handler is never called. I have included
the .xrc file for reference.
Any help is greatly appreciated. An explanation would be great, but at
the moment I would be eternally grateful for a workaround!
Thanks in advance for those of you that spend some time helping out.
Here is the blasted code,
from wxPython.wx import *
from wxPython.xrc import *
class TestFrame(wxFrame):
def __init__(self,parent,ID):
wxFrame.__init__(self,parent,ID,"test
frame",(100,30),(70,60),wxDEFAULT_FRAME_STYLE)
self.panel=wxPanel(self,-1)
class FileDropTarget(wxFileDropTarget):
def __init__(self, window):
wxFileDropTarget.__init__(self)
def OnDropFiles(self, x, y, filenames):
print filenames
class App(wxApp):
def OnInit(self):
self.res=wxXmlResource("test.xrc")
self.frame=self.res.LoadFrame(None,"FRAME1")
self.frame.panel=XRCCTRL(self.frame,"test_list")
dt=FileDropTarget(self.frame)
self.frame.panel.SetDropTarget(dt)
# The following lines break the drag and drop
# self.panel=XRCCTRL(self.frame,"panel")
# sizer=self.panel.GetSizer()
# sizer.SetSizeHints(self.frame)
self.frame.Show()
self.SetTopWindow(self.frame)
return True
def main():
app=App(0)
app.MainLoop()
if __name__=="__main__":
main()
and here the XRC
<?xml version="1.0" ?>
<resource>
<object class="wxFrame" name="FRAME1">
<title></title>
<object class="wxPanel" name="panel">
<size>100,100</size>
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<object class="wxStaticBoxSizer">
<label>test_list</label>
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<object class="wxListBox" name="test_list">
<content/>
</object>
</object>
</object>
</object>
</object>
</object>
<size>100,100</size>
</object>
</resource>
More information about the Python-list
mailing list