wxPython DnD stops working after SetSizeHints

Brett Calcott brett at coombs.anu.edu.au
Tue Jun 8 04:24:59 CEST 2004



"Emiliano Molina"  wrote

> <snip>
> 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)
This gets overwritten -^

>
> class FileDropTarget(wxFileDropTarget):
>      def __init__(self, window):
unused --------------------^

>          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)

What is self.panel, as opposed to self.frame.panel?

>
>          self.frame.Show()
>          self.SetTopWindow(self.frame)
>
>          return True
>


Hi Emiliano, it isn't clear what you are trying to do here, you seem to
have a panel being created in 3 different places -- which one do you
want? I suspect that the self.panel, is hiding the other panel
that you created (self.frame.panel) which is the drop target (just a
guess)

I've never used xrc, but this works for me (is it what you want?)

class App(wxApp):
    def OnInit(self):

        self.res=wxXmlResource("test.xrc")
        self.frame=self.res.LoadFrame(None,"FRAME1")
        self.frame.panel=XRCCTRL(self.frame,"panel")

        dt=FileDropTarget()
        self.frame.panel.SetDropTarget(dt)

        # The following lines break the drag and drop
        sizer=self.frame.panel.GetSizer()
        sizer.SetSizeHints(self.frame)

        self.frame.Show()
        self.SetTopWindow(self.frame)

        return True







More information about the Python-list mailing list