1
00:00:01,670 --> 00:00:06,860
OK, in the last video, I showed you how to create the open file dialogue box and it opened and it

2
00:00:06,860 --> 00:00:08,630
worked, but it didn't actually do anything.

3
00:00:08,660 --> 00:00:10,940
So in this video, we want to actually do something with it.

4
00:00:10,950 --> 00:00:16,550
So first, before we do anything, we don't want this to just open when our program runs, we want to

5
00:00:16,550 --> 00:00:18,860
be able to, like, click a button for it to open.

6
00:00:18,870 --> 00:00:20,710
So let's create a button first to do that.

7
00:00:20,720 --> 00:00:26,090
So my button equals and it's going to be a button and we want to put it in route.

8
00:00:27,440 --> 00:00:34,370
And we want the text to say open image or something and command.

9
00:00:35,730 --> 00:00:43,410
Equals let's call this open underscore image and let's pack this on the screen and let's give this a

10
00:00:43,410 --> 00:00:46,200
pad, why of 10, just smash it down a little bit.

11
00:00:46,440 --> 00:00:48,150
OK, so now we can create.

12
00:00:49,560 --> 00:00:50,490
Create.

13
00:00:51,520 --> 00:00:55,960
Open dialogue, box function.

14
00:00:58,470 --> 00:01:06,630
And so it's open image is what we called it, and now we just want to paste in all of this stuff in

15
00:01:06,630 --> 00:01:07,140
here.

16
00:01:10,010 --> 00:01:13,400
OK, so now this will only open when we click this button.

17
00:01:13,460 --> 00:01:16,910
Let's save this and run it just to make sure that that worked so open.

18
00:01:16,910 --> 00:01:23,380
DCPI sure enough, we've got our open image button when we click it, boom, this box appears excellent.

19
00:01:23,390 --> 00:01:24,950
So now that works much better.

20
00:01:25,160 --> 00:01:27,950
So now if we click Aspen's picture, nothing actually happens.

21
00:01:27,980 --> 00:01:31,160
So how do we do something with whatever we select?

22
00:01:31,430 --> 00:01:32,630
Well, pretty simple.

23
00:01:33,200 --> 00:01:37,340
And let's come back to our code and inside of our function here.

24
00:01:37,340 --> 00:01:40,160
Let's create a label and let's call it minor score label.

25
00:01:40,820 --> 00:01:41,690
And it's a label.

26
00:01:42,080 --> 00:01:45,200
And we want to put it in root and we want the text to equal.

27
00:01:46,160 --> 00:01:46,850
This thing.

28
00:01:50,960 --> 00:01:57,200
And let's pack this on the screen and let's give it a pad, why of 10, just to smash it down a little

29
00:01:57,200 --> 00:01:57,460
bit.

30
00:01:57,890 --> 00:01:59,960
So, OK, let's see what this does.

31
00:02:01,250 --> 00:02:03,710
And I can explain it to you or I could just show it to you.

32
00:02:04,050 --> 00:02:05,250
So let's just show it to you.

33
00:02:05,570 --> 00:02:05,930
All right.

34
00:02:05,930 --> 00:02:06,770
The box opens.

35
00:02:06,770 --> 00:02:10,400
We select Aspen PNG and boom, the.

36
00:02:14,110 --> 00:02:20,690
Location, the final location file name appears in our label, so, OK, we're done now, right?

37
00:02:20,710 --> 00:02:25,690
Basically, once we can grab that file location, we can do anything we want with it.

38
00:02:25,690 --> 00:02:27,910
If we want to open it and put that image on the screen.

39
00:02:27,920 --> 00:02:30,730
We've already learned how to do that when we looked at images in the past.

40
00:02:31,000 --> 00:02:36,040
The important thing is getting a hold of this thing right here so that we can then do something with

41
00:02:36,040 --> 00:02:36,130
it.

42
00:02:36,160 --> 00:02:37,000
So, all right.

43
00:02:37,000 --> 00:02:41,560
Let's just really quickly do something with it and come to our our new top highfather.

44
00:02:41,560 --> 00:02:45,400
We are working out a few videos ago, and I'm just going to grab all of this.

