drop problem with grid -- on Mac only?

I have been having problems getting drag & drop to work, where I drag into a grid on a Mac. I have constructed a <60 line demo program that works on Windows and Linux, but where dragging to the grid on my Mac (10.6.4, EPD 6.2-2) fails. Is this operator error or is there a wx bug here?

As a second question, since I am still struggling to learn proper use of sizers, can anyone explain to me why the commented out BoxSizer Add fails to cause the TextCtrl to expand to its proper size, if it is used in place of the previous Add?

Brian

testdrop.py (1.71 KB)

I have been having problems getting drag& drop to work, where I drag
into a grid on a Mac. I have constructed a<60 line demo program that
works on Windows and Linux, but where dragging to the grid on my Mac
(10.6.4, EPD 6.2-2) fails. Is this operator error or is there a wx
bug here?

The Grid widget is composed of several sub widgets (for the grid area and the col/row labels), which occupy all the visible area of the grid. If you want to be able to drop into the grid you should set the drop target on one of the visible windows, not its parent.

     grid.GetGridWindow().SetDropTarget(drptgt)

As a second question, since I am still struggling to learn proper use
of sizers, can anyone explain to me why the commented out BoxSizer
Add fails to cause the TextCtrl to expand to its proper size, if it
is used in place of the previous Add?

Depends on what you mean by "proper size." I'm guessing that you think it means to be large enough to show all the text. But since the wx.TextCtrl can have variable size needs that change at runtime as the user types then it just uses a fixed width for its best size and that is what the sizer will use for layout unless you tell it different. You can override the best size by setting the min size.

     lbl1.SetMinSize((200,-1))

···

On 9/25/10 7:40 AM, Brian H. Toby wrote:

--
Robin Dunn
Software Craftsman

Ah ha! Thanks this is indeed the solution:

  If you want to be able to drop into the grid you should set the drop
target on one of the visible windows, not its parent.

     grid.GetGridWindow().SetDropTarget(drptgt)

So I take it that the GridDragAndDrop.py example:

class SimpleGrid(gridlib.Grid):
    def __init__(self, parent, log):
        gridlib.Grid.__init__(self, parent, -1)
...
        # set the drag and drop target
        dropTarget = GridFileDropTarget(self)
        self.SetDropTarget(dropTarget)

is wrong. (How to get that changed?) To help others avoid this
pitfall, I have made appropriate (I hope) updates to http://wiki.wxpython.org/wxGrid
and AppointmentsSchedulingWidget - wxPyWiki where the
similar problematic usage is present.

Brian

Apparently not as that sample works fine on Mac for me, I guess I was misremembering something. Try to figure out what the difference is between your sample and the one in the demo, so we can narrow down where the problem is at.

···

On 9/27/10 2:50 PM, bht wrote:

Ah ha! Thanks this is indeed the solution:

   If you want to be able to drop into the grid you should set the drop
target on one of the visible windows, not its parent.

      grid.GetGridWindow().SetDropTarget(drptgt)

So I take it that the GridDragAndDrop.py example:

class SimpleGrid(gridlib.Grid):
     def __init__(self, parent, log):
         gridlib.Grid.__init__(self, parent, -1)
...
         # set the drag and drop target
         dropTarget = GridFileDropTarget(self)
         self.SetDropTarget(dropTarget)

is wrong.

--
Robin Dunn
Software Craftsman

Oops, what I was missing is that I ran one sample with wx 2.8 and the other with 2.9. In 2.9 this issue has been solved, and setting the Grid as the drop target on Mac will also work for drops done on the GridWindow.

···

On 9/27/10 3:12 PM, Robin Dunn wrote:

On 9/27/10 2:50 PM, bht wrote:

Ah ha! Thanks this is indeed the solution:

If you want to be able to drop into the grid you should set the drop
target on one of the visible windows, not its parent.

grid.GetGridWindow().SetDropTarget(drptgt)

So I take it that the GridDragAndDrop.py example:

class SimpleGrid(gridlib.Grid):
def __init__(self, parent, log):
gridlib.Grid.__init__(self, parent, -1)
...
# set the drag and drop target
dropTarget = GridFileDropTarget(self)
self.SetDropTarget(dropTarget)

is wrong.

Apparently not as that sample works fine on Mac for me, I guess I was
misremembering something. Try to figure out what the difference is
between your sample and the one in the demo, so we can narrow down where
the problem is at.

--
Robin Dunn
Software Craftsman