1 00:00:00,810 --> 00:00:04,290 So, we're gonna do a pop-up window, an alert window, like you do with JavaScript. 2 00:00:04,290 --> 00:00:05,990 And TkInter has one. 3 00:00:05,990 --> 00:00:08,650 But we can't use it from TkInter.whatever. 4 00:00:08,650 --> 00:00:10,600 We have to import it on its own. 5 00:00:10,600 --> 00:00:13,940 So, we'll say from tkinter import messagebox. 6 00:00:13,940 --> 00:00:16,300 And there are a lot of different message boxes. 7 00:00:16,300 --> 00:00:19,990 Some ask a question and the user can answer with a yes or no. 8 00:00:19,990 --> 00:00:24,660 Others accept input, like a text box to take in information. 9 00:00:24,660 --> 00:00:28,420 And some, like the one that we're gonna use, are just for sharing information. 10 00:00:28,420 --> 00:00:30,970 So, it's just going to put out a message. 11 00:00:30,970 --> 00:00:32,070 So let's go down here. 12 00:00:33,270 --> 00:00:34,790 Let's make a new function. 13 00:00:36,580 --> 00:00:39,350 And we're going to call it alert cuz it's our alert. 14 00:00:40,510 --> 00:00:47,802 And since it's going to get triggered, as well, we need it to take args. 15 00:00:47,802 --> 00:00:48,793 All right. 16 00:00:48,793 --> 00:00:55,229 So, we're gonna say, if not self.time left.get(). 17 00:00:55,229 --> 00:01:01,269 So, if there are no seconds left, then we want to do message box.showinfo(). 18 00:01:02,300 --> 00:01:05,193 And then the title that we want on the window, 19 00:01:05,193 --> 00:01:09,011 this right here says pymodoro.pi gui blah, blah, blah. 20 00:01:09,011 --> 00:01:11,689 We want that to say Timer done. 21 00:01:11,689 --> 00:01:14,340 I suppose it could say Pymodoro or something. 22 00:01:14,340 --> 00:01:17,985 And then our message is just going to be, Your timer is done! 23 00:01:17,985 --> 00:01:21,600 Super, super exciting [LAUGH] there. 24 00:01:21,600 --> 00:01:24,440 Okay, but now, how do I want to fire this off? 25 00:01:24,440 --> 00:01:28,279 So, we need to actually watch for stuff to happen and then fire this off. 26 00:01:28,279 --> 00:01:32,828 And this really make sense to have fired whenever this runs out. 27 00:01:32,828 --> 00:01:35,801 Now, I don't want to do it and update because that's weird. 28 00:01:35,801 --> 00:01:39,722 I've had to watch for running conditions and make sure the start button is disabled 29 00:01:39,722 --> 00:01:43,250 or the stop button is enabled, and then, it's just a lot of trouble. 30 00:01:43,250 --> 00:01:44,900 So, let's not worry about that. 31 00:01:44,900 --> 00:01:47,762 Let's do it with another trace. 32 00:01:47,762 --> 00:01:53,665 So, if we come back up here to our init, and we have this time left. 33 00:01:53,665 --> 00:01:57,414 Let's do self.time_left.trace, and 34 00:01:57,414 --> 00:02:03,070 we want whenever this is written to, to call self.alert. 35 00:02:03,070 --> 00:02:07,110 So, whenever our update method changes the number of seconds that are left, 36 00:02:07,110 --> 00:02:12,300 our alert method checks to see if it should fire the message box. 37 00:02:12,300 --> 00:02:13,040 Let's try this out. 38 00:02:14,240 --> 00:02:16,645 And I have a feeling this may end up firing off a second or 39 00:02:16,645 --> 00:02:21,135 two early due to the order of stuff. 40 00:02:21,135 --> 00:02:23,843 But not that big of a deal, especially not in something that we're just like, 41 00:02:23,843 --> 00:02:25,083 [NOISE] let's see what we can build. 42 00:02:25,083 --> 00:02:28,371 Feel free to experiment and see if you can make it not do that. 43 00:02:28,371 --> 00:02:33,730 But let's see, so four, three, two, one. 44 00:02:33,730 --> 00:02:36,350 Our timer's done, cool. 45 00:02:36,350 --> 00:02:39,010 So, yeah, you can see it's about a second early, 46 00:02:39,010 --> 00:02:42,300 it fires off, but not that big of a deal. 47 00:02:42,300 --> 00:02:43,485 So, there you go. 48 00:02:43,485 --> 00:02:49,004 In just a few short videos, and I don't know, 100 lines of code? 49 00:02:49,004 --> 00:02:52,353 Let's see, how many lines did we add here? 50 00:02:52,353 --> 00:02:54,260 114! 51 00:02:54,260 --> 00:02:58,610 114 lines of code, a few short videos, we have built a fully function Pymodoro 52 00:02:58,610 --> 00:03:03,480 application that'll let us do a lot of work very, very quickly. 53 00:03:04,665 --> 00:03:08,290 While our little app might not do much, it gives us a good glimpse of what all we can 54 00:03:08,290 --> 00:03:10,820 do with the Kintor and the rest of Python. 55 00:03:10,820 --> 00:03:13,770 Whether you're building your whole app into Kintor or just using it at a proof 56 00:03:13,770 --> 00:03:17,440 of concept, I think this library will serve you well in the future. 57 00:03:17,440 --> 00:03:20,530 I know people making games in it, and even using TkIntor to control lasers. 58 00:03:20,530 --> 00:03:22,980 I can't wait to see what you do with it.