1
00:00:01,670 --> 00:00:05,990
OK, this video, I want to show you how to create new windows, so up until now, we've just had one

2
00:00:05,990 --> 00:00:06,650
window, right?

3
00:00:06,650 --> 00:00:10,130
But you can imagine there's probably lots of times when you're going to want to create.

4
00:00:11,230 --> 00:00:16,870
Other windows that pop up and so that's we're going to look at so we can do a couple of ways, we could

5
00:00:16,870 --> 00:00:18,730
just sort of copy what we did here.

6
00:00:18,730 --> 00:00:25,960
So I've created a file called New DCPI and let's just create a new window, new and let's just go Teekay

7
00:00:26,110 --> 00:00:27,930
and just create an instance of it.

8
00:00:27,940 --> 00:00:29,640
So, OK, we can do that.

9
00:00:29,650 --> 00:00:31,370
This is not great, but it will work.

10
00:00:31,390 --> 00:00:33,600
So let's come up here and run our new tappy file.

11
00:00:34,000 --> 00:00:34,960
And when we do.

12
00:00:35,970 --> 00:00:41,040
We see here is our main wind window says, hello, world has our icon, and then here's this other one,

13
00:00:41,040 --> 00:00:44,970
it just pops up automatically and which that alone is not great.

14
00:00:45,210 --> 00:00:48,690
But also you'll notice it says Teekay here has a different icon.

15
00:00:48,690 --> 00:00:49,650
There's nothing inside it.

16
00:00:50,010 --> 00:00:51,780
But we didn't designate any of those things.

17
00:00:51,780 --> 00:00:53,660
So that kind of makes sense now.

18
00:00:53,790 --> 00:00:54,870
OK, that works.

19
00:00:54,870 --> 00:01:02,280
But Kintyre has a a function that will create a top level window, which is what you want.

20
00:01:02,280 --> 00:01:04,830
A top level window is sort of an independent window.

21
00:01:04,830 --> 00:01:06,450
It's it doesn't have its own parent.

22
00:01:06,720 --> 00:01:08,060
It's sort of what you want to do.

23
00:01:08,070 --> 00:01:11,730
So instead of calling Teekay, we would call top level.

24
00:01:12,210 --> 00:01:17,430
And this is the better way to do it as per the documentation.

25
00:01:17,430 --> 00:01:20,760
So if we save this and run it, it's going to be almost the same.

26
00:01:21,000 --> 00:01:24,300
Except now here's our original window.

27
00:01:24,600 --> 00:01:25,590
Here's our new one.

28
00:01:25,590 --> 00:01:28,590
Now it says, Hello, world in our new one to.

29
00:01:30,530 --> 00:01:32,450
And which is kind of weird now.

30
00:01:34,220 --> 00:01:39,770
This is going to change in just a second, but the thing I want to explain is this just popped right

31
00:01:39,770 --> 00:01:43,970
up, which is never what you're going to want to do whenever you run the program, it automatically

32
00:01:43,970 --> 00:01:45,770
just generates this other box.

33
00:01:45,770 --> 00:01:47,440
And that's definitely not what you want.

34
00:01:47,780 --> 00:01:53,270
Normally, you're going to want to, you know, have your second window pop up based on some event.

35
00:01:53,450 --> 00:01:58,190
You know, you click a button to open another window, you click a dropdown box menu, something like

36
00:01:58,190 --> 00:01:58,550
that.

37
00:01:58,850 --> 00:02:01,040
And that's normally what will happen.

38
00:02:01,050 --> 00:02:07,160
So to do that, let's just create in our main windows, create a button and let's just go my underscore

39
00:02:07,160 --> 00:02:10,910
button and it's a button and it's in route.

40
00:02:10,910 --> 00:02:20,990
And we want the text to equal open second window and we want the command to equal let's just call this

41
00:02:20,990 --> 00:02:22,550
open underscore window.

42
00:02:23,660 --> 00:02:27,200
And so now we can create that function.

43
00:02:27,200 --> 00:02:29,180
And let's pack this on the screen real quick.

44
00:02:32,840 --> 00:02:41,450
And let's go create second window function, and we called it open window.

45
00:02:41,900 --> 00:02:43,490
We don't need to pass anything into it.

46
00:02:43,500 --> 00:02:46,100
So now we can grab this guy here.

47
00:02:47,810 --> 00:02:54,410
And put it in this function, so this will only happen, so only get called if this function runs in,

