1 00:00:00,210 --> 00:00:03,520 I don't think that we have a huge number of tweaks to make to our UI, but 2 00:00:03,520 --> 00:00:05,160 we definitely have some. 3 00:00:05,160 --> 00:00:08,030 We need more space around entries, when we are reading them, and really, 4 00:00:08,030 --> 00:00:10,870 I'd rather not just keep scrolling the screen, let's see what we can do. 5 00:00:12,510 --> 00:00:17,160 Let's start by giving ourselves a little bit of room after we print out an injury. 6 00:00:17,160 --> 00:00:20,670 Having the menu right up against the content makes the content a little 7 00:00:20,670 --> 00:00:22,120 hard to read. 8 00:00:22,120 --> 00:00:27,370 So, let's go back to view entry again, view entries. 9 00:00:27,370 --> 00:00:31,010 This has been a very popular function for us to modify. 10 00:00:32,010 --> 00:00:37,170 So right here after we print out the content, let's print out two new lines. 11 00:00:38,250 --> 00:00:44,360 And let's also again print out the equal signs for the length of the time stamp. 12 00:00:45,430 --> 00:00:47,380 So two of the lines, and 13 00:00:47,380 --> 00:00:50,580 then as many equal signs as there are characters in the time stamps. 14 00:00:50,580 --> 00:00:53,610 Really, though, I think most of the unreadableness comes from the fact that 15 00:00:53,610 --> 00:00:57,000 everything is just printed onto the string one thing after another, 16 00:00:57,000 --> 00:00:59,970 just files down, like we've always been doing. 17 00:01:01,310 --> 00:01:03,050 We can do better than that, though. 18 00:01:03,050 --> 00:01:06,410 Let's add in the ability to clear the screen before we print something out. 19 00:01:07,730 --> 00:01:11,480 To do this, we're gonna need to call some OS level stuff, 20 00:01:11,480 --> 00:01:15,390 so let's bring in the OS library. 21 00:01:15,390 --> 00:01:18,850 So we come back up here, and we import OS. 22 00:01:20,550 --> 00:01:25,720 And I wanna make a little function that is called clear. 23 00:01:29,820 --> 00:01:33,200 And what I want this function to do is to clear the screen. 24 00:01:33,200 --> 00:01:35,410 And I'm gonna need this more than once, that's why I'm making it a function. 25 00:01:35,410 --> 00:01:39,260 If I was only gonna ever do this one time, I just write it straight into the code. 26 00:01:39,260 --> 00:01:43,390 So, what we're gonna do here is os.system, which let's us call a, 27 00:01:43,390 --> 00:01:47,580 function on the system, or sorry not a function a, like a program. 28 00:01:47,580 --> 00:01:54,100 And we're gonna call CLS if the OS's name is NT, 29 00:01:54,100 --> 00:01:58,550 which is Windows I guess if you're on really old like 98 or 30 00:01:58,550 --> 00:02:02,880 95 it won't be empty but I do believe everything else is empty. 31 00:02:02,880 --> 00:02:07,440 Else, call the function clear or the, the program clear. 32 00:02:08,510 --> 00:02:10,910 So we call cls if we're on Windows. 33 00:02:10,910 --> 00:02:14,890 We call clear if we're on Linux, Mac, whatever. 34 00:02:14,890 --> 00:02:18,322 So let's use this where we can. 35 00:02:18,322 --> 00:02:23,032 I think that whenever they do something on the menu- 36 00:02:23,032 --> 00:02:26,011 [BLANK_AUDIO] 37 00:02:26,011 --> 00:02:30,320 That we should, or whenever we show the menu rather, we should clear the screen. 38 00:02:30,320 --> 00:02:34,440 So while choice isn't Q let's call clear. 39 00:02:36,000 --> 00:02:41,020 And then, I think before we call whatever the thing is on the menu that we're gonna 40 00:02:41,020 --> 00:02:45,080 do, like add any entry, or view entries, I think we should clear the screen again. 41 00:02:46,150 --> 00:02:48,600 So, we add clear here, and we add clear here. 42 00:02:49,670 --> 00:02:50,920 Okay, I think those are pretty good. 43 00:02:50,920 --> 00:02:52,710 And then I think, the last place, 44 00:02:52,710 --> 00:02:58,060 maybe that we would put in clear would be right before we print out an entry. 45 00:02:58,060 --> 00:03:00,890 It seems like that's one of our more cluttery areas. 46 00:03:00,890 --> 00:03:03,670 So we go back to view entries yet 47 00:03:03,670 --> 00:03:09,420 again, and before we start doing our prints here, let's call clear. 48 00:03:10,580 --> 00:03:14,340 All right so it's gonna clear out our, our screen. 49 00:03:14,340 --> 00:03:14,840 Kay. 50 00:03:14,840 --> 00:03:16,705 So let's test all of this out. 51 00:03:16,705 --> 00:03:22,145 [SOUND] And look, there's our menu. 52 00:03:22,145 --> 00:03:23,790 Cool. 53 00:03:23,790 --> 00:03:26,090 So I'm gonna add an entry. 54 00:03:26,090 --> 00:03:27,230 That starts a brand new thing. 55 00:03:28,420 --> 00:03:30,335 Hello, this is a new entry. 56 00:03:30,335 --> 00:03:33,350 Ctrl+D. 57 00:03:33,350 --> 00:03:34,070 Save it, sure. 58 00:03:35,110 --> 00:03:37,710 Going back to the menu, clears out the screen again. 59 00:03:37,710 --> 00:03:38,230 Let's view. 60 00:03:39,350 --> 00:03:40,310 There's my new entry, and 61 00:03:40,310 --> 00:03:44,280 it's nicely format, I, I've got more room, everything's more nicely formatted. 62 00:03:44,280 --> 00:03:47,540 If I got to the next entry, there's just that entry. 63 00:03:47,540 --> 00:03:50,050 If I wanna delete that one, come to there, 64 00:03:50,050 --> 00:03:52,480 I'm gonna say, no, I don't wanna delete it. 65 00:03:52,480 --> 00:03:54,440 So we just moved on to the next one. 66 00:03:54,440 --> 00:03:58,210 I think we'll lose our print where we said, entry deleted, but 67 00:03:58,210 --> 00:04:00,150 that's not that big of a deal. 68 00:04:00,150 --> 00:04:02,750 So, yeah. 69 00:04:02,750 --> 00:04:03,460 That's our app. 70 00:04:03,460 --> 00:04:04,830 That's a lot better. 71 00:04:04,830 --> 00:04:08,911 I did notice one thing, which if you're typing along with me, 72 00:04:08,911 --> 00:04:10,451 you're gonna get too. 73 00:04:10,451 --> 00:04:13,252 [BLANK_AUDIO] 74 00:04:13,252 --> 00:04:16,330 Should be enter your entry, not just enter you entry. 75 00:04:16,330 --> 00:04:18,200 All right. 76 00:04:18,200 --> 00:04:20,670 That's our app, that's a whole lot better. 77 00:04:20,670 --> 00:04:22,420 Wow, that's so much better. 78 00:04:22,420 --> 00:04:25,660 About the only things I could see adding to this, would be some color coding, and 79 00:04:25,660 --> 00:04:27,200 maybe a bit of tech strapping. 80 00:04:27,200 --> 00:04:28,490 I'll leave all of that up to you. 81 00:04:28,490 --> 00:04:31,660 But I'll add a couple of handy libraries to the teacher's notes. 82 00:04:31,660 --> 00:04:32,900 Well, that's it. 83 00:04:32,900 --> 00:04:35,460 We're done with another Python course, here at Treehouse. 84 00:04:35,460 --> 00:04:37,370 Based on this new ability, you should be able to go and 85 00:04:37,370 --> 00:04:40,400 improve older projects, or start brand new ones. 86 00:04:40,400 --> 00:04:42,980 Record wins and losses on the games that we've built together. 87 00:04:42,980 --> 00:04:44,800 Or, if you did the regular Expressions course, 88 00:04:44,800 --> 00:04:47,970 stick the address book entries into a database table. 89 00:04:47,970 --> 00:04:49,570 Be sure to let me know if you build something. 90 00:04:49,570 --> 00:04:50,220 I'll see you next time.