00:01
Good day, ladies and gentlemen.
00:04
Today, we're looking at problem number 9 .3 from the great python book.
00:10
And it is the problem that of select geometric figures.
00:18
The basic idea is that you're supposed to use to kinter canvas to draw figures, particularly a rectangle and oval.
00:32
The idea and the user selects between the two of them.
00:37
They use a radio button and they select between a rectangle and your oval.
00:42
And then the image appears on the screen.
00:48
And you're also supposed to add a fill option to it.
00:54
So, i mean, the idea is pretty simple, but basically you have.
01:02
To outline what we're going to do, you create a tkinter window.
01:12
So this here is our window here, our tk object.
01:23
Okay.
01:25
This will call window.
01:27
So window equals to the tk object.
01:31
Okay, and then on this object, we're going to create a canvas.
01:43
So i'll draw it like this.
01:47
Maybe my canvas is like this guy.
01:50
Okay.
01:52
And this guy is a canvas.
01:56
So this guy here, maybe i'll do it over here.
02:01
This is a canvas okay and um wait a minutes um maybe i made a little bit of a tad bit of a mistake here let me just um do a little bit of fixing here um you'll see in a minute why uh yeah like this instead like this so this is my canvas.
02:37
And then below my canvas, this is kind of why i wanted to raise that.
02:44
I'm going to have some buttons there, which i have, let me see.
02:49
So they're radio buttons here.
02:51
So they're not erased that.
02:53
So they're radio buttons.
02:57
So this guy here and this guy here.
03:06
And then i'm going to have another one over here, which is a check box.
03:13
And in particular, then, this is a, this here is rectangle, and of course, the next one's oval.
03:28
I won't bother with that one.
03:30
But the final one then is filled.
03:39
And in particular, then, these guys are radio buttons.
03:42
So these over here are radio buttons, radio button.
03:55
And this one over here is a, what did he call it, a check button, i believe is the term for it.
04:07
Let me just take a look here.
04:11
Yeah, it's called a check button.
04:13
So this one's called a check button.
04:16
And these are the methods or the objects that you're creating.
04:26
So each one of these are objects that we're creating.
04:33
They're instances of the class, i guess.
04:36
So each one of these are instances of a class.
04:40
And then if i check, if, for instance, i check the rectangle.
04:46
So i say, okay, i want a rectangle.
04:50
Then on the screen, i'm going to get a rectangle here.
05:00
And this is pretty simple.
05:04
And then if per chance i say, well, i want this rectangle to be filled.
05:10
So somebody checks to fill or checks to fill.
05:14
Then, you know, this rectangle gets filled in like so.
05:19
So it's pretty basic.
05:22
But this is what we're trying to draw.
05:25
This is what we're trying to create.
05:28
So again, i have, because this is a little bit involved, instead of doing this live, i'm going to actually, i've already pre -written the code.
05:41
I'm just going to walk you through the code written.
05:45
And then i'll show it work.
05:47
It's just too much, too time -consuming to try and do this live, basically.
05:55
And there's too much chance for mistake, which could end up taking much more time than one wants.
06:01
Okay, so the very first thing, of course, is i always import tinkter, and this is the way i do it on this machine.
06:12
I just use ticinter import star.
06:16
Or from to kinter.
06:19
Okay.
06:20
And now what i do, what i'm going to do again is create a class called figure select.
06:31
And then when i run the, when i run the program, i create an instance of this class.
06:45
And so whenever you're doing classes, the very first thing, you initialize the object.
06:56
And of course, i'm just creating my window, which is an instance of a tk object.
07:02
And i'm giving it a name.
07:05
And then right here, i create the canvas.
07:08
So it's the, i want to, i'm going to be.
07:15
Changing this canvas as i go along.
07:18
So in this case, i make it a self .canvas.
07:27
So i've made it about 300 by 100.
07:31
And then the important thing is to remember to use the packet...