1
00:00:01,750 --> 00:00:06,550
OK, in this video we want to look at buttons and buttons are super easy to create and a lot of fun.

2
00:00:06,560 --> 00:00:11,860
So let's go my underscore button, create a button named Anything You Want and let's call it Button.

3
00:00:12,130 --> 00:00:13,540
And we want to put it in route.

4
00:00:13,540 --> 00:00:16,000
And we want the text to say, click me.

5
00:00:20,490 --> 00:00:26,850
And that's all for now, so now we can my button dot pack and you'll notice I've gone back to pack just

6
00:00:26,850 --> 00:00:30,600
because we're going to fly through some of these wedges and it's going to be easy just to pack them

7
00:00:30,600 --> 00:00:31,200
up on the screen.

8
00:00:31,270 --> 00:00:34,650
OK, let's go ahead and save this and let's run this guy.

9
00:00:37,040 --> 00:00:41,720
And when we do, we see click me now and we're clicking on this thing, nothing's happening, but we've

10
00:00:41,720 --> 00:00:42,310
got a button.

11
00:00:42,320 --> 00:00:43,520
So very cool.

12
00:00:43,880 --> 00:00:49,220
Now you can do the same sort of things that we've done in the past with our labels.

13
00:00:49,220 --> 00:00:52,040
You can change the colors, change the font.

14
00:00:52,040 --> 00:00:53,450
You change the height in the width.

15
00:00:53,720 --> 00:00:55,940
I'm not going to do any of those things because we don't really need to.

16
00:00:55,940 --> 00:00:58,190
But I am going to give this a pad Y.

17
00:00:59,450 --> 00:01:02,690
Of 20, just to sort of push it down a little bit.

18
00:01:02,960 --> 00:01:07,220
OK, so great, we've got a button, but it's not doing anything.

19
00:01:07,250 --> 00:01:09,170
How do we get a button to actually do something?

20
00:01:09,380 --> 00:01:16,570
So to do that, we create a command and now we set the sequel to whatever we want this thing to do.

21
00:01:16,580 --> 00:01:18,190
So let's say clicked.

22
00:01:19,160 --> 00:01:20,690
So what is our clicked command?

23
00:01:20,720 --> 00:01:22,740
Well, we haven't actually created a click command.

24
00:01:23,030 --> 00:01:30,200
Now, what this is doing is is passing it's calling the clicked function and we don't have a click function

25
00:01:30,200 --> 00:01:31,290
yet, so we need to create it.

26
00:01:31,310 --> 00:01:36,290
So let's come up here and let's go create clicked.

27
00:01:37,630 --> 00:01:38,350
Function.

28
00:01:40,480 --> 00:01:46,180
And so we just create a function called clicked and we create this function like we would any python

29
00:01:46,180 --> 00:01:47,330
function, right.

30
00:01:47,800 --> 00:01:51,940
And make sure here we're TABD over, I'm hitting the tab key on my keyboard.

31
00:01:51,940 --> 00:01:54,190
I'm not hitting the space bar a bunch of times.

32
00:01:54,430 --> 00:01:55,120
That's an error.

33
00:01:55,120 --> 00:01:56,320
You can't do that in Python.

34
00:01:56,320 --> 00:01:57,760
Python is tab sensitive.

35
00:01:57,980 --> 00:01:59,290
You have to be tabbed over.

36
00:01:59,500 --> 00:02:02,290
Or if you just come up here and hit, enter at Tab's it over for you.

37
00:02:02,590 --> 00:02:04,300
So now just what do we want to do?

38
00:02:04,310 --> 00:02:06,670
So let's go the other.

39
00:02:07,620 --> 00:02:08,430
All right, let's go.

40
00:02:08,600 --> 00:02:12,870
My label two equals a label.

41
00:02:13,920 --> 00:02:21,560
And we want to put this in root and we want the text to be you click the button, right.

42
00:02:22,230 --> 00:02:24,180
And we want to pack this on the screen.

43
00:02:24,180 --> 00:02:27,930
Now, you notice I just put a pack at the end of this.

44
00:02:27,930 --> 00:02:32,010
I didn't come down here and go my label to dot pack.

45
00:02:32,010 --> 00:02:32,700
You could do that.

46
00:02:33,480 --> 00:02:34,320
You could do like this.

47
00:02:34,320 --> 00:02:40,290
Or sometimes you can just come up here and just slap it on because Python is object oriented.

48
00:02:40,470 --> 00:02:44,130
Now, sometimes this will give you an error if you do that, if you're trying to do some other functions

49
00:02:44,130 --> 00:02:44,730
as well.

50
00:02:45,310 --> 00:02:47,190
But in this case, we can we can get away with it.

51
00:02:47,190 --> 00:02:48,360
So let's save this.

52
00:02:49,490 --> 00:02:54,830
And run this guy again, and if we click here, boom, you click the button pops up below and we can

53
00:02:54,830 --> 00:02:57,980
do it a bunch of times and it just keeps going and that's fun.

54
00:02:57,990 --> 00:03:01,790
So that's how you that's one of the ways you can call a command.

55
00:03:01,910 --> 00:03:08,390
Now, you can only now normally when you call a function, you call a function like this with the parentheses,

56
00:03:08,690 --> 00:03:11,690
but with Kintner four buttons, you don't you just call the thing.

57
00:03:11,930 --> 00:03:18,500
Now, the reason you usually do that is so that we can pass things into our function and then we can

58
00:03:18,500 --> 00:03:22,630
call the things in here and, you know, and do stuff with them.

59
00:03:22,970 --> 00:03:24,560
Well, you can still do that.

60
00:03:25,830 --> 00:03:31,110
But it's just a little different, instead of calling the command equal, as you call a lamda.

61
00:03:33,780 --> 00:03:40,800
Colon, and now you can pass things into your function and we'll look at doing this later on when our

62
00:03:40,800 --> 00:03:42,300
program gets a little more complicated.

63
00:03:43,050 --> 00:03:44,760
One thing I noticed mention this.

64
00:03:45,030 --> 00:03:48,480
One thing I'll note, this looks like a capital L it's not.

65
00:03:48,630 --> 00:03:49,740
It's a lowercase L.

66
00:03:50,130 --> 00:03:52,890
This is a capital L, right.

67
00:03:53,860 --> 00:04:00,070
For some reason, when you type on a lower case, L for Lambda in sublime text, it makes it kind of

68
00:04:00,070 --> 00:04:05,230
curly at the bottom and it kind of looks like a capital l it's not it's a lowercase l just keep that

69
00:04:05,230 --> 00:04:05,740
in mind.

70
00:04:06,710 --> 00:04:08,610
And so that's how you how you do that.

71
00:04:08,620 --> 00:04:10,390
So those are buttons.

72
00:04:10,390 --> 00:04:13,360
Really simple, pretty cool and not a whole lot to them.

73
00:04:13,870 --> 00:04:20,110
In the next video we'll look at input field so we can start typing stuff in two boxes and doing stuff

74
00:04:20,110 --> 00:04:20,490
with them.
