1
00:00:01,580 --> 00:00:06,770
OK, in this video, I want to talk about combo boxes and cargo boxes are just dropdown boxes, right?

2
00:00:07,060 --> 00:00:09,050
You see them on web forms and things.

3
00:00:09,050 --> 00:00:10,910
You click on them, little thing drops down.

4
00:00:10,910 --> 00:00:12,200
There's a list of items.

5
00:00:12,380 --> 00:00:14,510
You pick one and then that's it.

6
00:00:14,540 --> 00:00:19,940
So with combo boxes, again, we have to import a little module from TENTER.

7
00:00:20,240 --> 00:00:22,730
For some reason, we have to explicitly import this.

8
00:00:22,730 --> 00:00:23,540
So let's do that now.

9
00:00:23,550 --> 00:00:32,060
So it's from T Kintner import Teekay and TDK is just a module that has a little nicer looking widgets,

10
00:00:32,900 --> 00:00:34,340
some of which we'll look at.

11
00:00:34,340 --> 00:00:36,020
For instance, this one, the combo box.

12
00:00:36,320 --> 00:00:41,390
OK, so with a combo box you need to designate what the things are going to be in the list that drops

13
00:00:41,390 --> 00:00:41,690
down.

14
00:00:41,690 --> 00:00:44,110
So to do that, you use a Python dictionary.

15
00:00:44,120 --> 00:00:48,980
So I'm just going to call this options, set this equal to a Python dictionary, and we can put this

16
00:00:48,980 --> 00:00:50,000
on multiple lines.

17
00:00:50,270 --> 00:00:52,310
So let's just say Monday.

18
00:00:53,660 --> 00:01:00,530
And each of these things should be separated with commas Tuesday and let's just go Wednesday.

19
00:01:03,140 --> 00:01:05,900
OK, you can put a comma for the last one, but you don't have to.

20
00:01:06,260 --> 00:01:08,910
So now we need to create our combo box.

21
00:01:08,910 --> 00:01:10,730
So let's go my underscore combo.

22
00:01:12,340 --> 00:01:13,100
Equals now.

23
00:01:13,120 --> 00:01:22,810
This is a widget, so tech that combo box and we want to put this in route and we want the value.

24
00:01:24,370 --> 00:01:26,260
To equal our options.

25
00:01:27,630 --> 00:01:31,480
And that's these right here, so that's pretty much all there is to it.

26
00:01:31,500 --> 00:01:37,500
Now we have to designate which of these we want to show up by default in the combo box.

27
00:01:37,500 --> 00:01:46,110
So let's go my underscore combo dot current set the current one and it's a function and we just pass

28
00:01:46,110 --> 00:01:49,800
in the index number of the thing we want to show up.

29
00:01:49,810 --> 00:01:52,070
So Python lists start at zero.

30
00:01:52,410 --> 00:01:54,120
So Monday is the zeroth item.

31
00:01:54,120 --> 00:01:55,410
Tuesday is the first item.

32
00:01:55,410 --> 00:01:58,500
Wednesday is the second item, which is weird because there's three items.

33
00:01:58,500 --> 00:02:01,170
But just remember, Python lists always start at zero.

34
00:02:01,170 --> 00:02:03,180
So zero is Monday.

35
00:02:03,420 --> 00:02:06,300
If we want a Tuesday to show up, we would put one here.

36
00:02:07,170 --> 00:02:09,290
So, OK, that's how we do that.

37
00:02:09,300 --> 00:02:14,880
So now all that's left is to my combo pack, this guy on the screen and let's give this guy a pad Y

38
00:02:14,880 --> 00:02:16,600
of ten just to smash it down a little bit.

39
00:02:16,620 --> 00:02:20,970
So now if we save this and I say this as combo pie, so if we run this.

40
00:02:22,330 --> 00:02:27,550
We see Monday, Tuesday, Wednesday, now, nothing happens here because we have a button yet, we'll

41
00:02:27,550 --> 00:02:28,600
do that in just a second.

42
00:02:29,030 --> 00:02:29,920
But I mentioned.

43
00:02:31,090 --> 00:02:35,650
We sent this to current zero, if we wanted to stay to show up, we put one there.

44
00:02:36,040 --> 00:02:37,660
Now if we save this and run it.

