Conditions

Every drop is checked in this order. The first “no” refuses it, and the target shows a “not allowed” cursor instead of its highlight:
- Type. The draggable’s
type(a sortable item’s: the list’sgroup) must be in the target’saccepts(or itsgroup).Noneand"*"accept anything. - Disabled.
disabled=Truetargets take nothing. - The list’s rules.
put=Falsetakes nothing from other lists,sort=Falsedoesn’t reorder inside,max_itemsis full, and the source list’spull=Falsekeeps its items. - Your rule.
can_drop(event)returnsTrueorFalse.
Types and accepts
Section titled “Types and accepts”pz.draggable(photo, p.id, type="image")pz.draggable(doc, d.id, type=["file", "pdf"])
pz.droppable(gallery, "gallery", accepts="image")pz.droppable(inbox, "inbox", accepts=["file", "image"])Sortables use group for both: their items have it as type and they accept it. Add
accepts for more (a list that also takes pz.draggables from
a toolbar).
Your own rules
Section titled “Your own rules”can_drop(event) is asked once per drag and target (the first time the drag reaches it), so it can be as
slow as you like. event.data is the dragged item and event.target the target:
# A node can't be connected to itselfpz.droppable(port, f"in/{node}/{name}", accepts="port:float", can_drop=lambda e: e.data["node"] != node)
# Only the owner's cards go to "Done"pz.sortable(..., id="done", group="cards", can_drop=lambda e: e.data["owner"] == self.user)| Option | Effect |
|---|---|
pull=False |
Its items can’t leave it (they still reorder inside). |
pull="clone" |
Its items are copied out: a palette. |
put=False |
It takes nothing from other lists. |
sort=False |
It doesn’t reorder inside (a palette). |
max_items=3 |
Full at 3 items; reordering inside still works. |
locked=[...] |
These keys can’t be dragged. |
draggable=False |
No item can be dragged: only the order animates. |
disabled=True |
Nothing is dragged out or dropped in. |
Holding Alt while dropping marks the drop as a copy (event.copy), like in a file
manager: your handler decides what to do with it.