title
Scheduling tasks/functions/methods - Kivy Mobile and Desktop App Dev w/ Python

description
In this part of the Kivy tutorials, we're going to cover how to schedule tasks to run (either just once, or repeatedly), as well as actually connect to our chat server. Text-based tutorial and sample code: https://pythonprogramming.net/scheduling-clock-kivy-application-python-tutorial/ Channel membership: https://www.youtube.com/channel/UCfzlCWGWYyIQ0aLC5w48gBQ/join Discord: https://discord.gg/sentdex Support the content: https://pythonprogramming.net/support-donate/ Twitter: https://twitter.com/sentdex Facebook: https://www.facebook.com/pythonprogramming.net/ Twitch: https://www.twitch.tv/sentdex G+: https://plus.google.com/+sentdex

detail
{'title': 'Scheduling tasks/functions/methods - Kivy Mobile and Desktop App Dev w/ Python', 'heatmap': [], 'summary': 'Learn kivi scheduling using kivi clock and socket integration, with a focus on controlling screen changes and setting up ui tasks, including connecting to the info screen and implementing connect method with scheduled tasks. also, understand setting up socket values for port, ip, and username, connecting to the server, handling errors, and creating a chat page method.', 'chapters': [{'end': 110.61, 'segs': [{'end': 85.297, 'src': 'embed', 'start': 15.455, 'weight': 0, 'content': [{'end': 21.578, 'text': "But there's going to be times where you just simply want to control a changed screen or other things in general.", 'start': 15.455, 'duration': 6.123}, {'end': 24.64, 'text': 'So we know how to use events to make things happen.', 'start': 21.658, 'duration': 2.982}, {'end': 31.391, 'text': 'Now what we want to talk about is how to just schedule a thing to happen either one time or on some sort of cycle going into the future.', 'start': 24.68, 'duration': 6.711}, {'end': 33.712, 'text': "So to do that, we're going to use the KIVI clock.", 'start': 32.031, 'duration': 1.681}, {'end': 38.757, 'text': "So it's just from KIVI.clock, we're going to import clock.", 'start': 33.793, 'duration': 4.964}, {'end': 49.322, 'text': "Now the other thing that we're going to go ahead and do is take the socket code from the socket tutorial and just put that in our directory here.", 'start': 40.296, 'duration': 9.026}, {'end': 52.965, 'text': "So I'm going to go ahead and make two new files.", 'start': 49.462, 'duration': 3.503}, {'end': 57.228, 'text': 'One is going to be socket client.py.', 'start': 53.425, 'duration': 3.803}, {'end': 63.052, 'text': 'Yes And the other is going to be socket server.py.', 'start': 57.788, 'duration': 5.264}, {'end': 66.605, 'text': 'uh.. dot pie uh..', 'start': 64.602, 'duration': 2.003}, {'end': 72.028, 'text': "the code for both of these is hosted on python program internet i'll put links in the description uh..", 'start': 66.605, 'duration': 5.423}, {'end': 74.35, 'text': 'if you want to learn more about sockets again uh..', 'start': 72.028, 'duration': 2.322}, {'end': 76.051, 'text': 'go to the sockets tutorial uh..', 'start': 74.35, 'duration': 1.701}, {'end': 79.053, 'text': 'because this whole thing is, all you know, completely explained.', 'start': 76.051, 'duration': 3.002}, {'end': 85.297, 'text': 'so, like socket server, dot pie, all of this code is just a direct copy and paste from the tutorial code from there.', 'start': 79.053, 'duration': 6.244}], 'summary': 'Learn to schedule events with kivi clock and import socket code for socket client.py and socket server.py', 'duration': 69.842, 'max_score': 15.455, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hsnch676Lco/pics/hsnch676Lco15455.jpg'}], 'start': 1.508, 'title': 'Kivi scheduling with kivi clock', 'summary': 'Introduces scheduling in kivi using kivi clock and integrating socket code, emphasizing the need to control screen changes, and providing relevant tutorial code links.', 'chapters': [{'end': 110.61, 'start': 1.508, 'title': 'Kivi scheduling with kivi clock', 'summary': 'Introduces scheduling in kivi using kivi clock and integrating socket code from the tutorial, emphasizing the need to control screen changes and other events by scheduling them, while also providing links to the relevant tutorial code.', 'duration': 109.102, 'highlights': ['The chapter discusses the need to control screen changes and other events by scheduling them using KIVI clock.', 'It emphasizes the integration of socket code from the tutorial for handling socket operations within the KIVI framework.', 'The tutorial provides links to the relevant tutorial code for socket operations, offering further resources for learning about sockets and their implementation.']}], 'duration': 109.102, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hsnch676Lco/pics/hsnch676Lco1508.jpg', 'highlights': ['The chapter discusses the need to control screen changes and other events by scheduling them using KIVI clock.', 'It emphasizes the integration of socket code from the tutorial for handling socket operations within the KIVI framework.', 'The tutorial provides links to the relevant tutorial code for socket operations, offering further resources for learning about sockets and their implementation.']}, {'end': 223.384, 'segs': [{'end': 165, 'src': 'embed', 'start': 110.61, 'weight': 0, 'content': [{'end': 118.773, 'text': "because this is just a kiwi tutorial where i'm just trying to show the ui and how to do kiwi stuff, not really trying to go over sockets again.", 'start': 110.61, 'duration': 8.163}, {'end': 122.435, 'text': "so anyway, uh cool, So we've got that stuff.", 'start': 118.773, 'duration': 3.662}, {'end': 129.64, 'text': 'Now what we want to do is basically when someone connects right now, we do this.', 'start': 122.895, 'duration': 6.745}, {'end': 130.822, 'text': 'We show the info screen.', 'start': 129.701, 'duration': 1.121}, {'end': 139.209, 'text': 'And then after the info screen is when we want to eventually change the screen to the actual chat screen.', 'start': 131.342, 'duration': 7.867}, {'end': 141.965, 'text': 'Unless we throw an error.', 'start': 141.144, 'duration': 0.821}, {'end': 144.386, 'text': "So we're going to show the info screen.", 'start': 142.605, 'duration': 1.781}, {'end': 150.69, 'text': "And then what we want to do is we're going to say clock.", 'start': 145.407, 'duration': 5.283}, {'end': 152.872, 'text': "Actually, it's capital C.", 'start': 151.451, 'duration': 1.421}, {'end': 157.935, 'text': 'Clock.schedule once.', 'start': 152.872, 'duration': 5.063}, {'end': 160.677, 'text': "And then what's the thing we want to schedule?", 'start': 158.876, 'duration': 1.801}, {'end': 165, 'text': 'And then how many seconds in the future do we want to schedule at??', 'start': 161.077, 'duration': 3.923}], 'summary': 'Kiwi tutorial demonstrating ui and scheduling with clock.schedule_once', 'duration': 54.39, 'max_score': 110.61, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hsnch676Lco/pics/hsnch676Lco110610.jpg'}, {'end': 216.659, 'src': 'embed', 'start': 187.351, 'weight': 2, 'content': [{'end': 193.674, 'text': "So we're gonna say define connect, uh, the instance, and then we're going to use an underscore here.", 'start': 187.351, 'duration': 6.323}, {'end': 198.516, 'text': "The underscore is, uh, basically anytime you schedule something, it's going to pass two things.", 'start': 193.694, 'duration': 4.822}, {'end': 200.517, 'text': "It's going to pass the instance, but it's also going to pass.", 'start': 198.536, 'duration': 1.981}, {'end': 206.354, 'text': 'how many seconds has gone by transpired since the schedule.', 'start': 201.092, 'duration': 5.262}, {'end': 210.936, 'text': "So in this case it'll be one, and it will always be one, because we're scheduling once,", 'start': 206.974, 'duration': 3.962}, {'end': 216.659, 'text': "but sometimes you're going to schedule on a cycle and it might be useful to know how long it's been since that scheduling.", 'start': 210.936, 'duration': 5.723}], 'summary': 'Using an underscore to pass instance and time since schedule for connections.', 'duration': 29.308, 'max_score': 187.351, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hsnch676Lco/pics/hsnch676Lco187351.jpg'}], 'start': 110.61, 'title': 'Kiwi tutorial ui', 'summary': 'Focuses on setting up the ui and scheduling tasks in a kiwi tutorial, including connecting to the info screen and implementing the connect method with scheduled tasks.', 'chapters': [{'end': 223.384, 'start': 110.61, 'title': 'Kiwi tutorial: ui and kiwi stuff', 'summary': 'Focuses on setting up the ui and scheduling tasks in a kiwi tutorial, including connecting to the info screen and implementing the connect method with scheduled tasks, such as showing the info screen and transitioning to the chat screen.', 'duration': 112.774, 'highlights': ['The chapter focuses on setting up the UI and scheduling tasks in a kiwi tutorial, including connecting to the info screen and implementing the connect method with scheduled tasks, such as showing the info screen and transitioning to the chat screen.', "The tutorial demonstrates scheduling a task using Clock.schedule_once, with the example of scheduling the 'self.connect' method to execute one second into the future.", 'The connect method is defined to handle scheduled tasks, utilizing the passed instance and time elapsed information for potential use in the future.']}], 'duration': 112.774, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hsnch676Lco/pics/hsnch676Lco110610.jpg', 'highlights': ["The tutorial demonstrates scheduling a task using Clock.schedule_once, with the example of scheduling the 'self.connect' method to execute one second into the future.", 'The chapter focuses on setting up the UI and scheduling tasks in a kiwi tutorial, including connecting to the info screen and implementing the connect method with scheduled tasks, such as showing the info screen and transitioning to the chat screen.', 'The connect method is defined to handle scheduled tasks, utilizing the passed instance and time elapsed information for potential use in the future.']}, {'end': 732.009, 'segs': [{'end': 254.013, 'src': 'embed', 'start': 224.284, 'weight': 0, 'content': [{'end': 228.125, 'text': "Now what we're going to do is we're going to set up the values for port, IP, and username.", 'start': 224.284, 'duration': 3.841}, {'end': 232.966, 'text': 'So port is just going to be an integer of self.port.text.', 'start': 228.185, 'duration': 4.781}, {'end': 236.347, 'text': 'The IP will be self.ip.text.', 'start': 233.486, 'duration': 2.861}, {'end': 241.228, 'text': 'And the username will be self.username.text.', 'start': 237.447, 'duration': 3.781}, {'end': 245.005, 'text': 'and then we want to connect.', 'start': 243.464, 'duration': 1.541}, {'end': 254.013, 'text': "so the first thing I'm going to do before we do that is come over here and we're going to import socket underscore client and just for the record,", 'start': 245.005, 'duration': 9.008}], 'summary': 'Setting up values for port, ip, and username to connect using socket client.', 'duration': 29.729, 'max_score': 224.284, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hsnch676Lco/pics/hsnch676Lco224284.jpg'}, {'end': 436.258, 'src': 'embed', 'start': 408.09, 'weight': 1, 'content': [{'end': 412.151, 'text': "it's gonna be listening for connections which we can't do until we've connected.", 'start': 408.09, 'duration': 4.061}, {'end': 416.773, 'text': 'okay, cool, makes sense to me anyways, hopefully you guys understand.', 'start': 412.151, 'duration': 4.622}, {'end': 430.051, 'text': "so now what we want to say is define, create, chat, uh, page self, And what we wanna do is basically the same stuff that we've done before.", 'start': 416.773, 'duration': 13.278}, {'end': 436.258, 'text': "So chat page will equal chat, whoops, chat page, which we also need to create, but we'll get there.", 'start': 430.091, 'duration': 6.167}], 'summary': 'Setting up to listen for connections and defining chat page.', 'duration': 28.168, 'max_score': 408.09, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hsnch676Lco/pics/hsnch676Lco408090.jpg'}, {'end': 495.956, 'src': 'embed', 'start': 468.495, 'weight': 2, 'content': [{'end': 472.879, 'text': "And again, we're just separating it out because we have to connect before we can run this.", 'start': 468.495, 'duration': 4.384}, {'end': 478.724, 'text': 'But as soon as we connect, then we basically run this method that adds it to our list of possible screens.', 'start': 473.299, 'duration': 5.425}, {'end': 485.89, 'text': "So it's still at this point, we could switch to the info or even the connect screen if we wanted, or any other screen that we want to add later.", 'start': 479.344, 'duration': 6.546}, {'end': 487.532, 'text': 'We just need to run this.', 'start': 486.451, 'duration': 1.081}, {'end': 489.934, 'text': "We can't run this at the same time as we run these.", 'start': 488.032, 'duration': 1.902}, {'end': 495.956, 'text': "Unless we connect it immediately, but then it wouldn't make sense to fill in the form.", 'start': 491.434, 'duration': 4.522}], 'summary': 'Connecting before running method adds screen to list of possible screens in application.', 'duration': 27.461, 'max_score': 468.495, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hsnch676Lco/pics/hsnch676Lco468495.jpg'}, {'end': 655.009, 'src': 'embed', 'start': 615.933, 'weight': 3, 'content': [{'end': 625.815, 'text': "So what we're going to say here is clocked on schedule, uh, underscore once we'll do assist dot exit, and we'll do that in 10 seconds.", 'start': 615.933, 'duration': 9.882}, {'end': 629.416, 'text': 'Uh, do we have sis imported? No.', 'start': 627.195, 'duration': 2.221}, {'end': 634.217, 'text': "So we'll also import sis.", 'start': 629.436, 'duration': 4.781}, {'end': 642.663, 'text': "Great Okay, that's a lot of code that we've just thrown together, so let's see if it works.", 'start': 635.217, 'duration': 7.446}, {'end': 647.365, 'text': "Quick guess of how many typos I've made.", 'start': 644.584, 'duration': 2.781}, {'end': 652.848, 'text': 'Pi-37, KiwiApp, one, two, three, four.', 'start': 649.206, 'duration': 3.642}, {'end': 655.009, 'text': 'Come on, we can do it.', 'start': 653.748, 'duration': 1.261}], 'summary': 'Coding process: scheduling function to run in 10 seconds, importing sis, testing for errors.', 'duration': 39.076, 'max_score': 615.933, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hsnch676Lco/pics/hsnch676Lco615933.jpg'}], 'start': 224.284, 'title': 'Setting up socket connection in python', 'summary': 'Explains the process of setting up socket values for port, ip, and username, connecting to the server, handling errors, and creating a chat page method, with a focus on the code structure and order of execution.', 'chapters': [{'end': 732.009, 'start': 224.284, 'title': 'Setting up socket connection in python', 'summary': 'Explains the process of setting up socket values for port, ip, and username, connecting to the server, handling errors, and creating a chat page method, with a focus on the code structure and order of execution.', 'duration': 507.725, 'highlights': ['The chapter covers setting up values for port, IP, and username and attempting to connect to the server in Python, with an emphasis on the code structure and order of execution.', 'It explains handling errors and creating a chat page method, focusing on the importance of connecting before running the method and the sequence of operations.', 'The chapter also touches on the significance of adding the chat page to the list of possible screens only after establishing a connection and emphasizes the order of execution for the method.', 'It provides insights into the show error function and the use of clocked on schedule to exit after 10 seconds, demonstrating the error handling and execution order in the code.']}], 'duration': 507.725, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hsnch676Lco/pics/hsnch676Lco224284.jpg', 'highlights': ['The chapter covers setting up values for port, IP, and username and attempting to connect to the server in Python, with an emphasis on the code structure and order of execution.', 'It explains handling errors and creating a chat page method, focusing on the importance of connecting before running the method and the sequence of operations.', 'The chapter also touches on the significance of adding the chat page to the list of possible screens only after establishing a connection and emphasizes the order of execution for the method.', 'It provides insights into the show error function and the use of clocked on schedule to exit after 10 seconds, demonstrating the error handling and execution order in the code.']}], 'highlights': ["The tutorial demonstrates scheduling a task using Clock.schedule_once, with the example of scheduling the 'self.connect' method to execute one second into the future.", 'The chapter discusses the need to control screen changes and other events by scheduling them using KIVI clock.', 'The chapter covers setting up values for port, IP, and username and attempting to connect to the server in Python, with an emphasis on the code structure and order of execution.', 'It explains handling errors and creating a chat page method, focusing on the importance of connecting before running the method and the sequence of operations.', 'It provides insights into the show error function and the use of clocked on schedule to exit after 10 seconds, demonstrating the error handling and execution order in the code.', 'The chapter focuses on setting up the UI and scheduling tasks in a kiwi tutorial, including connecting to the info screen and implementing the connect method with scheduled tasks, such as showing the info screen and transitioning to the chat screen.', 'It emphasizes the integration of socket code from the tutorial for handling socket operations within the KIVI framework.', 'The tutorial provides links to the relevant tutorial code for socket operations, offering further resources for learning about sockets and their implementation.', 'The connect method is defined to handle scheduled tasks, utilizing the passed instance and time elapsed information for potential use in the future.', 'The chapter also touches on the significance of adding the chat page to the list of possible screens only after establishing a connection and emphasizes the order of execution for the method.']}