wxPython DnD stops working after SetSizeHints

Emiliano Molina nothanks at nothere.com
Tue Jun 8 07:56:52 CEST 2004

>>         self.panel=wxPanel(self,-1)
> This gets overwritten -^

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

Yes, you are 100% right, its there because I have been cutting
down the original program bit by bit to find the problem! It
should no longer be there.

>># 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.panel is where I am temporarily storing the window that
I am adding the DnD to.  One of the steps that I took when
trying to work out where the problem was was to start with
nothing but a frame and a panel and see if I could drop files
into the panel.  That worked fine, it was only when I added a
sizer and then had to fit and set hints that DnD broke.

I'm sorryt that the naming is a bit confusing, I posted this
last night as a last desperate attempt before going to bed!

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

The confusion is understandable, I should have spent more time
tidying up the code before posting.

self.frame.panel is used to store the retrieved control to which
the DnD handler is attached.  Its called panel because originally
it WAS a panel, its now a wxListBox.

self.panel is used to store the retrieved panel (this one IS a panel,
sorry for the confusion) from which we can then obtain the main sizer
for the frame.  If we don't have the sizer we can't call SetSizeHints
to arrange the controls in the window.  Its the calling of SetSizeHints
that seems to break the DnD handling.  If I don't call SetSizeHints
then DnD works fine and I can drop a file onto the list in the frame
and its name is printed.  The frame looks terrible of course, the
controls are only arranged properly when I call SetSizeHints.

> I've never used xrc, but this works for me (is it what you want?)
> some helpful code
>         return True 

I tried the code you sent on the iBook and no luck, but you mentioned 
that it worked so I sent it over to the PC and tried it again.  It worked!

I had a close look at it and you have changed the drop target from the 
list to the main panel.  I did the same with my code on the PC and it 
also worked.  So the conclusion is that neither your or my code works on 
the Mac.  Both sets of code work on the PC as long as the drop target is 
the panel and not the list.

Thanks for your help and time.  Now I have to figure out what is 
happening on the Mac.

More information about the Python-list mailing list