48
00:02:54,410 --> 00:02:56,960
this function will only run if we click this window.

49
00:02:56,960 --> 00:02:57,280
Right.

50
00:02:57,740 --> 00:02:59,660
So let's go ahead, save this and run it.

51
00:03:02,740 --> 00:03:08,680
And now we've got our original window, and now if we click open second window, boom, this pops up,

52
00:03:08,950 --> 00:03:10,980
if it closes, we can open it again.

53
00:03:11,920 --> 00:03:15,010
And I have to drag it over from my other screen.

54
00:03:16,190 --> 00:03:24,230
And now that works, so that's cool, now we can sort of do the things that we want to do to that second

55
00:03:24,230 --> 00:03:25,730
window inside this function.

56
00:03:25,740 --> 00:03:28,910
So like, for instance, we can grab all of this stuff.

57
00:03:28,910 --> 00:03:30,860
Right, and paste it in.

58
00:03:33,420 --> 00:03:37,080
But instead of root, now this is all new.

59
00:03:39,220 --> 00:03:45,010
For each of these, because that's the name of our window, the new window, and maybe that's not a

60
00:03:45,010 --> 00:03:53,780
great name, but for the title, let's put this as second window and let's make it slightly smaller.

61
00:03:53,800 --> 00:03:55,030
Let's just go two hundred.

62
00:03:55,420 --> 00:03:56,110
Three hundred by.

63
00:03:57,420 --> 00:04:01,560
Two hundred or whatever, so now if we save this and run this guy.

64
00:04:03,510 --> 00:04:06,120
So, boom, we get our first window if we click the button.

65
00:04:07,190 --> 00:04:12,280
When we get the second window now, it says second window here, if I click here to highlight this one,

66
00:04:12,280 --> 00:04:17,880
you can see this changes color here so we can see our icon and that works close this.

67
00:04:17,890 --> 00:04:23,010
Now, if we want to do something in that window, like, for instance, we want to label.

68
00:04:23,020 --> 00:04:30,910
So let's go my underscore label and this is a label and normally we put this in route, but we're not

69
00:04:31,030 --> 00:04:31,600
route anymore.

70
00:04:31,600 --> 00:04:32,560
Now we're in new.

71
00:04:32,590 --> 00:04:33,010
Right.

72
00:04:33,280 --> 00:04:35,120
And we want the text to equal.

73
00:04:35,980 --> 00:04:39,910
Look at my fancy second.

74
00:04:41,170 --> 00:04:42,780
I know, right?

75
00:04:43,180 --> 00:04:45,760
And we just want to pack this up on the screen, we could do that.

76
00:04:45,980 --> 00:04:50,740
Oh, let's give this a pat why of 20 to squish it down a little bit so that if we save this.

77
00:04:51,700 --> 00:04:57,250
And run it when we get our first window, if we click it, when we get our second window, look at my

78
00:04:57,250 --> 00:05:00,030
fancy second window and that's cool now.

79
00:05:01,030 --> 00:05:10,390
Now you'll notice this works, but strictly speaking, you really should run a main loop for this function.

80
00:05:11,930 --> 00:05:12,780
Misspelled label.

81
00:05:13,550 --> 00:05:17,440
So we would go new dot, main loop, right?

82
00:05:17,690 --> 00:05:21,110
That's what you're really supposed to do and we save this and run it.

83
00:05:21,440 --> 00:05:23,560
Nothing really seems to.

84
00:05:24,420 --> 00:05:25,530
Have changed.

85
00:05:26,100 --> 00:05:31,230
We open the second window, you know, still works, we can open and close it, but.

86
00:05:32,300 --> 00:05:37,670
That's what you're supposed to do, so I guess you should probably do that, you know, half the time

87
00:05:37,670 --> 00:05:42,570
I forget to do that and it just works fine anyway, but whatever.

88
00:05:42,620 --> 00:05:43,640
So that's all for this video.

89
00:05:43,640 --> 00:05:47,360
In the next video, we're going to continue on with this new window thing because there's a couple of

90
00:05:47,360 --> 00:05:51,950
little odd things that you're going to want to know about the deal with creating a second window.

91
00:05:51,950 --> 00:05:55,220
For instance, if you want to put images on it, there's a little trick you have to do.

92
00:05:55,540 --> 00:06:02,300
So we'll look at that and we'll look at hiding the first window and closing the second window manually.

93
00:06:02,600 --> 00:06:04,490
And we'll look at those things in the next video.
