[Tutor] Tkinter and after() method
Phil
phillor9 at gmail.com
Tue Jan 31 21:11:49 EST 2023
On 1/2/23 11:10, Alan Gauld via Tutor wrote:
>
> Where are the methods?
> An object that has no operations is just data...
I was coming to that, it's still work in progress.
>> my_dial = None # I cannot see an alternative to their use at the moment
>> my_canvas = None
> Why not make them attributes of your root class?
> After all the Root class actually represents your
> application does it not?
That's how they were but they weren't visible to functions outside the
root class. I'll give this more thought.
def draw_dial(the_dial, canvasName):
> Why is this not a method of the dial class. "the_dial" being self...
> And canvasName is not really a name but a canvas so why not call it so:
>
> class Dial:
>
> def __init__(...)...
> def draw(self,aCanvas):...
>
>> def move_pointer(the_dial, canvasName):
>> # this is just a test. In real use the_dial.value woule be supplied
>> with
>> # a value from a serial device
> Again a method of dial...
>
>> def drawPointer(x_centre, y_centre, x_end, y_end, fill, canvasName):
> Again a Dial method.
> The coordinates should be known to the dial hopefully?
>
>> def loop():
>> # again, this only for testing
> But could be a method of Root?
> Then your globals become
> self.my_dial etc.
>
Thank you Alan, I thought it would be best to have the canvas drawing
routines included in the root class and not the Dial class, but I see
your point. Much along the lines of Cameron's suggestions.
I've got to get back to my plumbing job otherwise I'll be in more trouble.
--
Regards,
Phil
More information about the Tutor
mailing list