egui_canvas: a TKinter-like canvas widget for the egui crate.
This crate implements a Canvas struct, which implements
egui's Widget trait while aiming to be
as similar to TKinter (python) Canvas widget as possible.
In practise, this means it is an global state holder for egui::Shape
objects and a click handler closure.
This is a hobby project and will not be regularly updated/maintained.
If you find out something is not working / could be made better, open an issue.
Check out the documentation and the examples.
Cargo features
click- enables click handler functionality. Enabled by default.image- enables image functionality. Not yet implemented.
TODOs
- Tests
- Image support (the feature does nothing yet)
- GitLab pipelines
Known limitations
- For click handler to be able to mutate the canvas object itself
(or an overlying object which owns the canvas object), it needs to have
a mutable pointer to said object moved into it at definition, because
a reference couldn't be guaranteed to live long enough. This makes mutating
(or even accessing) the canvas object from the click handler
unsafe. For now, safety is ensured by the fact that dropping the canvas object needs to wait for a lock on theMutexof the click handler, which is locked if the click handler is running. - Shapes need to be wrapped in
std::rc::Rc. - Full-sized canvas can't cover the whole window
(
egui::Ui::available_sizedoesn't return the whole size of the window)
Dependencies / Companion crates
- This crate needs to be used together with the
eframeandeguicrates (because it only implements a widget) - You may find it useful to use crate
native-dialogtogether with this one