1
00:00:01,700 --> 00:00:05,960
OK, in the last video, we looked at these pop up boxes in this video, I want to show you how to do

2
00:00:05,960 --> 00:00:11,390
things based on whether a person clicks, for instance, yes or no or whatever.

3
00:00:11,600 --> 00:00:13,970
And so we'll look at that for each of those things.

4
00:00:13,970 --> 00:00:15,470
So fairly simple.

5
00:00:15,470 --> 00:00:16,640
We can pull up our code.

6
00:00:16,640 --> 00:00:22,180
And remember, in our pupper function, we just ran this message box like this.

7
00:00:22,490 --> 00:00:29,720
Now, normally we assign widgets to things like down here, button equals the widget here.

8
00:00:29,720 --> 00:00:30,820
We just put the widget.

9
00:00:31,100 --> 00:00:36,800
Well, if we want to get the output of it and then do stuff based on it, we can just create a variable

10
00:00:36,800 --> 00:00:37,100
for it.

11
00:00:37,110 --> 00:00:39,290
So let's just call this response.

12
00:00:39,680 --> 00:00:45,010
And so that equal to this now we can do stuff based on whatever this response is.

13
00:00:45,020 --> 00:00:50,060
So if they click the yes, that will pass a thing to the response that we can then use.

14
00:00:50,060 --> 00:00:52,770
If they click on no, that will pass something else to the response.

15
00:00:52,770 --> 00:00:56,870
So we can use if they click on OK, if they click on cancel it, they click on, you know, whatever

16
00:00:56,870 --> 00:01:01,100
they click on, it'll it'll be passed to a response and then we can take some action based on it.

17
00:01:01,100 --> 00:01:07,640
So I could just tell you what the responses for each of these things are.

18
00:01:08,150 --> 00:01:12,680
But instead I think I just show you with examples because I think that's better.

19
00:01:12,690 --> 00:01:13,640
So let's create a label.

20
00:01:13,970 --> 00:01:17,510
And also if you realize how to do this, you can do this in the future.

21
00:01:17,510 --> 00:01:19,040
So you have to memorize all this stuff.

22
00:01:19,040 --> 00:01:22,340
You can just slap this on the screen and see for yourself what the output is.

23
00:01:22,670 --> 00:01:29,930
OK, so my label, this is a label and it's in root and we want the text to equal response, which is

24
00:01:30,470 --> 00:01:31,790
whatever this response is.

25
00:01:32,150 --> 00:01:32,470
Right.

26
00:01:33,050 --> 00:01:40,130
And then let's just pack this on the screen and give it a pad Y of ten just to push it down the screen

27
00:01:40,130 --> 00:01:40,610
a little bit.

28
00:01:41,080 --> 00:01:42,770
OK, so let's save this and run it.

29
00:01:42,920 --> 00:01:45,380
And so now we are on ask.

30
00:01:45,380 --> 00:01:45,700
Yes.

31
00:01:45,710 --> 00:01:46,520
No, right.

32
00:01:46,700 --> 00:01:47,210
Here we go.

33
00:01:47,510 --> 00:01:50,750
So let's see what the response for ask yes no is.

34
00:01:51,140 --> 00:01:51,410
All right.

35
00:01:51,410 --> 00:01:52,520
So click the pop up.

36
00:01:52,520 --> 00:01:54,170
Look at my pop up message.

37
00:01:54,170 --> 00:01:59,780
Yes, it returns one if we do it again and click no, it returns zero.

38
00:02:00,050 --> 00:02:01,160
So for ask yes.

39
00:02:01,160 --> 00:02:01,670
No.

40
00:02:01,850 --> 00:02:05,180
Instead of returning yes or no it returns one for yes.

41
00:02:05,180 --> 00:02:05,420
No.

42
00:02:05,420 --> 00:02:06,050
Four zero.

43
00:02:07,250 --> 00:02:07,590
Right.

44
00:02:07,790 --> 00:02:17,350
And just like anything else, you can now run an if statement so we could go if response equals one,

45
00:02:17,900 --> 00:02:25,040
then my label needs to be tapped over is.

46
00:02:26,370 --> 00:02:26,880
You know.

47
00:02:28,910 --> 00:02:30,080
You clicked.

48
00:02:32,040 --> 00:02:32,760
Yes.

49
00:02:34,830 --> 00:02:35,230
Right.

50
00:02:35,280 --> 00:02:36,000
Else.

51
00:02:42,010 --> 00:02:43,540
You clicked no.

52
00:02:46,110 --> 00:02:49,290
And then, well, let's just keep this here for now.

53
00:02:49,590 --> 00:02:54,480
So if we save this and run it, you could probably figure out what's going to happen here.

54
00:02:55,230 --> 00:02:55,920
If we click.

55
00:02:55,920 --> 00:02:57,920
Yes, we get one.

