Transcript #64: The GUI phoenix rises with wxPython
Return to episode page view on github00:00 Hello and welcome to Python Bytes where we deliver Python news and headlines directly to your earbuds.
00:05 This is episode 64 recorded February 7th, 2018. I'm Michael Kennedy.
00:11 And I'm Brian Okken.
00:12 And we're excited to be here with you today. We have a ton of good stuff that we've uncovered to share. Very exciting. Before we get to that, though, I just want to say thank you to DigitalOcean.
00:20 Check them out at do.co/python. There's some really awesome news from them and I'll share share that with you in a little bit.
00:28 But right now, I'm kind of in love with this project that you picked right now, Brian.
00:32 Tell me about it.
00:32 - Well, it's WXPython.
00:34 We've heard of this before, but when we've been talking about GUI development and desktop development lately, and the WXPython folks contacted us and said, "Hey, we are Python 3, "and version 4, code name Phoenix, is alive and usable." - That is really cool, because WXPython, there had been a really old version, And I mean, I think we all can see what Phoenix means in terms of a project, right?
01:00 It's sort of reborn in this new modern Python 3 UI.
01:04 Very exciting.
01:05 - The underlying WX toolkit had been, it also underwent a change and the WX widgets project has been updated.
01:13 And then the WX Python on top of all that has been updated.
01:17 And it's something that I think I've developed with years ago and sort of discounted because it had an old look, but now it looks nice and people should check it out.
01:27 - Yeah, that was one of my two major, major complaints, maybe one of three, about the Python GUI stuff.
01:33 And obviously we're still on this kick and I think it's a good one actually.
01:37 But the fact that a lot of these UI toolkits look like they've jumped in Marty McFly's car and like been transported from the early 90s into your computer and they got this old fashioned sort of look, they just looked out of place, right?
01:52 And so the WX Python stuff looks really modern.
01:55 It looks like it belongs on a lot of the platforms, at least Mac, Windows and Linux that I've been playing with lately.
02:00 So I'm really happy to see this coming along.
02:02 The other one, of course, I would love that like visual designer sort of tooling in there.
02:08 But you know, I'm happy with this thing is coming along has been re-released.
02:11 That's awesome.
02:12 On their startup page, there's a there's a like a, you know, after you do all the downloads for it, there's a five line application that you can use to try it out.
02:20 And that's pretty slick.
02:22 it's fast to get something up and running.
02:25 I tried it out yesterday, so it's good.
02:27 - Very cool.
02:28 So I have a little question, a little tech interview type question for you, Brian.
02:33 Did you know that you can define a Python function and just put triple dots after it and just kind of say, you know, actually I don't want to define it?
02:43 - I did not know that.
02:44 - I did not know that either.
02:46 However, part of my experience of going to PyCascades was to meet Lucas who gave this amazing talk from, he's from Facebook and Instagram about how they're doing gradual typing in Python and how they're adding types to like the millions of lines of code at Facebook slowly.
03:06 And this whole process they went through, it's super interesting.
03:08 I'm having him already recorded, having going to have him sort of in real time for the way people experience it on Talk Python, talking about it.
03:16 And one of the projects that came out of there that I thought was really interesting is this thing called typeshed.
03:22 Have you heard of typeshed?
03:24 - I have, yeah.
03:24 - Yeah, so typeshed is this place that contains the external type annotations, basically the signatures for everything in the Python standard library.
03:34 - Okay.
03:35 - So you go in there and you'll find functions or classes with methods and whatnot.
03:40 And you'll see stuff like def visit self common node colon AST this is like from the AST module.
03:48 So it'll tell you the type and it says, arrow goes to any, for example, colon, and then just dot, dot, dot, and that's it.
03:54 And this is a way in which you can define these external types in these PYI stubs.
04:01 So it's like a normal Python file that Python can interpret, except for all the methods are empty.
04:07 You know, there's a couple of annotations that talk about, sorry, a couple of peps that talk about the annotations and how this is working and so on.
04:14 And these are just the annotations people know.
04:16 But what's pretty interesting is that this is actually what mypy uses, like this get repository of what Python looks like in terms of types.
04:28 This is what mypy uses, the static type checker, as well as this is what PyCharm uses to get all of its magic.
04:36 So PyCharm is much better than many, many editors about going, "Oh, you know, if you call, like, what, right, you call some method on this other thing, it returns this other type and you hit dot and you can see all the autocomplete for me like where did that come from it came from typeset actually.
04:51 So I thought this was pretty interesting.
04:52 And the other thing that is really cool about this and it doesn't look like people are using it this way very much.
05:00 So I'm, I'm putting this out there as a call to everyone who cares about Python three, who wants their library to be very rich with inside these various editors and type checkers to take a moment and document their packages signatures here.
05:15 So there's a place to put third party packages like requests or flask or you know, you name it.
05:22 If you run an open source project that has a package that people use, you can come over here and put yours in and then that will be picked up by all the other things.
05:31 So it's pretty cool.
05:33 - Okay, that's interesting.
05:34 We're not sure how they avoid name collision on that.
05:36 - They basically structure, there's a third party folder and then I think it's just the next subfolder the name of your package, which is unique on PyPI.
05:44 Okay, yeah, right.
05:45 So it's probably okay.
05:47 I hadn't heard of typeshed.
05:48 I knew that you could annotate your signatures and stuff, but I didn't know that there's this one place that's kind of being used as this common source.
05:57 So I thought that was pretty cool.
05:58 Yeah, and I'm curious about, so are these Python stub files, is that the only thing that they're used for, is type?
06:05 I don't know.
06:06 I had never heard of them before, but apparently...
06:08 Interesting.
06:09 Yeah, it's this new signature. It reminds me a little bit of what happened a few years ago with TypeScript, where I think it's called definitely typed, I can't remember where there's now this massive Git repository of all these external JavaScript libraries that want to interact with the typed version of JavaScript.
06:28 And so they all have basically like there's this similar concept of just the signature descriptions without the implementation in this one giant Git repository. So this is kind of cool to see it happening in the Python space. Yeah, definitely. All right.
06:41 One of the things I wanted to, I think that Ned Batchelder's coverage tool is super cool.
06:47 The same caveats as normal is don't be too enticed with trying to search for a hundred percent code coverage in your tests But it's useful tool in its own otherwise anyway, but he coverage 4.5 just came out and he added just one new feature and this new feature is pretty darn cool It's the configurator plugins Feature which allows you you kind of have to read it a bit and get your head around it But the idea is there's a lot of people that have different configurations or different run configurations of their code and Some of the code is intentionally not supposed to run at certain times So it throws up honoring all these different like different requests from people to put new features in as this configurator plug-in feature so that you can do your own pragmas ahead of time you run a little bit of code before you run the rest of your code and You can comment out things as an example for instance on the in the pytest book I had an application that used both Two different used both tiny DB and Mongo DB as two different options So I would want to run my test on the whole thing using tiny and then also the whole thing using Mongo But I don't want to there's some of the code that's only for tiny and some of the code is only for Mongo So it doesn't make sense to run coverage on that those parts in those configurations.
08:12 So that'd be a great use for that.
08:14 Yeah, that's really cool.
08:15 Because it's really easy to say, okay, we're at 80% coverage, we got to keep going, like, how do we get this higher, right?
08:21 But there's some stuff that should just kind of be left alone.
08:24 And this is a nice way to say, right now, you should not consider this bit of code, because who knows, maybe it's like some sort of little utility script that you're just throwing in, and you don't actually want it to be run as part of your package.
08:37 knows. It's pretty cool. Yeah, so you know what else is pretty cool is the recent changes that the folks over at DigitalOcean just made. So they've always been the incredible affordable hosting and basic virtual server space. They've sort of made places like AWS react in like extreme ways to try to keep up with them. So that's pretty cool but they just recently more or less just doubled everything that you get for the price. So for like $5 you get a server worth a gig of RAM and 25 gigs of SSD.
09:09 It's pretty sweet.
09:10 And even includes a terabyte of transfer, which by the way, at AWS rates, that's $93 worth of bandwidth.
09:15 $10, two gigs.
09:18 If you pay like 20 bucks, you get four gigs, 80 gigs of SSD, couple CPUs.
09:23 It's just crazy some of the prices that they have now over here.
09:27 So if you're looking to do sort of virtual server stuff or things like that, definitely check them out at do.co/python.
09:34 they've got some really cool options now.
09:36 - That's great.
09:37 - Yeah, definitely.
09:38 And thank you Digital Edition for supporting the show.
09:39 It helps us keep going.
09:41 So we've already talked about, Brian, the fact that neither of us are really into gaming, right?
09:46 I've been playing a little bit of Formula One, you know, with like the steering wheel thing.
09:49 That's kind of a fun simulation, but generally gaming, not so much with either of us.
09:53 But I have some gaming news that is pretty interesting.
09:56 It doesn't have to do with playing games.
09:58 It has to do with the creation of games and 3D worlds.
10:01 So you may know, I'm sure that you know personally, but people listening may know that Python is actually used quite a bit to automate and manage and sort of build the pipeline between all these different tools and all these different people at these massive game and movie companies, right?
10:20 - Yeah, that's pretty cool.
10:21 - Yeah, so if you've got to go from like Maya over to some other tool, or you've got these hundreds of gigs of files and they need to be transformed and processed and whatnot, That's a challenge and a lot of people have built sort of custom versions of that.
10:36 So the big news here is that Unreal, the Unreal Engine, which is one of the most significant sort of 3D game engines there is, they're now integrating Python deeply into its sort of processing pipeline, not its necessary execution, but they plan to integrate Python into the Unreal Engine for data, basically for this data pipeline.
10:58 - That's great.
10:59 - Yeah, it's cool, right?
10:59 So this is from Autodesk and they said, hey, we're gonna give you a glimpse of what we're doing.
11:02 So maybe somebody's built like a model in 3D Max and it's like this super intense, ultra, ultra fine quality.
11:11 You know, every single thing is modeled.
11:13 The example I have in this article we're linking to is like, there's a motorcycle and the tires on the motorcycle have those little, like, you know, those little dots, those little sticky pieces of rubber that come out on like new tires, where they come out of the mold and they're still like sticking out.
11:28 So they're like, we don't need that in the game, right?
11:31 This is going to kill the performance if we actually put every little bit of these like knobby things and stuff into the model that ends up in the 3D in the Unreal Engine, right?
11:41 So they're basically building this pipeline where you can say, in Python, why don't we just delete all the objects that are probably too small for people to notice anyway, and just do that automatically.
11:52 Do level of details models, you can like merge objects together.
11:56 you could say actually create a bunch of different motorcycles by automatically taking the source one and replacing the material that is, say, the fenders and the gas can and stuff to change it from, say, a light blue to a purple, shiny motorcycle.
12:13 And so all of this is automatic.
12:14 So once it's automatic, you can make a change at the beginning of the process and replicate this entire workflow, which is pretty cool, and it's awesome to see that Python's the choice for it.
12:24 - Yeah, very cool.
12:24 So just one more example of people using Python in ways that I had no idea existed. Yeah, yeah, pretty cool Good job on real. Yeah, good job and real and Autodesk And they're gonna have a brand new version of Python to work with pretty soon, aren't they?
12:37 I think we mentioned Python 3 7 last week, but the Python 3 7 0 beta 1 is out and Because it's now beta instead of alpha that means the feature sets I think I might get this right the feature sets frozen and we're just tweaking it, making sure it's all tight and everything and tested.
12:56 But beta means that there's beta testers.
12:59 And I was just thinking, if it's not people like you and me in our community that listen to this, who is it? So I think we are, I'm just putting a call to action out there to go pick a few of the features that are coming up and take test things out, make sure it works in you and report bugs otherwise.
13:15 Yeah, and there's definitely some cool features in there.
13:18 Like we talked about data classes last week, that being in there, but there's actually a bunch of changes.
13:23 And, you know, it's one of these things, speak now or forever hold your peace, it's going to come out in June.
13:30 So here's your chance to test it.
13:32 I was going to take a look at the breakpoint feature and the data classes and maybe a couple of the others and give it a whirl.
13:38 Nice. So do you know if there's easy ways with things like talks and stuff to go ahead and run your tests on Python 3.7?
13:44 Yeah, of course.
13:46 you can set up 3.7 as one of the pythons to test everything.
13:51 Yeah, that's one of the ways I'm going to test this.
13:53 I've got to make sure that there's new versions of pytest as well, and I want to make sure that all combinations of Python, all recent versions of Python and pytest work with all the demo code I have in my book, and doing that manually is just too much work, so I'll use Tox for that.
14:09 Yeah, that's a complete nightmare.
14:11 Yeah, tell people really quick, I know some people know about Tox, but not everyone.
14:14 Tell people what, like, where does Tox fit in?
14:17 Because I thought you were a pytest guy.
14:18 What's up with this testing with Tox thing?
14:20 Well, Tox is sort of like a top-level scripter thing, and I'm totally going to get it wrong.
14:28 But the way I use it really is to pick multiple configurations to, you can have multiple combinations of different libraries together or configurations of your system and test them separately.
14:41 Yeah, nice.
14:42 So you could say test on pypi and cpython and multiple versions of either of those in a single test run, right?
14:50 But the system will like configure sort of the interpreter or the runtime for that, right?
14:55 It goes out and by default, you can turn off or on all these features, but by default it takes your, like let's say a package that is a Python package, and it runs its setup function to create an installable Python wheel, I think, and then it creates a virtual environment, installs your package and all of its dependencies, and then runs the tests on it, and then reports on that.
15:18 And then it does it again for however many different configurations you've got set up.
15:22 Alright, so for our final item, the one that I want to cover is similar, you were talking about a new release of Python coming out in beta.
15:29 I want to just sort of hit a whole bunch of other things that were released that were pretty interesting on a couple levels.
15:35 So first of all, I think some people use this web framework, it's called Django.
15:39 What do you think, Brian?
15:40 Yeah, quite a few.
15:42 So they just announced that they had a security release to fix some issues in around authentication and basically the login infrastructure in Django.
15:53 So if you're using 2 or 1.11, you may want to check that out.
15:57 Right. So there's been like, you know, here's the testing thing.
16:00 There's been a regression. There was a problem. It was fixed.
16:03 And now it's unfixed. It's fun when problems unfix themselves.
16:06 So the release is with the unfixed one?
16:08 fixed one or this puts the fix back. Okay. And then two more around Python three, one is Python three, four, there's a security release there. And one is Python three, five, there's also a security release there. So respectively, the versions are 348 and 355. And there's apparently some problem with this internal bit called lib expat, as far as I tell us like an XML parsing library, and there's some kind of issue with that. That sounds not good. Like people could send you bad XML and bad things happen. So be aware and just a reminder to everyone and if anything like this happens in Python 2 shortly, there will be no fixes. You're just going to have to live with it after it goes end of life. So that's good that they're fixing these. I suspect, I don't know when 3.4 is gone. End of life, right? 3.3 I think is now out. Anyway, the final one I said at a lot of releases is channels. So these are Django channels are pretty interesting in that they add like an asynchronous way to write Django WebSocket and these types of things actually had the guy behind this on Python I linked to the interview there. But this is sort of a complete rewrite. This is channels to Oh, it's a major rewrite and most notably, Python two, seven, even Python 3.4 are no longer supported. They're fully legacy Python, they're out, it's 3.5 and above is all this works on. So I suspect some of that might have to do with Django 2. But also it being this async thing, maybe they use the async and await keywords, and it just doesn't work in 3.4 or below. So but yeah, it's all pretty cool bunch of new releases. So if you're using these and want to check them out, do. That's it for our news this week, Brian, what items do you have to share? Well, I've got a couple exciting things. Yes, you do. I had submitted five talks to PyCon and one of them was accepted. Congratulations. That's awesome. It's a talk both. I'm going to do it together with Paul Everett from the PyCharm team. So it'll be PyCharm and pytest. And that'll be fun. That's gonna be really, really fun. The two of us also are going to do a webinar coming up on the 22nd of February and a similar topic, a little bit more advanced.
18:25 So we're gonna dive into how to productively and effectively use pytest within PyCharm.
18:30 - Oh, that is really cool.
18:31 You know what I'm doing right now?
18:33 I'm gonna register.
18:34 After I'm done signing up, that'll be really fun.
18:37 And then all these, of course, get recorded afterwards.
18:40 Right, so it's typically an hour of Q&A, lots of fun.
18:44 But if you can't make it live, you know you should still register because then you'll get a notice that, hey, the recording is out.
18:49 And I suspect we'll let people know when your recording is out, like maybe this week I might let people know my recording is out?
18:56 I registered for yours and I got a, I didn't watch it, but I got an email saying, "Hey, it's up." So I got to go, I started watching it this morning.
19:04 Yeah, that's cool. So I did recently, I did a webcast with the PyCharm guys as well.
19:08 Paul was sort of there as the emcee of the whole experience.
19:12 And what I did in mind was I said, "Let's learn how to play with MongoDB from Python." And so let's take PyPI and recreate the data access layer of what PyPI might look like in a document database using Mongo and Mongo engine, stuff like that.
19:28 It was lots of fun.
19:29 So you can go check out that recording and we link to it in the show notes.
19:32 And I suspect around February 30th, you might have a similar one.
19:35 Just a small toy project there, recreate PyPI.
19:38 And I'm a little disappointed because I used Faker.
19:40 You know, we've talked about Faker before, right?
19:42 Where you can like create fake data.
19:43 Thing is glorious.
19:44 It needs a few other features, which I'm actually, I'm thinking of doing some PRs for it to add them.
19:50 But I created sort of 100,000 fake PyPI packages and they have kind of some kind of data.
19:58 So now what I'm working on is a system that will let me entirely download every piece of data from PyPI and then model it in the database so that for other projects, like I'll have this, like basically corpus of all of PyPI.
20:11 - Okay, so for the next few weeks, if PyPI is slow, it's your fault?
20:15 - Yeah, you can blame me, I'm sorry about that.
20:16 (laughing)
20:18 Exactly, or I go over my bandwidth limit or something like that, yeah.
20:22 - It was really interesting so far that I've gotten into it, so good job.
20:26 - Yeah, cool, thanks.
20:27 All right, well, that's it for this week.
20:30 Thank you everyone for listening.
20:31 Brian, thank you for sharing this with us.
20:33 - All right, thank you.
20:34 Talk to you next week.
20:34 - Yep, bye.
20:36 Thank you for listening to Python Bytes.
20:38 Follow the show on Twitter via @pythonbytes.
20:40 that's Python Bytes as in B-Y-T-E-S.
20:43 And get the full show notes at pythonbytes.fm.
20:47 If you have a news item you want featured, just visit pythonbytes.fm and send it our way.
20:51 We're always on the lookout for sharing something cool.
20:54 On behalf of myself and Brian Okken, this is Michael Kennedy.
20:57 Thank you for listening and sharing this podcast with your friends and colleagues.