Brought to you by Michael and Brian - take a Talk Python course or get Brian's pytest book


Transcript #64: The GUI phoenix rises with wxPython

Return to episode page view on github
Recorded on Thursday, Feb 8, 2018.

00: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.

00:09 I'm Michael Kennedy.

00:11 And I'm Brian Okken.

00:12 And we're excited to be here with you today.

00:13 We have a ton of good stuff that we've uncovered to share.

00:17 Very exciting.

00:17 Before we get to that, though, I just want to say thank you to DigitalOcean.

00:21 Check them out at do.co slash Python.

00:23 There's some really awesome news from them, and I'll share that with you in a little bit.

00:27 But right now, I'm kind of in love with this project that you pick right now, Brian.

00:31 Tell me about it.

00:32 Well, it's WXPython.

00:34 We've heard of this before.

00:35 But when we've been talking about GUI development and desktop development lately,

00:41 and the WXPython folks contacted us and said, Hey, we are Python 3, and version 4, codename Phoenix, is alive and usable.

00:51 That is really cool because WXPython, there had been a really old version.

00:56 And 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:03 Very exciting.

01:04 The underlying WX toolkit had been, it also underwent a change, and the WXWidgets project has been updated.

01:13 And then the WXPython 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.

01:24 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 or three,

01:31 about the Python GUI stuff.

01:33 And obviously, we're still on this kick.

01:34 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

01:45 and, like, been transported from the early 90s into your computer, and they got this old-fashioned sort of look.

01:51 They just looked out of place, right?

01:52 And so the WXPython stuff looks really modern, and it looks like it belongs on a lot of the platforms,

01:57 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:07 But, you know, I'm happy that this thing is coming along.

02:10 It's been re-released.

02:11 That's awesome.

02:12 On their startup page, there's a, like, a, you know, after you do all the downloads for it,

02:17 there's a five-line application that you can use to try it out.

02:20 And that's pretty slick.

02:22 That's fast to get something up and running.

02:24 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,

02:41 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:45 However, part of my experience of going to PyCascades was to meet Lucas, who gave this amazing talk from,

02:55 he's from Facebook and Instagram, about how they're doing gradual typing in Python

03:01 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, going to have him sort of in real time with the way people experience it on Talk Python,

03:15 talking about it.

03:16 And one of the projects that came out of there that I thought was really interesting

03:20 is this thing called TypeShed.

03:22 Have you heard of TypeShed?

03:23 I have, yeah.

03:24 Yeah, so TypeShed is this place that contains the external type annotations,

03:29 basically the signatures for everything in the Python standard library.

03:34 Okay.

03:34 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-commonode colon AST.

03:45 This is, like, from the AST module.

03:47 And so it'll tell you the type.

03:49 And it says, you know, arrow goes to any, for example, colon, and then just dot, dot, dot.

03:53 And that's it.

03:54 And this is a way in which you can define these external types in these PYI stubs.

04:02 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

04:11 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

04:27 in terms of types.

04:28 this is what mypy uses, the static type checker, as well as this is what PyCharm uses

04:34 to get all of its magic.

04:35 So PyCharm is much better than many, many editors about going, oh, you know, if you call, like, what, right?

04:42 You call some method on this other thing, it returns this other type, and you hit dot,

04:46 and you can see all the autocomplete from it.

04:48 Like, where did that come from?

04:49 It came from TypeShed, actually.

04:50 Okay.

04:50 So, I don't know.

04:51 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.

04:59 So, I'm putting this out there as a call to everyone who cares about Python 3,

05:04 who wants their library to be very rich with inside these various editors and type checkers

05:10 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:21 If you run an open source project that has a package that people use, you can come over here and put yours in,

05:28 and then that will be picked up by all the other things.

05:31 So, it's pretty cool.

05:32 Okay.

05:33 That's interesting.

05:33 We're not sure how they avoid name collision on that.

05:36 They basically structure it.

05:37 There's a third-party folder, and then I think it's just the next subfolder

05:40 is the name of your package, which is unique on PyPI.

05:44 Okay. Yeah, right.

05:45 So, it's probably okay.

05:46 Okay.

05:46 I hadn't heard of TypeShed.

