Web Analytics Made Easy - Statcounter
Skip to content

Functions for Drag and Drop support

These are the calls you can make into the psgdnd package.

is_drop_event

Returns True if the passed in event is a drop event. A drop event is always a DropEvent object

is_drop_event(
    event
)

Parameter Descriptions

Name Type Default Description
event Any Event to check
RETURN bool Trye if the event is a drop event

on_drop

The function that is called when a drop happens. This function reformats and puts the data into a DropEvent object and sends it to the window's event queue.

on_drop(
    event,
    element,
    window
)

Parameter Descriptions

Name Type Default Description
element (sg.Element) Element that received the drop
event (tkinterdnd2.TkinterDnD.DnDEvent) Data about the drop event
window (sg.Window) Window that contains the element

register_element_dnd

Register a window element to accept Drag and Drop. Pass in your elmenent object, the window that contains it, the type of drops it can receive. Valid drop types: DROP_TYPE_TEXT, DROP_TYPE_FILES, DROP_TYPE_ALL

register_element_dnd(
    element,
    window,
    drop_type = "ALL"
)

Parameter Descriptions

Name Type Default Description
drop_type str ALL Type of drops it should accept. DROP_TYPE_TEXT, DROP_TYPE_FILES, DROP_TYPE_ALL
element (sg.Element) Element to register
window (sg.Window) Window that contains the element