56
00:02:57,930 --> 00:02:58,410
You click.

57
00:02:58,410 --> 00:02:59,970
Yes, we click.

58
00:02:59,970 --> 00:03:02,220
No, we get zero.

59
00:03:02,220 --> 00:03:02,710
You clicked.

60
00:03:02,730 --> 00:03:04,950
No, pretty simple.

61
00:03:06,420 --> 00:03:11,400
Pretty straightforward, so now I'm going to comment this out.

62
00:03:16,070 --> 00:03:21,710
For now and just leave it like this, so let's run through here and look and see what the responses

63
00:03:21,710 --> 00:03:22,460
are for each of these.

64
00:03:22,460 --> 00:03:24,760
So ask, OK, cancel.

65
00:03:25,190 --> 00:03:26,180
You might be surprised.

66
00:03:26,180 --> 00:03:29,070
You might see some of these are going to be not what you think.

67
00:03:29,090 --> 00:03:30,170
Maybe so.

68
00:03:30,170 --> 00:03:30,770
OK, ask.

69
00:03:30,770 --> 00:03:33,770
OK, cancel, let's run this guy and see what it does.

70
00:03:35,750 --> 00:03:42,740
So look at my message, so, OK, it returns one cancel, it returns zero to OK, cancel returns one

71
00:03:42,740 --> 00:03:44,910
or zero, just like the last one.

72
00:03:45,150 --> 00:03:46,620
OK, that's not that exciting.

73
00:03:46,910 --> 00:03:49,670
Now ask questions that one does.

74
00:03:54,660 --> 00:04:02,480
So pop up, yes, it returns, yes, no, it returns no, so that we're talking about in the last video

75
00:04:02,490 --> 00:04:06,350
the difference between ask question and ask.

76
00:04:06,360 --> 00:04:08,070
Yes, no, they both say yes.

77
00:04:08,070 --> 00:04:08,370
No.

78
00:04:08,370 --> 00:04:08,700
Right.

79
00:04:09,630 --> 00:04:10,470
But one returns.

80
00:04:10,470 --> 00:04:10,800
Yes.

81
00:04:10,800 --> 00:04:12,810
No, the island returns one or zero.

82
00:04:14,070 --> 00:04:17,450
Subtle difference, but OK, so show error.

83
00:04:17,460 --> 00:04:19,500
Let's see what this one does if we save this.

84
00:04:19,950 --> 00:04:23,130
And if you remember, this one doesn't give us an option.

85
00:04:23,700 --> 00:04:25,970
It just has an OK.

86
00:04:26,270 --> 00:04:27,720
If we look there, it returns.

87
00:04:27,720 --> 00:04:31,670
OK, so if we click, pop up and click the X, it also returns.

88
00:04:31,680 --> 00:04:33,690
OK, that's kind of interesting.

89
00:04:35,640 --> 00:04:38,220
What else show error now we're on show warning.

90
00:04:40,230 --> 00:04:41,880
Say this and run it.

91
00:04:45,720 --> 00:04:47,220
Like pop up, OK?

92
00:04:47,250 --> 00:04:48,250
It returns, OK?

93
00:04:48,600 --> 00:04:50,010
And just like.

94
00:04:51,330 --> 00:05:02,640
Down here, if a response equals one, we could change this to if response equals OK or yes or whatever

95
00:05:02,640 --> 00:05:08,290
it returns, that's what you put in your if statement here to do something based on what it returns.

96
00:05:08,640 --> 00:05:10,200
So, OK, so warning.

97
00:05:10,200 --> 00:05:11,550
We got one more show info.

98
00:05:12,590 --> 00:05:16,220
And that is going to be.

99
00:05:17,870 --> 00:05:21,710
Very suspenseful, I know, OK, and it will also return.

100
00:05:21,740 --> 00:05:26,750
OK, so those are pop up boxes, pretty simple and very useful.

101
00:05:26,750 --> 00:05:28,850
You'll find all kinds of reasons for pop up boxes.

102
00:05:28,850 --> 00:05:30,200
Sometimes you want to ask a question.

103
00:05:30,210 --> 00:05:35,030
Sometimes you just want to throw an error up on the screen and have them click, OK, now you can pick

104
00:05:35,030 --> 00:05:37,100
the one you want based on that.

105
00:05:37,100 --> 00:05:39,560
It also maybe is based on the little icon that it shows.

106
00:05:39,560 --> 00:05:41,540
Maybe you don't want that big AI to be showed up.

107
00:05:41,540 --> 00:05:46,490
There may be one exclamation point to be shown up or whatever so you can play around with that.

108
00:05:46,490 --> 00:05:48,290
So that's all for up boxes.

109
00:05:48,290 --> 00:05:51,050
In the next video, we'll look at combo boxes.