05:48 I mean, I knew that you could annotate your signatures and stuff, but I didn't know that there's this one place

05:54 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:04 I don't know.

06:05 I had never heard of them before, but, you know, apparently.

06:08 Okay.

06:09 Yeah, it's this new signature.

06:11 It reminds me a little bit of what happened a few years ago with TypeScript,

06:16 where I think it's called definitely typed.

06:19 I can't remember.

06:20 There's now this massive Git repository of all these external JavaScript libraries

06:24 that want to interact with the typed version of JavaScript.

06:27 And so, they all have basically, like, there's this similar concept of just the signature descriptions

06:34 without the implementation in this one giant Git repository.

06:37 So, this is kind of cool to see it happening in the Python space.

06:40 Yeah, definitely.

06:41 All right.

06:41 One of the things I wanted to, I think that Ned Batchelder's coverage tool

06:46 is super cool.

06:47 The same caveats as normal is, don't be too enticed with trying to search

06:52 for 100% code coverage in your tests.

06:55 But it's a useful tool in its own otherwise.

06:58 Anyway.

06:59 But he, coverage 4.5 just came out, and he added just one new feature.

07:05 And this new feature is pretty darn cool.

07:07 It's the configurator plugins feature, which allows you, you kind of have to read it a bit

07:13 and get your head around it.

07:13 But the idea is, there's a lot of people that have different configurations

07:17 or different run configurations of their code.

07:21 And some of the code is intentionally not supposed to run at certain times.

07:26 So, it throws up, honoring all these different, like, different requests from people

07:31 to put new features in.

07:33 It has this configurator plugin feature so that you can do your own pragmas ahead of time.

07:38 You run a little bit of code before you run the rest of your code.

07:40 And you can comment out things.

07:44 As an example, for instance, in the pytest book, I had an application that used both TinyDB

07:52 and MongoDB as two different options.

07:55 So, I would want to run my test on the whole thing using Tiny and then also the whole thing using Mongo.

08:01 But I don't want to, there's some of the code that's only for Tiny and some of the code

08:06 that's only for Mongo.

08:07 It doesn't make sense to run coverage on those parts in those configurations.

08:12 So, that'd be a great use for that.

08:14 Yeah, that's really cool because it's really easy to say, okay, we're at 80% coverage.

08:18 We've got to keep going.

08:19 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

08:29 because who knows, maybe it's like some sort of little utility script that you're just throwing in

08:34 and you don't actually want it to be run as part of your package.

08:36 Who knows?

08:37 It's pretty cool.

08:38 Yeah, so, you know what else is pretty cool is the recent changes that the folks over at DigitalOcean just made.

08:43 So, they've always been the incredible, affordable hosting and basic virtual server space.

08:52 They've sort of made places like AWS react in like extreme ways to try to keep up with them.

08:58 So, that's pretty cool but they just recently more or less just doubled everything that you get for the price.

09:03 So, for like $5, you get a server with a gig of RAM and 25 gigs of SSD.

09:08 It's pretty sweet and even includes a terabyte of transfer which, by the way,

09:12 at AWS rates, that's $93 worth of bandwidth.

09:14 $10, 2 gigs, if you pay like $20, you get 4 gigs, 80 gigs of SSD, couple CPUs.

09:22 It's just crazy some of the prices that they have now over here.

09:26 So, if you're looking to do sort of virtual server stuff or things like that,

09:30 definitely check them out at do.co slash Python.

09:34 They've got some really cool options now.

09:36 That's great.

09:36 Yeah, definitely.

09:37 And thank you, DigitalOcean, for supporting the show.

09:39 It helps us keep going.

09:40 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 1, you know, with like the steering wheel thing.

09:49 That's kind of a fun simulation.

09:50 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

10:06 that Python is actually used quite a bit to automate and manage and sort of build the pipeline

10:13 between all these different tools and all these different people at these massive game

10:18 and movie companies, right?

10:20 Yeah, that's pretty cool.

10:21 Yeah.

10:21 So, if you've got to go from like Maya over to some other tool or, you know,

10:26 you've got these hundreds of gigs of files and they need to be transformed

10:29 and processed and whatnot, that's a challenge and a lot of people have built

10:34 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

