Re: how can a value be retrieved from an event loop?
Alan Gauld <[email protected]>
| Newsgroups | gmane.comp.python.tutor |
|---|---|
| Message-ID | <[email protected]> |
On 16/11/2023 10:31, Phil wrote: > What I have in mind is to have the knob class return values to the > instance app and use it just like a scale widget. > > To set an angle from the instance code this is what I have done: I'm slight confused by your terminology here. A class is a template from which you create instances. Instances present an API to which you can send "messages" (aka call functions) Those functions are implemented in the class definition but each instance offers them independently. So I don't really understand what you mean by the class returns values to the instance app? The class creates an instance. The instances should return values. > knob.set_angle(15) which does set the angle but only once I've clicked > on the knob and started the event loop. > > So, should I call turn_clockwise() before I call knob.set() and what > arguments should I pass to the turn method? If so, that seems a bit > clumsy. I don't have to do anything like that to get values from a scale > widget. Getting values should be straightforward. It's setting them that's hard. At least, making the new value display is hard, just setting the value is easy. I still don't understand what it is that you are trying to do that requires you to set/get values of widgets outside the mainloop? Apart from initialising the widgets (which should be inside the __init__), anything you need to do should be possible inside the loop. It seems like you are fighting the framework for no obvious purpose. The event loop is there to make your life easier, why not use it? -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor