Placeholder Image

字幕列表 影片播放

  • What's going on?

  • Everybody.

  • And welcome to part two of the key V cross platform Kuby development tutorial Siri's this video are gonna be doing is continue along.

  • We're trying to make this chat application, and the first thing we need to be able to do is fill out that form and then, like, submit the form right.

  • So we need a button to click, probably says Join or something like that.

  • And then besides just throwing in the button, we also need to handle for the event when that button is clicked.

  • So we're tapped or whatever.

  • So that's what we'll be doing today is buttons, events and just a quality of life.

  • Update immediately out the gate.

  • So let's go ahead and get started.

  • So we've got these, uh, these things all added already.

  • Now the first thing that we're gonna do is throw in a button.

  • So we're gonna say from key v dot Your i s stop but in We're going to import button.

  • Now.

  • We want to use that button.

  • So again all the widgets are placed in order, so we can just like throwing a button.

  • Right?

  • So we could say self dot Join equals button.

  • And then we could say that tax here is joined.

  • Okay?

  • And then we could say self that add a widget itself dot joint clips Don't run it there.

  • Cool.

  • So I saved that.

  • And let's just run that real quick.

  • I kind of went off screen, but anyway, here you go I p ports user name.

  • And then there's a joint button.

  • Doesn't do anything when we click it, though Now I kind of want to join button over here.

  • So this is actually really simple.

  • There's like, there's a 1,000,000 things that we could do to get this button to be moved and to place things specifically especially, People start getting fancy with layouts and silently outs.

  • And, you know, you could get really cool with this.

  • You could just have, like, a grid layout for Rome or for Rose.

  • And then each row is its own two column layout.

  • And then bang, bang, bang, bang, and then join Could be the whole thing down here, right?

  • So, yeah, you could get super fancy.

  • Yeah, you could just self doubt add widgets.

  • Ah, and in them to label.

  • So say that, uh, run that.

  • So we're adding that before we add the widget of the button and boom, we got the button oriented over to the right.

  • Uh, that's good enough for me.

  • But like I said, if you want to fix it and do it a different way, have at it.

  • So that's buttons, Okay, but obviously we want these buttons to do stuff when they're clip.

  • So what we want to do is bind a function to the budget.

  • So it's pretty easy, actually.

  • So what we're gonna say is self dot join dot bind.

  • That's just AnAnd tribute, basically, or a method of these things button that we can run, and then we're gonna bind.

  • What?

  • Well, we're going to say on press.

  • Um, there's there's probably all kinds.

  • This is the only method I've ever used.

  • But I would wager maybe if you hovered over maybe on on hold or something you might have Ah, thing I don't know.

  • Anyway, there's probably methods like that.

  • You could just assume they exist.

  • Eso check those out in the a p I documentation on press.

  • What do we want to dio self dot join.

  • But it seems to make sense, right, So we're gonna run a method called Joined Button.

  • Now that method doesn't quite yet exist, so we better probably make it.

  • So what we're gonna do is define And just so it's clear we're in the class connect page.

  • We were coding in the innit method.

  • Now we're just making another method.

  • So define join button method and self.

  • And when you click on the button, it's also going to pass or when you bind, I don't know.

  • Anyway, it's gonna pass.

  • Instance we're gonna handle for that so we can also taken instance.

  • So here, we're gonna get weaken, grab really whatever we want, right, because if someone's filled out these forms like it's a it's a live instance, right?

  • So as people are putting text inside of these fields, we can actually grab that, uh and then do something with it.

  • So not only so just like later on down the road, we're gonna talk about scheduling things and just running things.

  • So just understand that everything's running like live as you put things in.

  • It just so happens that we're like scheduling things, and it seems very script e as we click buttons or whatever, but it doesn't have to be like that, so just keep that in mind.

  • But anyway, so this event here, we're running the event.

  • Now it's just grab some stuff real quick.

  • We're just going to say port equals self, self doubt, port, not text.

  • We're in a I p equal self that I peed a text and then user name equals self die user name dot text.

  • So we're just grabbing the text values of those fields at the time of the button press.

  • But again, like I said, you could grab values of fields at any point.

  • You can have all kinds of reasons why you might grab that stuff.

  • So anyway, port i p using an infant out, let's just say print f uh, actually, let's say attempting to join I P colon ports and user name.

  • Okay, so let's save that.

  • And did I close?

  • I guess I closed my counsel window.

  • Awesome.

  • I love it when that happens.

  • Uh, let's run that again.

  • Uh, what do you hear there?

  • Pied at seven in Africa.

  • But I called a skeevy app too.

  • Okay, run that It's not close.

  • The consul, little next time.

  • You Okay?

  • So I p Let's just I'm just gonna throw in some stuff really quick and talk about that hit.

  • Join an actual.

  • Bring this back.

  • So we're attempting to join, um this Colin, this as this, we'll both 1234 Oh.

  • Oh, have a hot Maybe, I don't know, something hinky going on there.

  • There we go.

  • Okay, Cool.

  • So I'm gonna bring this down here.

  • I'm a closes.

  • Um, so one thing right of the gate, it's very tedious to keep filling out the i p the port.

  • The user name is over, and I keep going to the same one every single time.

  • So So both in development and then in actually use case, we probably actually just want to, like, save these things.

  • So I'm just gonna make that final quality of life update for us real quick.

  • And, um, so the first thing we're gonna do is basically right here.

  • We're just going to say with open preview details dot tex with the intention to write, uh, as f we're gonna say f done right.

  • And we're just going to write basically this with some common some copy pasta, comma, comma.

  • Cool.

  • Okay, so we'll save that.

  • Fix this for Pepe and awesome.

  • So with that now what we want to do is we're gonna import important s and then somewhere in this innit method, uh, we're going to get the initial values for I P port and user names.

  • So the first thing we need to know is if that file exists, because if this has never actually been run, that file won't exist.

  • So if o Estado path thought is file preview details, not text.

  • If that's the case with open this file with the intention to read as f ah, we're going to say the details of that file are, uh, there's a d equals f dot reed and then we'll actually just go and split by Kama.

  • And then what was your I p port user name?

  • So we'll just say pre V I p equals d zero and then take this and then we'll pays that twice.

  • 123 i p Poor user Nombre, if that's the case, do that.

  • Otherwise we need to handle if it doesn't, so we'll paste that in.

  • Come on, May.

  • Okay.

  • Knocking stuff over.

  • Um okay.

  • And then what we want to dio is ad in the starting text.

  • So, um, so, in text input, we can also pass a metric or a parameter called text.

  • So in this case, would be pre V i.

  • P.

  • So now what I'm gonna do is just take this copy, and then I'm gonna paste here and paste here.

  • Now, this would be preview port, and then this will be pre ve user name.

  • Cool.

  • Okay, that should be everything.

  • So let me go and save that.

  • Let me just rerun this in.

  • Uh oh.

  • Because it may be because I had the file already.

  • I've already done this.

  • Um, okay.

  • Yeah, just, like loaded it.

  • I'm gonna delete those real quick and just test to make sure everything's working the way I have it.

  • Now we run that up, So good thing.

  • Oh, right.

  • Do Okay.

  • This should be empty.

  • I'm glad I tested that.

  • Uh, so make these empties of the file doesn't exist.

  • We can't split anything and d doesn't exist either.

  • So nice.

  • Good work, everybody.

  • Basic python skills.

  • All right, so now it is empty, and yeah, I'm just gonna fill out what I had before.

  • So 1 27 001 poor 1234 It's fine for now.

  • And Centex, we hit join, and sure enough, attempting to join.

  • Close that.

  • And then we'll run that one more time.

  • And sure enough, everything's there already for us.

  • So we have to keep retyping it.

  • So, uh, I p import might change depending on what you guys planned to use for the server with sockets best basically the socket server.

  • Um, I'm probably gonna host mine, and I'm gonna work off of that.

  • Um, but I'm gonna take that down before you release these videos because there's price, all kinds of security issues that could happen.

  • So because one we're passing through key to we did very little security checks for the socket based tutorial bit, So that seems pretty rescue.

  • Let that run live and let you guys use it.

  • So I'm just gonna have you guys probably run it locally on a local port or something like that.

  • But, you know, uh okay, so that's it for now.

  • Quick shot to Martin knows recent Channel members Ivan Dixon and Matthew, You guys are awesome.

  • Thank you very much for your support.

  • If you don't know, you can join by clicking that beautiful, beautiful blue button that just beckons your clique.

  • Okay, so in the next video we'll talk about is what happens once we click joined.

  • So, yeah, we're like, handling the event, but actually probably want to actually do something I don't know useful.

  • So we need to, like, change the screen.

  • Like once we click joined.

  • We don't We don't want this layout anymore.

  • We don't really want that screen anymore.

  • We want the chat screen thing.

  • Um, yeah.

  • So how do we do that?

  • So that's what we're going to talk about in the next video questions, comments, concerns, whatever.

  • Fearfully leaving below.

  • Also join the discord.

  • Discord dot g slash Centex.

  • That's it, everybody see next time.

What's going on?

字幕與單字

單字即點即查 點擊單字可以查詢單字解釋

A2 初級

按鈕和事件 - Kivy移動和桌面應用開發/Python (Buttons & Events - Kivy Mobile and Desktop App Dev w/ Python)

  • 1 0
    林宜悉 發佈於 2021 年 01 月 14 日
影片單字