45
00:02:40,750 --> 00:02:44,800
Boom, now Tuesday shows up by default, which is kind of weird, I don't know why you would want to

46
00:02:44,800 --> 00:02:46,990
do that, but if you did, that's how you would do it.

47
00:02:47,000 --> 00:02:49,910
So, OK, so how do we now do something with this?

48
00:02:49,930 --> 00:02:55,030
Well, let's create a button called my button, and this is a button.

49
00:02:55,600 --> 00:02:59,500
And we want to put it in route and we want the text to say select.

50
00:03:00,780 --> 00:03:04,770
And what let's give this a command, a select.

51
00:03:07,800 --> 00:03:09,540
And let's pack this on the screen.

52
00:03:10,110 --> 00:03:13,140
OK, so now we need to create this select function.

53
00:03:13,140 --> 00:03:18,310
So I'm going to come up here and create select function.

54
00:03:19,420 --> 00:03:27,520
So we want to define, select, it's a function, so let's create a label, my underscore label, and

55
00:03:27,520 --> 00:03:28,330
that's a label.

56
00:03:30,600 --> 00:03:35,850
And we want to put it in root and we want the text to equal my combo.

57
00:03:38,950 --> 00:03:45,040
Don't get we want to get that right now, let's pack this on the screen and let's give this a pat.

58
00:03:45,040 --> 00:03:47,570
Why of 10, just give spacing.

59
00:03:47,590 --> 00:03:49,630
OK, so let's take this and run it.

60
00:03:53,200 --> 00:03:55,810
And did I not forget to change this back, so Monday.

61
00:03:56,470 --> 00:04:01,690
Monday, Wednesday, Wednesday, Tuesday, Tuesday.

62
00:04:01,690 --> 00:04:05,410
And again, you can do things based on that, like we've already learned in the past.

63
00:04:05,770 --> 00:04:09,100
So let's change this back to the default Monday, for instance.

64
00:04:10,840 --> 00:04:11,890
So like in our slides.

65
00:04:11,900 --> 00:04:13,390
So we could go if.

66
00:04:14,470 --> 00:04:17,410
My underscore combo get.

67
00:04:18,610 --> 00:04:21,730
Equals, you know, Monday.

68
00:04:23,970 --> 00:04:25,020
Then let's.

69
00:04:27,360 --> 00:04:30,090
Put out instead of just the thing.

70
00:04:33,140 --> 00:04:34,080
Let's go.

71
00:04:34,700 --> 00:04:37,450
You clicked on the.

72
00:04:38,800 --> 00:04:44,170
All right, we can just continue with my underscore combo dot get.

73
00:04:47,650 --> 00:04:56,890
Equals Tuesday, or you can use else statements as well, whatever, let's just copy this whole thing.

74
00:04:57,250 --> 00:04:59,020
You clicked Tuesday.

75
00:05:00,890 --> 00:05:05,390
And if I can get.

76
00:05:06,810 --> 00:05:10,200
Equals Wednesday.

77
00:05:13,200 --> 00:05:15,690
You clicked Wednesday.

78
00:05:16,870 --> 00:05:20,410
Save this runit, you click Monday.

79
00:05:21,550 --> 00:05:22,690
You click Tuesday.

80
00:05:23,740 --> 00:05:25,920
If wed, easy as can be.

81
00:05:26,490 --> 00:05:29,550
So those are dropdown boxes, combo boxes, pretty simple.

82
00:05:29,760 --> 00:05:37,620
Now Kintyre has a dropdown box widget that does not look as good as this combo box widget, its actual

83
00:05:37,620 --> 00:05:39,540
options menu you can use.

84
00:05:39,810 --> 00:05:42,360
And if you want to Google how to use that, you can.

85
00:05:42,360 --> 00:05:47,460
But you're always going to want to use this combo box because it looks better, it looks nicer, and

86
00:05:47,760 --> 00:05:50,150
I'll let you discover how bad the other one works.

87
00:05:50,160 --> 00:05:52,920
It looks if you want to, but it looks bad.

88
00:05:53,280 --> 00:05:55,630
So just use this combo box whenever you want to.

89
00:05:55,630 --> 00:05:57,170
You use a dropdown box of any kind.

90
00:05:57,420 --> 00:05:58,560
So that's all for this video.

91
00:05:58,560 --> 00:06:01,230
In the next video, we'll look at creating new windows.