45
00:02:46,490 --> 00:02:53,600
Stuff right here, when we open this image file, come back here and then down here, let's go.

46
00:02:55,130 --> 00:03:01,230
Open picture or open image and place on screen.

47
00:03:01,890 --> 00:03:07,160
I'm just going to paste in this stuff so we've got my image and it's an image that took that photo image

48
00:03:07,520 --> 00:03:08,540
image to open.

49
00:03:08,540 --> 00:03:18,050
And then instead of calling Aspendale PMG, what we can do is grab this root file name and just pass

50
00:03:18,050 --> 00:03:19,220
it in there.

51
00:03:20,370 --> 00:03:21,870
Boom, just like that, right?

52
00:03:22,290 --> 00:03:27,950
And then again, here it is not new, we're still in our route here right now.

53
00:03:27,990 --> 00:03:29,190
This will be that.

54
00:03:29,670 --> 00:03:32,670
And then we can go IMG underscore label.

55
00:03:33,890 --> 00:03:40,850
Not pack, and let's give this a pat why of 10 to smash it down a little bit and remember this image,

56
00:03:40,850 --> 00:03:43,640
Teekay stuff is from up here that we imported.

57
00:03:43,830 --> 00:03:44,960
Remember how to do all that.

58
00:03:45,270 --> 00:03:47,120
OK, so let's walk through this again.

59
00:03:47,660 --> 00:03:52,430
We click the main button, which opens our dialog box thing right here.

60
00:03:53,030 --> 00:04:00,290
Then we whatever we select in the dialog box gets put into this thing right here, this variable root

61
00:04:00,290 --> 00:04:00,890
filename.

62
00:04:01,280 --> 00:04:01,700
Right.

63
00:04:01,730 --> 00:04:02,840
And then we can do stuff with it.

64
00:04:02,850 --> 00:04:05,480
So let's uncommented this comment out.

65
00:04:05,480 --> 00:04:05,960
This label.

66
00:04:05,960 --> 00:04:09,760
We don't need to put the location of the file on the screen anymore.

67
00:04:09,920 --> 00:04:15,410
Once we have the location of the file and screaming anymore, we can open it like this and this should

68
00:04:15,410 --> 00:04:15,730
work.

69
00:04:15,740 --> 00:04:17,330
So let's go ahead and save this.

70
00:04:18,540 --> 00:04:20,690
And run this guy one more time.

71
00:04:21,990 --> 00:04:28,080
So we have an image, we select Aspendale PMG of something happened.

72
00:04:29,110 --> 00:04:30,620
What did not work there?

73
00:04:31,300 --> 00:04:37,240
We can actually grab this and make it into a global kind of talked about this earlier.

74
00:04:37,720 --> 00:04:40,150
All right, so save this now if we run this.

75
00:04:43,560 --> 00:04:46,950
Open image like this, boom, now it works.

76
00:04:48,060 --> 00:04:55,260
And it's not quite the right size, but you get the idea that we can tinker with this if we just want

77
00:04:55,260 --> 00:04:55,890
to have fun.

78
00:04:56,160 --> 00:05:01,290
Let's change this to 500 by 700 and try this again.

79
00:05:03,270 --> 00:05:12,450
Open image, select it, boom, there it is, very cool, so pretty easy to open images using open dialogue,

80
00:05:12,480 --> 00:05:16,020
open file, dialogue box and then doing anything you want with them.

81
00:05:16,350 --> 00:05:21,990
The trick is just getting the location, the address, where the file is located, and you use that

82
00:05:21,990 --> 00:05:28,980
by clicking that dialog box thing and it just puts it in route, that filename in this sort of variable

83
00:05:29,190 --> 00:05:30,600
that you can then do whatever you want with.

84
00:05:30,600 --> 00:05:32,530
You can open it, you can do anything with it.

85
00:05:32,550 --> 00:05:34,490
So very cool and pretty easy.

86
00:05:34,500 --> 00:05:35,670
So that's all for this video.

87
00:05:35,670 --> 00:05:43,050
In the next video, we'll look at removing things from the screen labels and anything really.

88
00:05:43,200 --> 00:05:44,430
And that'll be in the next video.