10:41 sort of 3D game engines there is, they're now integrating Python deeply into its sort of processing pipeline,

10:48 not its necessary execution.

10:50 But they plan to integrate Python into the Unreal Engine for data, basically for this data pipeline.

10:58 That's great.

10:58 Yeah, it's cool, right?

10:59 So, this is from Autodesk and they said, hey, we're going to give you a glimpse

11:01 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,

11:07 ultra, ultra fine quality, 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

11:16 and the tires on the motorcycle have those little, like, you know, those little dots,

11:21 those little sticky pieces of rubber that come out on like new tires where they come out of the mold

11:26 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

11:34 of these like knobby things and stuff into the model that ends up in the 3D

11:40 in the Unreal Engine, right?

11:41 So, they're basically building this pipeline where you can say, in Python,

11:46 why don't we just delete all the objects that are probably too small for people to notice anyway

11:50 and just do that automatically.

11:52 do level of details models.

11:54 You can like merge objects together.

11:56 You could say, actually create a bunch of different motorcycles by automatically taking the source one

12:01 and replacing like the material that is say the fenders and the gas can and stuff

12:08 to change it from say like a light blue to like a purple shiny motorcycle.

12:12 And so, all of this is automatic.

12:14 So, once it's automatic, you can, you know, make a change at the beginning

12:18 of the process and replicate this entire workflow, which is pretty cool and it's awesome to see

12:22 that Python's the choice for it.

12:23 Yeah, very cool.

12:24 Yeah, so just one more example of people using Python in ways that I had no idea existed.

12:29 Yeah.

12:30 Neat.

12:30 Yeah, pretty cool.

12:31 Good job, Unreal.

12:32 Yeah, good job, Unreal and Autodesk.

12:34 And they're going to 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

12:43 and because it's now beta instead of alpha, that means the feature sets,

12:49 I think I might get this right, the feature sets frozen and we're just tweaking it,

12:54 making sure it's all tight and everything and tested.

12:56 But beta means that there's beta testers and I was just thinking if it's not people like you and me

13:02 in our community that listen to this, who is it?

13:04 So, I think we had, I'm just putting a call to action out there to go pick a few of the features

13:10 that are coming up and 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,

13:28 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

13:35 and maybe a couple of the others and give it a whirl.

13:38 Nice.

13:39 So, do you know if there's easy ways with things like talks and stuff to go ahead and run your tests

13:44 on Python 3.7?

13:45 Yeah, of course.

13:46 Talks 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

13:58 that all combinations of Python, all recent versions of Python and pytest

14:03 work with all the demo code I have in my book and doing that manually is just too much work.

14:08 So, I'll use talks for that.

14:09 Yeah, that's a complete nightmare.

14:10 Yeah, tell people really quick, I know some people know about talks but not everyone.

14:14 So, tell people what, like, where does talks fit in?

14:17 Because I thought you were a pytest guy.

14:18 What's up with this testing with talks thing?

14:20 Well, talks 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

14:35 multiple combinations of different libraries together or configurations of your system

14:40 and test them separately.

14:41 Yeah, nice.

14:41 So, you could say test on PyPy and on CPython and multiple versions of either of those

14:48 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,

14:59 it takes your, takes your, like, let's say, a package that is a Python package

15:04 and it runs its setup function to create an installable Python wheel, I think.

15:09 And then it creates a virtual environment, installs your package and all of its dependencies

15:15 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:23 All right, so for our final item, the one that I want to cover is similar,

15:27 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

15:32 that were pretty interesting on a couple levels.

15:35 So, first of all, I think some people use this web framework.

15:38 It's called Django.

15:39 What do you think, Brian?

15:40 Yeah, quite a few.

15:41 Yeah.

15:41 So, they just announced that they had a security release to fix some issues

15:48 in around authentication and basically the login infrastructure in Django.

15:53 So, if you're using 2 or 111, you may want to check that out.

15:56 All right, so there's been like, you know, here's the testing thing.

16:00 There's been a regression.

16:01 There was a problem.

16:02 It was fixed and now it's unfixed.

16:04 It's fun when problems unfix themselves.

16:06 So, the release is with the unfixed one?

16:08 This puts the fix back.

16:10 Oh, okay.

16:12 And then two more around Python 3.

