accessing the return value of function that was bound to an event (tkinter)

后端 未结 3 1261
余生分开走
余生分开走 2021-01-14 09:27

Basically, what I\'ve done is bound a click event to a function. For example:

self.button1.bind(\"\",self.chooseDice)

What

3条回答
  •  孤街浪徒
    2021-01-14 10:03

    Refactor. Split this into two functions.

    One returns the proper result, usable by other objects.

    The other is bound to a GUI control, and uses the proper result to activate and deactivate GUI objects.

    Indeed, you should always do this. You should always have functions that do normal Python stuff, work correctly without the GUI and can be unit tested without the GUI. Then you connect this working "model" to the GUI.

提交回复
热议问题