You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pygame_gui understandably follows the event model of pygame, but that can be inefficient and unnecessary when rather than dozens to thousands of objects processing the same event that doesn't apply to them, a single call can be made to achieve the desired result.
To increase efficiency, and make code easier to debug, I end up creating my own approach to this on top of the existing menu system (UIDropDownMenu in my case), where I keep a dictionary of menu items and which method to call when the menu item is selected.
I propose that UIDropDownMenu, at minimum, allow for a dictionary of menu items names and the associated method pointer to call. If a dictionary is provided instead of a list, the associated method would be called directly and the event process would be skipped. The existing API doesn't need to change, except for specifying that the options_list can be either a list or dictionary.
I'm going to take a crack at implementing this, so this request is really for any discussion needed...
The text was updated successfully, but these errors were encountered:
Sounds cool, I know tkinter uses this callback function model.
Perhaps we might also want to exclude elements that have a callback function for specific events from generating events and like-wise stop certain elements from even listening for any/certain events if they don't need to be. Could perhaps have a couple of broad categories of events (input, UI) and be able to exclude certain elements from listening to them by default...
So far all the UIs I've built have been fairly small scale in the range of tens of simultaneous active elements, but if you have use cases with thousands and thousands of elements each generating lots of events then I can see forcing each of those elements to in turn look at events from each of the the other thousand would get wasteful fairly quickly.
Regarding the categories of events, allowing for registering for certain types of events is another way to handle that, though perhaps gets too much away from the pygame model...
I looked at UISelectionList and realized if we do the same there, it'll be a bit more complex for the developer: We'd probably want a callback that accepted a list of selected strings, so their method declaration would need to be correct. Though I guess that's not too big an issue with typing to help out, and example code.
pygame_gui understandably follows the event model of pygame, but that can be inefficient and unnecessary when rather than dozens to thousands of objects processing the same event that doesn't apply to them, a single call can be made to achieve the desired result.
To increase efficiency, and make code easier to debug, I end up creating my own approach to this on top of the existing menu system (UIDropDownMenu in my case), where I keep a dictionary of menu items and which method to call when the menu item is selected.
I propose that UIDropDownMenu, at minimum, allow for a dictionary of menu items names and the associated method pointer to call. If a dictionary is provided instead of a list, the associated method would be called directly and the event process would be skipped. The existing API doesn't need to change, except for specifying that the options_list can be either a list or dictionary.
I'm going to take a crack at implementing this, so this request is really for any discussion needed...
The text was updated successfully, but these errors were encountered: