A package that provides tkinter (in python) with support for drag/drop and widget resizing of widgets directly on a GUI window. I built this while developing my python GUI builder (https://github.com/the-pythonist/python-gui-maker). I found no library at the time capable of providing drag/drop and widget resize in real time, so thankfully, I built this.
This package is one that provides drag/drop and widget resizing support to tkinter widget. What this means is that you (as programmer) can make your widget move to any position on the GUI window (drag/drop). It additionally means that you can resize your widget directly on the GUI window.
For widget resizing, you can resize your widget in any direction you can think of (even diagonally), whether:
- UP (or NORTH) direction
- DOWN(or SOUTH) direction
- RIGHT (or EAST) direction
- LEFT (or WEST) direction
- UP-RIGHT (or NORTH-EAST) direction
- UP-LEFT (or NORTH-WEST) direction
- DOWN-RIGHT (or SOUTH-EAST) direction
- DOWN-LEFT (or SOUTH-WEST) direction
https://github.com/the-pythonist/python-gui-maker
First import the tkinter_dndr module. The tkinter_dndr module contains a class called DragDropResizeWidget.
- Create an instance/object of the DragDropResizeWidget class. This class receives your widget as a positional argument.
EXAMPLE: instance = DragDropResizeWidget(w)
, where w is the widget you want to give drag/drop or resize support
a) instance.make_draggable()
# Provides only drag/drop support to widget
b) instance.make_resizable()
# Provides only resizing support to widget
c) intance.make_draggable_and_resizable()
# Provides both drag/drop and resizing support to widget
- Call any of the above methods (a,b or c) as you desire
e.g: instance.make_draggable()
- NOTE: I HAVE INCLUDED A
test_dndr.py
file in repository. Run/Open this file to see and understand how this package works.
-- To use the .make_draggable()
method, your widget MUST use the PACK or PLACE layout managers (either .pack()
or .place()
)
-- To use the .make_resizable()
method, your widget MUST ONLY use the PLACE layout manager
-- To use the .make_draggable_and_resizable()
method, your widget MUST ONLY use the PLACE layout manager
-- If using the .make_resizable()
or .make_draggable_and_resizable_method()
, you MUST define x,y,width and height in .place() for your widget
e.g: widget.place(x=5, y=10, width=10, height=12)
I will endeavour to make SUBSEQUENT VERSIONS of this package work well with any layout manager (whether .grid()
, .pack()
or .place()
)
See the test_dndr.py
file in the package directory for a usage example.
Feel free to raise an issue if you have anything you like urgently patched or added.
If your software/project relies on this package fully supporting all layout managers or any other desired support/addition, I am only an Issue creation away.