Open pushfoo opened 1 month ago
Bear in mind, every if statement is going to become an annotated method declaration, so total lines of code may increase.
On Thu, Jul 25, 2024, 2:26 PM Paul @.***> wrote:
Enhancement request:
TL;DR: Consider one of the other dispatch tools to clean up GUI event code What should be added/changed?
Consider one of the following to clean up our event code:
- functools.singledispatchmethod https://docs.python.org/3/library/functools.html#functools.singledispatchmethod
- The 3rd party multipledispatch https://github.com/mrocklin/multipledispatch/
- Beartype's plum https://github.com/beartype/plum
Why wait til 3.0+?
There might be unexpected problems which would delay 3.0.
The status of the following are unclear:
- Union types and arguments
- functools.singledispatch https://docs.python.org/3/library/functools.html#functools.singledispatchmethod only got Union support in 3.11
- Where does that leave singledispatchmethod https://docs.python.org/3/library/functools.html#functools.singledispatchmethod ?
- It looks like there are issues with inheritance as of a month ago https://stackoverflow.com/questions/68190543/how-to-use-singledispatchmethod-with-inheritance-class
What would it help with?
Reduce verbosity in cases like this:
— Reply to this email directly, view it on GitHub https://github.com/pythonarcade/arcade/issues/2313, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAC35ODWCKMQFWB2WILJBP3ZOE7LRAVCNFSM6AAAAABLPCTRJOVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQZTANZSG42DONQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Hi,
from my point of view, we do not have to enforce a decision for such topic without experimenting and testing it in praxis.
You can just create a UIWidget, which passes the events to the singledispatch function. This could even be an opt-in Mix-in.
Side note:
I personally try to stick to the current arcade "statement":
Arcade is an easy-to-learn Python library for creating 2D video games. It is ideal for beginning programmers, or programmers who want to create 2D games without learning a complex framework.
My conclusion is, it should be easy to understand for beginner, or have to be optional. ( I am aware, that the GUI comes with its own complexity, but it is the easiest solution I found so far 🙈)
Enhancement request:
TL;DR: Consider one of the other dispatch tools to clean up GUI event code
What should be added/changed?
Consider one of the following to clean up our event code:
functools.singledispatchmethod
multipledispatch
plum
Why wait til 3.0+?
There might be unexpected problems which would delay 3.0.
The status of the following are unclear:
Union
types and argumentsfunctools.singledispatch
only gotUnion
support in 3.11singledispatchmethod
?What would it help with?
Reduce verbosity in cases like this: https://github.com/pythonarcade/arcade/blob/05b476f5bbe3e02a2a7352d67e5daa980e7f489b/arcade/gui/widgets/text.py#L432-L477