Python

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • OnDragOver is dragging me mad... :-D

    2 answers - 1917 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    Hi all,
    I am trying to implement some DnD from a treectrl to a
    flatnotebook. Everything works fine, except the implementation of
    D inside a DropTarget class.
    Basically, if the dragged tree item has no associated data (empty
    dictionary), I would like to have the same "barred" icon which
    provides a visual feedback to the user (the dop can't be performed
    because there is no data).
    This is what I do:
    class DropTarget(wx.DropTarget):
    def __init__(self, parent):
    """ Default class constructor. """
    wx.DropTargetinit__(self)
    self._parent = parent
    self._dataobject =
    wx.CustomD(wx.CustomDataFormat("SymphonyPlot"))
    self.SetD(self._dataobject)
    def D(self, x, y, dragres):
    if not self.GetData():
    return wx.DragNone
    draginfo = self._dataobject.GetData()
    drginfo = cPickle.loads(draginfo)
    if not drginfo.GetPlotData():
    return wx.DragNone
    return dragres
    def Data(self, x, y, dragres):
    """ Handles the Data() method to call the real DnD routine. """
    if not self.GetData():
    return wx.DragNone
    draginfo = self._dataobject.GetData()
    drginfo = cPickle.loads(draginfo)
    if not drginfo.GetPlotData():
    return wx.DragNone
    return DropTarget(x, y, drginfo.GetPlotData())
    Well, I am surely doing something stupid here, but as soon as
    D is called, Python crashes with the usual Windows error
    message box. The offending line in D is:
    if not self.GetData():
    return wx.DragNone
    Does anyone know what I may be doing wrong?
    Thank you for every hint.
    Andrea.
    "Imagination Is The Weapon In The War Against Reality."
    To unsubscribe, e-mail: wxPython-users-unsubscribe (AT) lists (DOT) wxwidgets.org
    For additional commands, e-mail: wxPython-users-help (AT) lists (DOT) wxwidgets.org
  • No.1 | | 2295 bytes | |

    Hi Andrea,

    I'm shooting in the dark BUT you have

    if not self.GetData():
    return wx.DragNone

    draginfo = self._dataobject.GetData()

    shouldn't that be

    if not self._dataobject.GetData():
    return wx.DragNone

    draginfo = self._dataobject.GetData()

    Peter.

    10/24/06, Andrea Gavana <andrea.gavana (AT) gmail (DOT) comwrote:

    Hi all,

    I am trying to implement some DnD from a treectrl to a
    flatnotebook. Everything works fine, except the implementation of
    D inside a DropTarget class.
    Basically, if the dragged tree item has no associated data (empty
    dictionary), I would like to have the same "barred" icon which
    provides a visual feedback to the user (the dop can't be performed
    because there is no data).

    This is what I do:

    class DropTarget(wx.DropTarget):

    def __init__(self, parent):
    """ Default class constructor. """

    wx.DropTargetinit__(self)

    self._parent = parent
    self._dataobject =
    wx.CustomD(wx.CustomDataFormat("SymphonyPlot"))
    self.SetD(self._dataobject)
    --
    def D(self, x, y, dragres):

    if not self.GetData():
    return wx.DragNone

    draginfo = self._dataobject.GetData()
    drginfo = cPickle.loads(draginfo)

    if not drginfo.GetPlotData():
    return wx.DragNone

    return dragres
    --
    def Data(self, x, y, dragres):
    """ Handles the Data() method to call the real DnD routine. """

    if not self.GetData():
    return wx.DragNone

    draginfo = self._dataobject.GetData()
    drginfo = cPickle.loads(draginfo)

    if not drginfo.GetPlotData():
    return wx.DragNone

    return DropTarget(x, y, drginfo.GetPlotData())
    --
    Well, I am surely doing something stupid here, but as soon as
    D is called, Python crashes with the usual Windows error
    message box. The offending line in D is:

    if not self.GetData():
    return wx.DragNone

    Does anyone know what I may be doing wrong?

    Thank you for every hint.
    --
    Andrea.

    "Imagination Is The Weapon In The War Against Reality."

    To unsubscribe, e-mail: wxPython-users-unsubscribe (AT) lists (DOT) wxwidgets.org
    For additional commands, e-mail: wxPython-users-help (AT) lists (DOT) wxwidgets.org
    --
  • No.2 | | 493 bytes | |

    Hi Peter,

    shouldn't that be

    if not self._dataobject.GetData():
    return wx.DragNone

    draginfo = self._dataobject.GetData()

    Yes, that was the problem. I am blind.

    Thank you for the hint ;-)

    Andrea.

    "Imagination Is The Weapon In The War Against Reality."

    To unsubscribe, e-mail: wxPython-users-unsubscribe (AT) lists (DOT) wxwidgets.org
    For additional commands, e-mail: wxPython-users-help (AT) lists (DOT) wxwidgets.org

Re: OnDragOver is dragging me mad... :-D


max 4000 letters.
Your nickname that display:
In order to stop the spam: 9 + 8 =
QUESTION ON "Python"

EMSDN.COM