16:14 One is Python 3.4.

16:16 There's a security release there and one is Python 3.5.

16:20 There's also a security release there.

16:22 So, respectively, the versions are 3.4.8 and 3.5.5 and there's apparently

16:27 some problem with this internal bit called libxpat.

16:30 As far as I tell, it's like an XML parsing library and there's some kind

16:33 of issue with that.

16:34 That sounds not good.

16:35 Like, people could send you bad XML and bad things happen.

16:38 So, be aware.

16:40 And just a reminder to everyone and if anything like this happens in Python 2 shortly,

16:45 there will be no fixes.

16:47 You're just going to have to live with it after it goes end of life.

16:51 So, it's good that they're fixing these.

16:55 I suspect, I don't know when 3.4 is gone end of life, right?

16:58 3.3 I think is now out.

17:00 Anyway, the final one, I said I had a lot of releases, is channels.

17:05 So, these are Django channels.

17:06 They're pretty interesting in that they add like an asynchronous way to write Django,

17:11 WebSocket, and these types of things.

17:14 Actually, I had the guy behind this on Talk Python and I linked it and interviewed there.

17:18 But, this is sort of a complete rewrite.

17:22 This is channels 2.0.

17:23 It's a major rewrite.

17:24 And most notably, Python 2.7, even Python 3.4, are no longer supported.

17:30 They're fully legacy Python.

17:33 They're out.

17:34 It's 3.5 and above is all this works on.

17:36 So, I suspect some of that might have to do with Django 2.

17:39 But, also, it being this async thing, maybe they use the async and await keywords

17:43 and it just doesn't work in 3.4 or below.

17:46 But, yeah, it's all pretty cool.

17:48 A bunch of new releases.

17:49 So, if you're using these and want to check them out, do.

17:52 That's it for our news this week.

17:54 Brian, what items do you have to share?

17:56 Well, I've got a couple exciting things.

17:59 Yes, you do.

17:59 I had submitted five talks to PyCon and one of them was accepted.

18:03 Congratulations!

18:04 That's awesome.

18:05 Yay!

18:05 It's a talk.

18:06 I'm going to do it together with Paul Everett from the PyCharm team.

18:10 So, it'll be PyCharm and pytest and that'll be fun.

18:14 That's going to be really, really fun.

18:16 The two of us also are going to do a webinar coming up on the 22nd of February

18:20 and a similar topic but a little bit more advanced.

18:25 So, we're going to 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:32 I'm going to register after I'm going to sign up.

18:36 That'll be really fun.

18:36 And then all these, of course, get recorded afterwards.

18:40 Right?

18:41 So, it's typically an hour, a 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

18:48 that, hey, the recording is out.

18:49 And I suspect we'll let people know when your recording is out.

18:53 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,

19:00 hey, it's up.

19:01 So, I got to go, I started watching it this morning.

19:04 Yeah, that's cool.

19:04 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:13 And what I did in mine was I said, let's learn how to play with MongoDB from Python.

19:18 So, let's take PyPI and recreate the data access layer of what PyPI might look like

19:24 in a document database using Mongo and Mongo Engine and 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:31 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 talked about Faker before, right?

19:42 where you can like create fake data.

19:43 The thing is glorious.

19:44 It needs a few other features which I'm actually, I'm thinking of doing some PRs for it

19:49 to add them.

19:49 But I created sort of 100,000 fake PyPI packages and they have kind of some kind of data.

19:57 So, now what I'm working on is a system that will let me entirely download

20:02 every piece of data from PyPI and then model it in the database so that for other projects

20:07 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.

20:15 I'm sorry about that.

20:16 Exactly.

20:18 Or I go over my bandwidth limit or something like that.

20:21 Yeah.

20:22 It was really interesting so far that I've gotten into it.

20:25 So, good job.

20:26 Yeah, cool.

20:26 Thanks.

20:27 All right, well, that's it for this week.

20:30 Thank you everyone for listening.

20:30 Brian, thank you for sharing this with us.

20:32 All right, thank you.

20:33 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 at Python Bytes.

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:46 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:53 On behalf of myself and Brian Okken, this is Michael Kennedy.

20:57 Thank you for listening and sharing this podcast with your friends

Back to show page