Latest / Talk Python To Me / #326: Building Desktop Apps with wxPython
Transcript
- 0:00Did you know that I'm a fan of GUIs? You know, they're kind of like web pages,
- 0:03but they run on your computer, they have their own windows, and you can even use those applications
- 0:08offline. On this episode, we'll dive into WXPython with Mike Driscoll. He's back on the podcast to
- 0:15share his hard-won experience building and distributed Python window-based applications.
- 0:20This is Talk Python To Me, episode 326, recorded July 14th, 2021.
- 0:26Welcome to Talk Python To Me, a weekly podcast on Python, the language, the libraries, the ecosystem,
- 0:44and the personalities. This is your host, Michael Kennedy. Follow me on Twitter, where I'm @mkennedy,
- 0:49and keep up with the show and listen to past episodes at talkpython.fm,
- 0:53and follow the show on Twitter via at Talk Python. This episode is brought to you by Linode,
- 0:59us over at Talk Python Training, and the transcripts are brought to you by Assembly AI. Please check out
- 1:04what we're all offering during our segments. It really helps support the show.
- 1:07Do you want to learn Python, but you can't bear to subscribe to yet another service?
- 1:12At Talk Python Training, we hate subscriptions too. That's why our course bundle gives you full access
- 1:18to the entire library of courses for one fair price. That's right. With the course bundle,
- 1:23you save 70% off the full price of our courses, and you own them all forever. That includes courses
- 1:29published at the time of the purchase, as well as courses released within about a year of the bundle.
- 1:34So stop subscribing and start learning at talkpython.fm/everything.
- 1:41Mike, welcome to Talk Python To Me.
- 1:43Yeah, thanks so much for having me again.
- 1:44Yeah, it's great to have you here. Maybe we can just remind people of the last time you are here.
- 1:49You wrote a really cool book called, I think it was Python Interviews. Do I have the title correct?
- 1:54Yes, that's correct.
- 1:55Yeah, and that was back in episode 156, way back in 2018, three years ago, I guess, more than that.
- 2:02But it was a history book, so I was looking back, right? It's fine. It's still relevant. People can
- 2:07check that out. And I really love some of the stories that you told on there. I love, I think it was Alex
- 2:13Martelli. You interviewed him and talked about how Google Video and YouTube were sort of competing neck
- 2:20and that was sort of a Python versus C++ story. That's probably the one that stuck with me the most.
- 2:25Yeah, I really enjoyed that one. Although there's some good stuff in the Brett Cannon interview as
- 2:29well.
- 2:29Yeah, there's great stuff all over. I'm just trying to think of the one that I can remember years later,
- 2:34you know?
- 2:34Yeah.
- 2:35Yeah. So it's been a couple years since you've been on the show. What have you been up to?
- 2:39Well, since that book came out, I have been pretty prolific in my writing and continue to write
- 2:45more Python books. For example, I've written one on wxPython and Report Lab. I redid Python 101,
- 2:52which was my first book.
- 2:53Report Lab is about like working with PDFs, right?
- 2:56Yes. You can use it to create PDFs. But that book also covers how to edit, or I shouldn't say edit,
- 3:01how to read and get data out of an existing PDF as well.
- 3:05Yeah. Cool. You got a couple of 101, 201 type of books as well.
- 3:11Yes.
- 3:11Like learning Python.
- 3:12Yep. Python 101 is for beginners and 201 is kind of intermediate advanced.
- 3:16So if I was like a sophomore, I might take that.
- 3:18Yes.
- 3:19Cool. So what are you doing these days? Are you doing the independent thing with your authoring
- 3:25and creating? Are you doing consulting? What are you up to?
- 3:28Oh, I still do a full-time job. I write Python code that tests an embedded C++ application with Python.
- 3:34Oh, nice.
- 3:35It's really neat. But I also, you know, kind of as a hobby slash side job, I write for myself. I write
- 3:42these books and I occasionally contribute to RealPython as well.
- 3:46A lot of good stuff going over RealPython. Dan and crew keeps that content flowing over there for sure.
- 3:52Yep.
- 3:52Yeah, absolutely. So we're going to talk about building GUIs or GUIs as some people say them. I don't know.
- 4:00Are you a GUI or are you a GUI sort of person?
- 4:02I usually call it GUI.
- 4:04Yeah, me too. So we're going to talk about those for Python, which I think is interesting because there are,
- 4:09there have been, there are decent options, but it's not a place where Python has traditionally received a ton of focus
- 4:16and energy on building. A lot of these frameworks have to do with picking another framework that's a nice
- 4:22cross-platform framework and like making it friendly for Python, right? I'm thinking of like PyQt or even WXPython, right?
- 4:29Yeah, it's usually a C++ wrapper that preexisted Python and then it got wrapped with bindings of some sort.
- 4:36Yeah, exactly. A lot of these, especially the ones that do native widgets, those are really just wrappers
- 4:41over the operating system when doing APIs, right? Like Win32 or what is it? Coco on macOS, those kinds of things,
- 4:51right? So it's like some thin layer than some adaption adapting thing for Python, right?
- 4:56Yeah, I think there's only a handful that aren't wrapping something else. Like BeWares Toga,
- 5:02I don't believe is wrapping the native, I was trying to look, I guess it is wrapping in a way,
- 5:07but it's not wrapping a preexisting framework.
- 5:10Right, right. It's probably super low level. Like here is a, literally create a window that is a button
- 5:16and that's it. Like not like Qt or something. Yeah, I think Toga is actually like, you know,
- 5:22trying to render the Coco widgets or the Win32 widgets itself, you know, rather than calling like
- 5:27Qt or WX.
- 5:28Yeah, there's some value to that. There's some value to that. So I thought the place that we could start
- 5:33is maybe a survey of these different libraries that we could use.
- 5:37Sure.
- 5:37Right. And so let's start with Tinker, TK Enter, which is really the Python interface to TCL,
- 5:43TK, right?
- 5:44Mm-hmm. Yeah.
- 5:45So this one comes built in, right? I'm here on the Python 396 documentation. And I guess this is the
- 5:53official way to create QIs with Python, right? I mean, in the sense that it ships with it.
- 5:58It ships with it. However, on like Linux, the system Python does not come with it.
- 6:04Okay. So you still got it.
- 6:05And I believe, I believe Mac is the same way. You have to install it separately for its system Python
- 6:10too.
- 6:10Yeah. That wouldn't surprise me. Well, you know, the system Python and Mac is all sorts of outdated and
- 6:16whatnot, basically, right? Like 2.7, who knows what, right? But-
- 6:22Yeah. But it always surprises me when I go to import TK Enter and it's like, oh, it's not there.
- 6:25Like, what the?
- 6:27Yeah, exactly. Tell us about this one. Like, what's the good side? When would you use it? Or
- 6:32would you use it? When wouldn't you use it?
- 6:33I don't like it because it looks a little old-fashioned, but mainly because it draws all its
- 6:39own ridges, just like some of the other GUI toolkits. So basically, when you create a TK Enter GUI,
- 6:45you know it's a TK Enter GUI because it doesn't look native. However, you can use a TK Enter,
- 6:51the code can be written without classes. You could write it completely functionally,
- 6:56and still make it work. So, you know, as a learning way to create a GUI, it might be a good first,
- 7:02you know, a good beginner or first GUI to create with.
- 7:05Yeah, absolutely. Here, I put up on the screenshot, the screen for us to see there's like this TK Enter hotel
- 7:11management system. It definitely doesn't. I didn't see the top bar. I couldn't tell you what OS that's
- 7:16from, but because it doesn't look like any OS that I know, right? Although there's another example. I'll
- 7:21put these in the show notes. There's a pretty nice one that's hosting some kind of, it's like a predate
- 7:28jupiter or something like host map plotlib exploration and stuff. And that looks like a
- 7:34pretty solid app to me.
- 7:35Yeah. TK Enter did add a submodule called TTK, which does look a lot more native across platforms.
- 7:41You can make it look nice, actually, if you spend the time, but you're going to have trouble
- 7:46finding good examples online because a lot of them just use the old interface. And one other thing I do
- 7:52want to note about TK Enter is it's themable. So if you want it to look, you want to add themes to
- 7:57your GUI, you want to take it as an option for that.
- 8:00Oh, interesting. It was like, so for example, you could give it a macOS like theme that turns
- 8:05on on that platform and a Linux theme, maybe dark mode and a not dark mode.
- 8:11Yeah. I was thinking of dark modes, light modes, be giving them a certain color things,
- 8:14kind of like a Winamp type skin.
- 8:16Yeah. Oh man. Remember how crazy those skins would get? They'd get like 3D with little holes
- 8:21cut in them. And yeah, that stuff got, that got a lot of little drawers, like an alien tongue
- 8:26would shoot out. And that's where like the playlist would be. Don't do that people.
- 8:29Yeah. Don't do that.
- 8:30Okay. So for the most part, TK Enter is built in ish. At least it's sort of somewhat officially
- 8:37part of Python, right?
- 8:38Yes, it is.
- 8:39Another one, one that I think of a lot when I think of cross-platform stuff is Qt, Qt and PyQt.
- 8:46There's been a lot of different versions of PyQt. There's been a lot of stuff with licensing.
- 8:52So like right here on the homepage, it says licensing. PyQt is dual license on all the
- 8:56platforms under DPL3 and the Riverbank commercial one. Unlike Qt, PyQt is not available under LGPL,
- 9:03which is, I guess what you would need for like a commercial closed source app. And then there's,
- 9:08there's another wrapper around Qt that I think is LGPL. Like the, there's a lot of stuff that's
- 9:14just like, whoa, why is it so complicated?
- 9:16Yeah. PyQt is kind of confusing when it comes to its licensing structure.
- 9:20Yeah. Which is crazy because I've had this conversation multiple times and it seems like it,
- 9:25I don't know, it either, it never resolves clearly in my mind or it's just challenging. But that said,
- 9:31there's really nice apps built with Qt. So for example, like one of the database tools I use for
- 9:37working with MongoDB is Robo3T. And if you look at Robo3T, this thing is glorious in terms of its sort
- 9:44of native look and feel. Like if you go to the robomongo.org, scroll down for the screenshots,
- 9:49there's the three OSs side by side and every one of them looks like it belongs on that platform,
- 9:55right?
- 9:55Yeah. You can get a little bit simpler with, instead of using PyQt, you could use Qt for Python,
- 10:00which is the new name for PySide.
- 10:02That's right.
- 10:02That's right.
- 10:03And it has a bit more permissive licensing structure.
- 10:05That's the one I was thinking of. Yes. Thank you. Yeah. They renamed that to Qt for Python,
- 10:10right?
- 10:11I believe so. Although the import is still PySide.
- 10:13Is it still PySide? How interesting.
- 10:15It's like PySide 6, I think. Yes.
- 10:17Yeah. How interesting. So this, I think Qt's a pretty solid option. I feel like I see Qt being
- 10:23used in embedded systems and other types of things. Like I said, I started using RoboMongo just because
- 10:28it seemed like a good app and like, oh, this is a Qt app. It's not a Python. It's a C++ app,
- 10:34but it just as well could be. Like there's nothing fancy about it that it makes it have
- 10:38to be C++. It just happens to have been that way. Yeah. Yeah. So what are your thoughts on
- 10:42this as one of the options? Oh, Qt is really powerful. You can do a ton. And while it draws
- 10:49all of its own widgets itself, it's not actually using the native widgets. It looks native.
- 10:54At least they made an effort. Yeah. Yeah. Again, this one is also a themable. If you want to do themes,
- 10:59you can change, you know, dark mode, light mode easily because that's all drawn itself.
- 11:04I think PyQt and PyQt for Python both support QML, which is kind of an XML version of the C++ library.
- 11:12So you can kind of write it, write your GUIs in a markup language.
- 11:17Yeah, that's right. It's a little bit like XML or XAML from the Microsoft space. Yeah, that's right.
- 11:22It also has a, what you see is what you get editor. I think it's Qt Designer.
- 11:27It works for both C++ and Python. I believe the Python side, you have to do some special imports
- 11:33to actually use the UI file it generates. Yeah. That seems like a really valuable thing to me
- 11:38to visually be able to say, I want this widget to be here. I want this one to stretch like that and so
- 11:42on. Yeah. I work with a bunch of C++ cute guys and they use the designer, but occasionally it will do
- 11:49crazy things when your design gets really complex, where it's really hard to get stuff to stretch the
- 11:55way you want it to. And sometimes you just have to drop into the code to make it work right.
- 11:59Yeah. Well, I think that's probably the case with many of the frameworks, right? Not just these Python
- 12:04ones we're highlighting, but you know, Xcode, whatever, right?
- 12:08I think that's just a problem with auto-generated UI code. Whenever you use a designer like that or
- 12:13Visual Studio, you're going to run into quirks.
- 12:16Yeah. Yeah, for sure. Next up on our list here is Kivy. Kivy, I heard about a lot from sort of
- 12:23building mobile apps with Python in interesting ways. It's kind of got this game, draw your own UI
- 12:29sort of feel to it.
- 12:30Yeah. It's also cross-platform. It runs on mobile too, though. So you can deploy its apps to Android and
- 12:38Apple OS. But yeah, a lot of the stuff on there... Well, I should back up. It was originally developed
- 12:43for multi-touch. So like Microsoft's original Surface table, I think is what it was originally developed
- 12:49for. Yeah.
- 12:50But, you know, obviously it also works great on multi-touch phones and whatnot. But yeah, all of its widgets are
- 12:57drawn by Kivy itself. So they look like a Kivy app most of the time.
- 13:01Yeah. They have a gallery over here. And in the gallery, they even have like some surface table
- 13:07exploration stuff, like the city of Marseille map exploration type thing, right?
- 13:12They have a Kivy garden, I believe, that also showcases lots of custom widgets.
- 13:16Yeah. So when I look at the... I'm scrolling through the gallery here, I feel like there's a lot of 2D
- 13:23sort of interactive things, a lot of games or stuff like that, right? So it's... If I wanted to build an
- 13:30app that maybe looked like it used the Windows rich text box and the Windows button, so it looked like
- 13:36a, I don't know, a Windows 10 button on Windows 10 and a Windows 11 button with curved edges.
- 13:42It's not that kind of framework, right?
- 13:44No, it's not.
- 13:45Okay.
- 13:45And I believe Kivy is based on, or written on top of Pygame. So it has... That's why I can do games so well.
- 13:52Right. That sounds familiar to me as well. And apparently the winner of the Python Discord
- 13:56Code Jam 6 was done in Kivy. So that's pretty cool.
- 14:01That is cool.
- 14:02As well as second place.
- 14:03So I was unaware.
- 14:04Is there a third place one down here?
- 14:06Yeah, it is.
- 14:07Wow.
- 14:08They have a clean sweep of the podium with Kivy. So that's pretty impressive, actually.
- 14:12Yeah. I've actually played one of their games on my phone before and they seem pretty well
- 14:16done.
- 14:16Nice.
- 14:17Another one that's gotten a lot of traction and has its own opinions for how it works is
- 14:23PySimple GUI. I think Mike Barnett, if I'm remembering correctly, is working on that.
- 14:29Yeah.
- 14:29And yeah, the idea is to make it super simple to just get a basic UI up and running, right?
- 14:35Yeah.
- 14:35So PySimple GUI wraps, I think, four or five other frameworks. So it wraps tkenter, wxPython,
- 14:43PyCute, Remy, which is a mobile thing, and something else. And basically it gives you the same API for
- 14:50all of them. So that, you know, if you write your code once and then you just change the import from
- 14:54import PySimple GUI to import PySimple GUI Qt or PySimple GUI WX, you can get that native look and feel
- 15:02because you're using WX acute.
- 15:04Oh, that's a really cool aspect, right? That you can swap out the widget engine or something,
- 15:10basically.
- 15:10Mm-hmm. Yeah. The default is tkenter.
- 15:13Yeah. Probably because it's the least dependencies and you don't have to think about which kind of
- 15:18license you're doing what with.
- 15:19Yes.
- 15:20Interesting. Okay. So this is a pretty cool one. If you're just trying to get a dialogue up that
- 15:26has one or two buttons and an input and a progress bar, maybe this is a good option.
- 15:30They can do quite a bit of complex GUIs too. There's a demo package that they have that
- 15:35shows how to integrate it with matplotlib and opencv and lots of other things. These examples
- 15:42don't show the advanced stuff it can do.
- 15:44Right. I'm just sort of paging through the gallery, the screenshot they have on the site
- 15:50there, which we'll link to.
- 15:51And again, since it's using tkenter, it also does themes natively.
- 15:55Yeah, it can just float.
- 15:56At least for the tkenter part.
- 15:57Yeah, exactly.
- 16:00This portion of Talk Python To Me is sponsored by Linode. Visit talkpython.fm/Linode to see why Linode has been voted the top infrastructure as a service provider by both G2 and TrustRadius.
- 16:11From their award-winning support, which is offered 24-7, 365 to every level of user, to the ease of use and setup, it's clear why developers have been trusting Linode for projects both big and small since 2003.
- 16:24Deploy your entire application stack with Linode's one-click app marketplace, or build it all from scratch and manage everything yourself with supported centralized tools like Terraform.
- 16:34Linode offers the best price-to-performance value for all compute instances, including GPUs as well as block storage, Kubernetes, and their upcoming bare metal release.
- 16:44Linode makes cloud computing fast, simple, and affordable, allowing you to focus on your projects, not your infrastructure.
- 16:52Visit talkpython.fm/Linode and sign up with your Google account, your GitHub account, or your email address, and you'll get $100 in credit.
- 17:00That's talkpython.fm/Linode, or just click the link in your podcast player's show notes.
- 17:06And thank them for supporting Talk Python.
- 17:08One that you put in the list that I haven't really done anything with is DearPyGUI, a fast and powerful graphical user interface toolkit for Python with minimal dependencies.
- 17:20Tell us about this one.
- 17:21This one I haven't played with very much yet, but I believe the guy who created it has been working a lot on it lately, and it has a really neat interface.
- 17:30I don't think it's wrapping anything, but I could be mistaken.
- 17:33It looks very focused on providing animated and interactive aspects for scientific visualization and exploration.
- 17:42Yeah, I think it is.
- 17:44I don't believe it tries to look native necessarily either, but it has a very slick interface.
- 17:49Yeah.
- 17:49Yeah, it does.
- 17:50There's a lot of cool stuff that's going on here.
- 17:52Okay.
- 17:53So that's a neat one.
- 17:54And I guess one that I didn't properly cover yet, because I didn't pull up in our little list here, but it's a toga from Beware.
- 18:02You touched on that, right?
- 18:03Yeah.
- 18:04So all this stuff over at Beware is super neat.
- 18:07There's a lot of nice things going on.
- 18:09It definitely, the native widgets feels, and I just always feel kind of like, ah, this thing doesn't really belong here, right?
- 18:16When I see an app, it just looks like you're like, this is, you know, some clearly cross-platform, not really this platform feel, right?
- 18:25Yes.
- 18:26I don't know.
- 18:26I appreciate the native widgets aspects, but it's also listed in sort of the maturity level as early development, right?
- 18:32So I'm not sure if this is pretty for you to pick up and build with yet.
- 18:36Yeah, not really is my understanding.
- 18:38And oddly enough, it's been in early development for like the last five years.
- 18:42Yeah.
- 18:42So it's been really slow to develop.
- 18:44They're trying to do it from the ground up and they're not wrapping anything.
- 18:47It's somewhat understandable, but I think they recently added Android support.
- 18:51So I think that they're focusing more on the mobile stuff than, you know, like Windows and Macs, native OSs.
- 18:58Yeah.
- 18:59The last commit was a merged PR from Russell Keith-Magee four days ago.
- 19:04So there's still, still action.
- 19:05Yeah.
- 19:06Yeah.
- 19:06They're still working on it.
- 19:07All right.
- 19:08Well, that brings us over to the wxPython, which is another one of these options in this space,
- 19:14but that's what we're going to focus on in this particular episode, right?
- 19:18Sure.
- 19:18Yep.
- 19:18So give us the quick overview of wxPython sort of compared to these other options we've been covering.
- 19:23So wxPython is again, a C++ project.
- 19:27It wraps WX widgets or Wix widgets, I've heard it called.
- 19:31It works on Windows, Mac and Linux and Raspberry Pi.
- 19:34The big thing about DAPX Python is that it does do native widgets wherever possible on all platforms.
- 19:41Yeah, that's cool.
- 19:41So that is really cool.
- 19:43It also provides a lot of custom widgets in case you need them for certain purposes.
- 19:48Like some, I believe, I think it was Mac that didn't have a toggle widget for a long time.
- 19:53So they provided their own toggle widget for it.
- 19:56Right.
- 19:56It's the GUI equivalent of a polyfill.
- 19:58It's like that feature is not supported, but you want it.
- 20:01Well, like, all right, here's that something that'll do for now.
- 20:04Yeah.
- 20:04Yeah.
- 20:05Very cool.
- 20:05You know, it looks to me like it checks a lot of the right boxes.
- 20:09What's the licensing story?
- 20:11It's very permissive.
- 20:12Yeah.
- 20:12I'll pull up there.
- 20:13I'll pull up the repo and hit their license doc and see what I can find.
- 20:17I know they called it the wxPython license, but I'm trying to remember.
- 20:21Ah, that's right.
- 20:21It looks LGPL-ish.
- 20:24Yeah.
- 20:24I think it is mostly LGPL.
- 20:26Mm-hmm.
- 20:26Yeah.
- 20:27Cool.
- 20:27That's better than multi-license confusing.
- 20:31Like the C layer has one license and the Python layer has another license, but then there's
- 20:35this other commercial license.
- 20:37So it seems like it's pretty easy for you to just decide to adopt it and use it on your
- 20:41project.
- 20:41Yeah.
- 20:42I would agree with that.
- 20:43And it's also extremely stable.
- 20:45They almost never break your code when they release a new version.
- 20:50Okay.
- 20:50That's cool.
- 20:51I heard that it rose from the ashes.
- 20:52Yeah.
- 20:54The Phoenix release and then the legacy or traditional version.
- 20:59What's the story of that?
- 21:00So, you know, Python 3 came out and a lot of people, you know, fussed about supporting it.
- 21:05It was a pretty big deal to port wxPython to Python 3 because wxPython has a really small
- 21:13group of core developers.
- 21:14But eventually he created, or Robyn Dunn is the main guy behind wxPython currently.
- 21:19And he decided, well, we're going to call it Project Phoenix while I get this working.
- 21:24And I think he actually switched the way he binded to Wix widgets at the time because he
- 21:29went from like SWIG to, I believe, SIP, which is a different type of binding.
- 21:33Okay.
- 21:34And that made it a lot easier to support both Python 2.7.
- 21:37And I think it was 3.4 was the first release for Wix Python.
- 21:41And that also made it pip installable.
- 21:44So that was super awesome when he got that working.
- 21:46So if I want to use it, I can just pip install DevX Python or Wix Python.
- 21:50As I'm learning that I might want to say it that way.
- 21:53Yes, that's correct.
- 21:54And there's a caveat on Linux that sometimes you need to have a couple of extra Linux dependencies
- 21:59installed.
- 22:00But other than that, pip install should work.
- 22:03Yeah.
- 22:03Well, that's pretty standard, right?
- 22:05If you're doing GUI stuff on Linux, a lot of times there's elements there you got to add.
- 22:09It doesn't seem outrageous.
- 22:11No.
- 22:11Yeah.
- 22:12So another thing that I'm a big fan of to the extent that they work, and the better that
- 22:17it works, the more I'm a fan of it, is the GUI designer.
- 22:21So there's two over here, right?
- 22:23We've got like this Wix form builder in the Wix Glade.
- 22:27I think I tried the Wix form builder and it just, it kept crashing.
- 22:31Not like it would start and was unstable.
- 22:33It would not start for me.
- 22:35And I don't know what the deal, maybe it was the version of macOS I was running on or something.
- 22:40But what's the story?
- 22:41Are these things that people would use?
- 22:43Yeah.
- 22:44What's the story around the WYSIWYG side of these?
- 22:47wxPython traditionally hasn't had really a WYSIWYG editor, but people have tried to build
- 22:53them.
- 22:53So I think Wix Glade is probably the one that's been around the longest.
- 22:56Okay.
- 22:57And probably the best supported.
- 23:00I don't think it, I think it supports the core widgets of wxPython.
- 23:03If you were to pull up the wxPython demo app, there are like a hundred, I would say at least
- 23:08a hundred widgets, maybe more, maybe 200.
- 23:10So the core widgets, you know, like buttons.
- 23:13Do I find that under widgets?
- 23:14You would find that under, let me see, downloads.
- 23:18Downloads.
- 23:19There you go.
- 23:19Unfortunately, it's actually something you run.
- 23:21Yeah, sure, sure.
- 23:22So if you can download, I think I have run that before and you basically, it's like got all
- 23:27these windows that'll show you little use cases for this widget or that widget, right?
- 23:31Yeah.
- 23:31It also shows you the code and you can edit the code live in the demo and see how it, how
- 23:35it changes the widgets.
- 23:37Oh, that's neat.
- 23:37It does a decent enough job.
- 23:39I think it outputs a Python file.
- 23:41So that's nice.
- 23:42I mean, it doesn't put, you know, like Qt's designer output's a UI file that you have to
- 23:46figure out how to import and then use.
- 23:48This one actually outputs a Python file.
- 23:51Oh, that's nice.
- 23:51Yeah, that's really good.
- 23:52So I'm looking at the screen here and it looks like Audacity, the well-known audio editing
- 23:58app is built in DubX.
- 24:00I'm guessing.
- 24:01Otherwise, there's no reason they would feature it.
- 24:02I believe that's true.
- 24:04I'm not sure if it's Wix widgets itself.
- 24:06Yeah, it's on the Wix widgets site.
- 24:08So I'm pretty sure it's a C sort of thing.
- 24:11But yeah, these are pretty good looking apps that you can like sort of page through all their
- 24:15screenshots on just Wix widgets.org.
- 24:18Almost even like an auto trader looking thing and like a diff tool.
- 24:22Yeah, file merge.
- 24:23Yeah, Audacity.
- 24:24Yeah, I believe one of the Linux diff tools is written with wxPython.
- 24:28And I had heard that the Dropbox UI was written with WX for a while.
- 24:33I don't know if it still is or not.
- 24:35Cool.
- 24:35So it seems like there's quite a rich library for working with these things with wxPython
- 24:41or Wix Python.
- 24:42And I guess maybe one of the nice ways to explore this would be, where am I going to
- 24:48go?
- 24:48I'm going to go over here a little bit.
- 24:49To talk about sort of some of the things you covered in a recent book that you wrote.
- 24:53Not super recent, but somewhat recent.
- 24:55Creating GUI applications with Wix Python, which is pretty cool.
- 24:59And a comment from the live stream out there.
- 25:02Juergen says, congrats on the successful fundraiser for your latest book, which is not this book,
- 25:07but like...
- 25:08No.
- 25:08What book is that that you're just working on now?
- 25:10I'm working on one that talks about automating Excel with Python using OpenPy Excel.
- 25:16Well, that's certainly a hot topic indeed.
- 25:18What's the story with this creating GUI apps with Wix Python in your book?
- 25:24Feels like from the extent that I got to read it, which is not all of it, but some of it.
- 25:29It does a quick introduction of how to work with the widgets and stuff and get some stuff
- 25:34on the screen, understand the layout a little bit.
- 25:37And then it goes through and just builds like a bunch of different apps, like a nice little
- 25:41image viewer, a database viewer tool that uses SQLAlchemy to like explore stuff there,
- 25:47a calculator, an archiver, MP3 tag editor, those types of things.
- 25:51You want to maybe just tell us like kind of some of the key elements before we actually,
- 25:56before we get into those, let's just maybe, it's hard in code, but on audio to talk about
- 26:01code, but maybe just give us like a sense of what is it like to get a window and a button
- 26:07on the screen or something like that?
- 26:08Sure.
- 26:09So, you know, Linux Python, much like PyQt, they're all class-based.
- 26:15So, you're going to be inheriting from different classes to create all the widgets online.
- 26:21Whereas with Tcancher, you don't have to do that.
- 26:23I see.
- 26:23So, you might make like a window class and like a layout main section class or something like
- 26:29that?
- 26:29Kind of.
- 26:30Okay.
- 26:31Layouts usually aren't needed to be subclassed, but like you subclass a frame, which is the main
- 26:36window.
- 26:36You can subclass a panel, which is kind of like the tabs on your Firefox or Chromebook.
- 26:45You can create a notebook object that has multiple panels when each of those panels is a tab,
- 26:50basically.
- 26:51I see.
- 26:51So, it has like a multi-doc version or style that it'll support.
- 26:55Correct.
- 26:55Yeah.
- 26:56Okay.
- 26:56Cool.
- 26:56And within your frame, you have your panel.
- 26:58And then within the panel, you have your widgets.
- 27:00And so, those are your children widgets.
- 27:02Like you have your buttons or your, you know, your scroll bar or your check boxes or whatever.
- 27:08The code can get kind of unruly, but for just creating something really simple, you can do
- 27:13it in less than a hundred lines of code most of the time.
- 27:16But, you know, once you start doing like anything complex with wxPython, you're going to start
- 27:22adding a lot of code.
- 27:23Right.
- 27:23Because if you're going to have, say, three buttons and a text field and you want to,
- 27:28you want to figure out how they lay out, there's like a couple of things that you're going to put
- 27:31just on the layout side.
- 27:33And then you're going to have to hook potentially the events.
- 27:35You can abstract that away a little bit.
- 27:37So, it's not too bad.
- 27:38Like if all the buttons do something similar, then you can make that really short.
- 27:42But yeah, if you, if all the buttons do something completely different, then you could, you know,
- 27:47you have three different functions.
- 27:49The way I have written wrappers to make laying that stuff out simpler.
- 27:53So, I don't have to repeat the same boilerplate.
- 27:55Yeah.
- 27:55All the time.
- 27:56Yeah.
- 27:56As soon as you're like, why is this so complicated?
- 27:58Why do I keep doing this?
- 27:59Maybe that's the time to think about how do I do it just one more time with a little more
- 28:03polish and then never again.
- 28:04Yeah.
- 28:05Yeah.
- 28:06So, the widgets have events, right?
- 28:09Like on a Windows, it'd be like a WM key down, like win32 event that is then translated to
- 28:16the Wix event, which then calls back into, say, Python, right?
- 28:20And what you do is you give it just either a class level or just a regular function.
- 28:25Whenever somebody clicks this button, call this function, right?
- 28:28Yes.
- 28:28It's usually like for buttons, it's like WX.event button, and then you just bind it to a function.
- 28:34Right.
- 28:35Or you could bind it to the entire app if you wanted to, so it captures the clicks.
- 28:39Yeah.
- 28:40Yeah.
- 28:40What I thought was interesting looking through the framework was in many UI framework, like
- 28:45native compiled built-in frameworks, they don't, basically the button gets a click or it doesn't,
- 28:53or somebody clicks the thing outside of it or it doesn't.
- 28:56But in JavaScript, we have like bubbling events that go up and down.
- 29:00So, if I click on a label, but the label doesn't handle it, like, but somewhere higher up, maybe it's in a div and the div is handling the event, like that would catch it, right?
- 29:09So, you have this ability to say, go up until it's the right level to deal with this action.
- 29:14And it looks like wxPython has that as well.
- 29:16Yes, it does.
- 29:17Yeah.
- 29:17Yeah.
- 29:17That was a little surprising that you can sort of bind the same event at different levels and then either capture it or let it keep flowing up.
- 29:25So, they both get hit, I guess.
- 29:27Yeah.
- 29:27You can do that and you can, you know, execute your event and then you can say, I think it's event.skip.
- 29:31Yeah.
- 29:32And it'll go to the next level.
- 29:33Right.
- 29:33That's like, don't let me consume the event.
- 29:35Let it keep going.
- 29:36Mm-hmm.
- 29:36Bubble it up or something.
- 29:38Yeah.
- 29:38Yeah.
- 29:38Really nice.
- 29:39So, one thing that you talked about that I thought was interesting before we get into maybe a little more detail is you talked about, it's really nice to have a conception of what your app is going to look like, especially around layout, right?
- 29:51Mm-hmm.
- 29:52Yes.
- 29:52So, you recommended, well, one is just like writing stuff out on paper, which is always good.
- 29:58We also recommended using Balsamic as something where you could potentially sketch out the UI.
- 30:03Yeah.
- 30:04I really like Balsamic because it just makes, it makes laying stuff out kind of a breeze.
- 30:08You could also, you know, you could use that cute designer because it's free and open source.
- 30:12You could use that to lay, to draw a layout too.
- 30:15Right.
- 30:16Even though your destination is not ultimately cute.
- 30:18Correct.
- 30:18But it still lets you drag the widgets around, right?
- 30:21Yeah.
- 30:21So, you could still get a good idea of what you want it to look like using that.
- 30:25Yeah.
- 30:25I guess if you had a really old version of Visual Basic laying around.
- 30:28Yes.
- 30:28That also works.
- 30:29I thought about that.
- 30:30The VV6.
- 30:32I mean, that thing went out of support like in the 90s, but you might get it to run.
- 30:36But yeah, the Balsamic one.
- 30:38I really like this.
- 30:38I've used this for prototyping a couple of things.
- 30:41I think I used it a lot when I was building the Talk Python training platform and stuff like that.
- 30:45But it's one of these wireframe type of tools that like specifically is not meant to look native or finished.
- 30:54Right.
- 30:55It kind of looks as if you had drawn it by hand.
- 30:57Like the web browser, it's sort of wiggly lines as if you had sketched that out.
- 31:01Right.
- 31:01I like this thing a lot.
- 31:03It's a good recommendation.
- 31:04Yeah.
- 31:04I really like it.
- 31:05It's not super expensive and it does a good job of sketching the ideas that you have in your head.
- 31:10Yeah.
- 31:10For sure.
- 31:10A couple of live stream comments.
- 31:12Just to get a quick shout out to you.
- 31:14Alexander says, interesting.
- 31:15Sounds like React in Python when we're talking about the event bubbling.
- 31:18Yeah.
- 31:18Very cool.
- 31:19And then David has equated you to Brian Okken.
- 31:22Mike is to Python GUIs as Brian Okken is to pytest.
- 31:26Yeah.
- 31:26So really cool.
- 31:28I guess one more general concept let's talk about a little bit before we maybe just touch
- 31:32on some of the lessons and whatnot from the various apps and the types of things that people could
- 31:37go play around with.
- 31:38And I'm guessing the source code for these apps is on GitHub available.
- 31:42Even if people don't have the book, they could probably go dig it up.
- 31:44Yes, it is.
- 31:45Yeah.
- 31:45Same.
- 31:46Same for all my stuff.
- 31:46And the extra thing that I really want to talk about is layout.
- 31:50So layout's interesting, right?
- 31:52You've got these different, what are they called?
- 31:55Resizers?
- 31:56Resizers, yes.
- 31:57Yeah.
- 31:57So if you're going to put like two buttons next to each other, then you just want them to
- 32:02take up 80% of the space combined and have a little bit of margin or something.
- 32:05If you just put them in a location, well, that might be true for their size at first.
- 32:10But if you move the window, obviously not so much.
- 32:13All right.
- 32:14Yeah.
- 32:14They'll just stay there.
- 32:15They're not going to move.
- 32:16They're not going to change size.
- 32:17Talk about the different layout sizers and how you can combine them.
- 32:22How do you build like real composed UI worlds with this?
- 32:26You know, you could use absolute positioning.
- 32:28I don't recommend it.
- 32:29But if you made your frame unresizable, then you could totally do that.
- 32:33Yeah.
- 32:34But if you want to use sizers, I usually use box sizers.
- 32:37They support vertical or horizontal alignment.
- 32:41So if you set it for vertical, which I think is the default, it will add the widgets from left to right across, I mean, horizontal.
- 32:48I get myself all confused.
- 32:49All right.
- 32:50Vertical is top to bottom.
- 32:51Horizontal is left to right.
- 32:53So as you add them, the widgets will stack in that direction.
- 32:56And the nice thing is you can nest the sizers.
- 32:58So if I wanted to, you know, add columns, I could put, you know, three or four vertical sizers, box sizers inside of a regular horizontal sizer or vice versa to just create these kind of stacks of widgets on my UI.
- 33:13All right.
- 33:13So let's think about this.
- 33:14So imagine I want to build like a photo viewer thing and I want on the left, I want a vertical list of all of the image names, you know, just the short image names, then maybe folders.
- 33:28And I click the folder and then in the right, I get like a grid of photos.
- 33:32So overall, I've got the panel and then I would put a vertical sizer that has the two pieces, right?
- 33:40Yes, probably.
- 33:41The one on the left would be another vertical sizer that just takes a bunch of like little image name display and things.
- 33:48And on the right, maybe a horizontal one.
- 33:50Or does it have to wrap?
- 33:51Would that wrap around?
- 33:52Or would it just shoot off the screen to the right eventually or make them really small or something like that?
- 33:56It should make them smaller if you make it too small.
- 34:00But you can also set size hints in Dabix Python that says, do not reduce this window beyond, you know, like 400 by 400 pixels or whatever it is.
- 34:09Okay, just get like a scroll bar or something like that.
- 34:10Yeah, you can tell.
- 34:11So that's actually a different widget.
- 34:13There's a scrollable panel that you could add.
- 34:16And then the scroll bar will appear when you resize as appropriate.
- 34:21Right.
- 34:21Okay.
- 34:21Another way you could do that is use a splitter window and then have your widgets, some widgets on the right and some on the left.
- 34:27Interesting.
- 34:27Okay.
- 34:27So you really have to probably think about how do you compose these things, though?
- 34:31There's not like one super duper layout that's just going to do all this stuff.
- 34:35You're like, here's a section.
- 34:37There's a section, right?
- 34:38Yeah.
- 34:38I mean, there is a flex grid sizer and a grid sizer.
- 34:41So if you know your layout is going to be kind of in a grid shape, you could use one of those grid sizers and lay them out that way.
- 34:48They're a little bit confusing to work with at first because you're trying to figure out, you know, where does everything go?
- 34:53They work great for like a calculator because that's a grid.
- 34:56Right.
- 34:56Okay.
- 34:56But.
- 34:57And they're probably not changing.
- 34:58It's a fixed number of nine or whatever.
- 35:01Yeah.
- 35:02Things are going in there.
- 35:02And you could nest, you know, box sizes inside of the grids to make, give yourself more flexibility.
- 35:06Mm-hmm.
- 35:07Make the return button bigger or something like that as it stretches.
- 35:10I believe you can make each cell in a grid sizer stretch differently.
- 35:13So you don't actually need to do the nesting.
- 35:16I was thinking more like if you needed to like have stacks of widgets in a cell within the grid sizer, then you might need to put a different sizer inside of it.
- 35:24Yeah.
- 35:24Okay.
- 35:25Very neat.
- 35:26Quick feedback from the live stream.
- 35:27Matt Robynson says in my last company, we used a bunch of Wix Python.
- 35:30Your book was an awesome resource.
- 35:32Super cool.
- 35:33Oh, cool.
- 35:33Awesome.
- 35:34Yeah.
- 35:34Yeah.
- 35:34Very good.
- 35:35All right.
- 35:35Now let's go on and talk about some of the apps in your book because I think, you know, thinking about like what are the kinds of apps I could build with this framework reasonably and stuff that fits in a book usually has to fit that reasonable category.
- 35:48It's not like, well, we're going to build Microsoft Word and like, you know, something that does a zillion things.
- 35:54So let's see the first one that you had there was really the first meaningful one was like an image viewer, which is a little bit like a simpler version of what I'd sort of just described.
- 36:06Right.
- 36:06Yes.
- 36:06I chose the image viewer because I know it wouldn't take a lot of code to create something that just shows you an image on screen.
- 36:12And because JPEG's Python uses pillow underneath, it can support most image types natively, which is really handy.
- 36:20Yeah.
- 36:20It supports, you know, the list is like seven or eight different formats, ping, JPEG, GIF and on and on.
- 36:27Right.
- 36:27Which is something that TK Enter doesn't do.
- 36:29It only supports like two or three natively.
- 36:31And then you have to import pillow.
- 36:32Yeah.
- 36:33Give us a BMP and you're like, how do I get a BMP?
- 36:35Like in a TIFF?
- 36:36Like where did it?
- 36:36Yeah.
- 36:37It gets very unhappy if you do that.
- 36:39Yeah.
- 36:40That's cool.
- 36:40And then it started out as just, you've got a button that says choose a file and then you show it on one of these, these image widgets, which is pretty straightforward.
- 36:50But, you know, I was still impressed that when you click the button, it's like a really clear way to open a dialogue that is the native dialogue.
- 36:57So in your case, you used your Mac file dialogue and it has like all the stuff you'd expect on the left.
- 37:03It's got like your favorites and your tags and, you know, whatever customizations you've done to your binder, whatever.
- 37:09Yeah.
- 37:10Because JBS Python does their native.
- 37:12Exactly.
- 37:12And it's always drove me crazy that like, oh, I know on the real OS, I can navigate to another folder this way, but now I'm just hitting the up arrow over and over again.
- 37:21And, you know, it's just those little things, you know, they just, it's nice to have it native.
- 37:26Yes, I agree.
- 37:27I feel your pain.
- 37:28Yeah.
- 37:30So to like, for example, open up file dialogue, you create a context manager and you just say with, I don't remember the exact command, but you give it basically the file description.
- 37:39And then the file filter and you say open and you just check to see if they hit okay versus cancel.
- 37:44And then you work with it in the, within the context.
- 37:47All the wxPython dialogues.
- 37:49And I think maybe even the frames support using them as a context manager to open and show them.
- 37:54Yeah.
- 37:54It would make sense if you wanted to create the equivalent of a modal dialogue, but a custom one that you create, put that in a width block too.
- 38:00Right.
- 38:01Would that work?
- 38:01If you inherit from Dabix dialogue, I believe it well.
- 38:04Yes.
- 38:04Okay.
- 38:05Yeah.
- 38:05Super neat.
- 38:06So I guess you probably have to learn your class hierarchy.
- 38:09It sounds like I got to know.
- 38:11I got, I, this one derives from frame.
- 38:12That one derives from dialogue.
- 38:14Unfortunately, there is a bit of a learning curve.
- 38:17Yes.
- 38:18But once you've got the top level widgets figured out, which are frame dialogue and window, and you almost never use window, you know, you're not too bad.
- 38:26Yeah.
- 38:26All right.
- 38:27Another one that you built was the database viewer based on SQLAlchemy, object list view, and so on.
- 38:34And tell us about that.
- 38:35So I actually wrote this example a long time ago for my blog, and then I updated it for my book.
- 38:40I've always liked SQLAlchemy, and I realized that I could create a SQLAlchemy model class and use it with Dabix Python because they have a third party widget called the object list view that basically matches a model in SQLAlchemy almost exactly.
- 38:56So I can kind of combine the two classes and make them work together in a way.
- 39:00So that's kind of what I did.
- 39:02I just made it so that I could open up a SQLite database in the book.
- 39:05Do you basically see the tables and then click on them and get the records or something like that?
- 39:10Yes.
- 39:10You can see the records.
- 39:11I think I made it so I can edit the records too, or maybe that was just on my blog that I did that.
- 39:17Yeah.
- 39:17What widget do you use that shows basically the Excel looking view?
- 39:21That's object list view.
- 39:22Dabix Python has its own native widget called WRX list control.
- 39:26And object list view is kind of a wrapper of that widget that makes it a lot easier to work with, in my opinion.
- 39:33Yeah.
- 39:33What about animations?
- 39:35I know that doesn't have anything to do with the app that we're talking about, but is there some sort of support for changing the screen?
- 39:42Or if I'm going to put something on the screen, like I want to build a dashboard that is maybe looking at all the analytics on our system and it updates once a second.
- 39:51How easy is that to do?
- 39:52So if you're talking like a graph?
- 39:54A graph or even if it just has numbers, like here's the current flow rate of such and such or the number of users on the site versus like the minutes of video watch today up to date by the second.
- 40:06Something like that.
- 40:07Yeah.
- 40:07You have a couple of options.
- 40:08Dabix widgets has a, I believe it's called a device context.
- 40:11Dabix.dc.
- 40:13It has a couple of different variants of that.
- 40:15You can use it to basically draw whatever you want.
- 40:17And it's the basis for creating a lot of the custom widgets that you'll see in the Dabix Python demo.
- 40:22So you could use that to like draw any custom widgets you want.
- 40:25I see.
- 40:26So you're just given like a rectangle or whatever and just go crazy with the draw commands on it.
- 40:31Yes.
- 40:32The alternative is that Dabix Python supports matplotlib and can embed it easily.
- 40:37And it also has its own pyplot library.
- 40:39So it can draw them without matplotlib itself.
- 40:43So both of those are also options.
- 40:45Yeah.
- 40:45Very nice.
- 40:46What's the external like super custom control world look like?
- 40:51So we've got the Wix widgets, but are there like other third party libraries that you get?
- 40:56Like, oh, here's like a really fancy editable grid type of thing or auto completing drop downs or,
- 41:03you know, is there an ecosystem around those types of things?
- 41:06And I remember in Visual Basic and like Windows forums, there was like whole companies based around
- 41:11building those little extensions.
- 41:13Well, I know that I know the object list view was a third party one for a while and it still
- 41:18is third party.
- 41:19But I think the actual C++ version of it has outstripped the current wrapper for it.
- 41:26So it's the current wrapper doesn't follow it very well anymore.
- 41:28Besides that, there used to be a guy, Andrea Gavanna, I believe is his name.
- 41:33He created a ton of awesome custom widgets for Dabix Python.
- 41:37And eventually they got wrapped into the Python framework itself.
- 41:41So now it's like import WX.agw and you have access to all of those custom widgets within
- 41:47Dabix Python.
- 41:48But besides those, there's not a lot out there that I can think of that are like just custom
- 41:55ones you'd add on.
- 41:56Right.
- 41:56I was doing some quick searching for whether or not there's like an awesome list, basically,
- 42:01for those types of things.
- 42:03I couldn't find it, but maybe people, someone out there knows the one, they can send it
- 42:06to us and I'll put it in the show notes.
- 42:08Cool.
- 42:08Yeah.
- 42:08Cool.
- 42:09So another one that you built was one that would look at basically zip files or tarball
- 42:15and pull those apart.
- 42:16Yeah.
- 42:17What are some of the cool takeaways from that?
- 42:18Oh, for me, it was fun to dig into Python's native Tarian libraries, which I haven't played
- 42:24with that much.
- 42:25And I was originally going to include the zip file, but zip files tended to be more buggy when
- 42:30I was playing with it.
- 42:31So I just stuck with tarballs to keep it simple.
- 42:34But the main takeaway is that it works really well with wxPython.
- 42:37I try to show newer concepts like Pathlib in this book using, you know, in conjunction with
- 42:43the tar file library.
- 42:46Yeah.
- 42:46Pathlib is nice.
- 42:47Yeah.
- 42:47It's not entirely obvious when you first get to it that the division operator been taken
- 42:52over.
- 42:52No, it's not.
- 42:53To combine elements.
- 42:55But at the same time, it is quite neat once you learn it.
- 42:58Yeah.
- 42:58The syntax always throws me when I see those examples.
- 43:01I'm like, what?
- 43:01Oh, yeah.
- 43:03All right.
- 43:03That's how it works.
- 43:04Yeah.
- 43:04All same thing for date time and time deltas.
- 43:06Nice.
- 43:07Yes.
- 43:07And then you mix those with f-strings and you get into a whole other world.
- 43:11Yeah, absolutely.
- 43:13Absolutely.
- 43:13All right.
- 43:14Another one that you discussed was creating an application for NASA's API.
- 43:18I don't know what NASA's API is, but that sounds fun.
- 43:21Tell us about that.
- 43:23So this one was actually recommended to me by the Kickstarter people that were back to the
- 43:28book.
- 43:28They were like, so whenever I do a Kickstarter, I ask the backers, what ideas do you guys have?
- 43:33What do you think will be a good addition?
- 43:35And someone was like, well, NASA's API is basically open source.
- 43:40You can query it if you have a license API key.
- 43:43And you can make it show you basically any pictures that NASA has publicly available.
- 43:48So the NASA API will let you get photos of the moon, get photos of their launches, get
- 43:54photos of Mars, you know, whatever.
- 43:55Nice.
- 43:56And they really wanted an example of how do you make Dibix Python hook up to a web API?
- 44:01So that's kind of what this chapter is about.
- 44:04Yeah.
- 44:04That's a pretty cool example, right?
- 44:06There's a lot of fun stuff that you can check out there.
- 44:08Yeah.
- 44:09It was fun.
- 44:10So at api.nasa.gov, you can go over there and yeah, there's a bunch of stuff.
- 44:15Pad maps for the moons, two-line element data for earth elements orbiting the earth.
- 44:21Yes.
- 44:22You update it in real time and so on.
- 44:24Yeah.
- 44:24Nice.
- 44:25So what did you end up actually building?
- 44:27Like there's a bunch of APIs there.
- 44:29I think this one only like loads, it has a, basically a list control widget, which I use
- 44:35to display the search results when you query the NASA search.
- 44:39And then when you click on them, it will load the image.
- 44:42So, you know, if I looked up like Challenger space flight or Apollo or whatever, it'll show
- 44:47all the public NASA images in that list box and you can click on them and it will load the
- 44:52picture for you.
- 44:53So you can view the picture.
- 44:54Yeah.
- 44:54There's a ton of room for improvement, like how to download the picture, which I believe
- 44:58I covered how to download it with the GUI.
- 45:00But you could also, you know, add a tag editor.
- 45:03So you could view the metadata in the images.
- 45:06Right.
- 45:06And then you could browse it by show me all the pictures of the shuttle or, you know, things
- 45:11from this mission or something like that.
- 45:13Or from this date.
- 45:13Yeah.
- 45:14Yeah.
- 45:14Cool.
- 45:14That seems like a really fun thing to play with.
- 45:16And just people who are looking to have a fun API out there in the world to choose.
- 45:20That seems like a neat one.
- 45:21Yeah, it was really neat.
- 45:22Yeah.
- 45:23Super cool.
- 45:24So I guess, you know, there's a bunch of other stuff that we could talk about that
- 45:27you wrote about.
- 45:28But I think one maybe final thing, one of the challenges that's not immediately obvious with
- 45:34Python is how do I take my Python code and give it to somebody so they can put it in their
- 45:40doc or their taskbar as a picture and click it and see it without them, without discussing,
- 45:46here's how you create a virtual environment.
- 45:47Here's how you have the right version of Python.
- 45:49Here's how you pip install the requirements.
- 45:50How do you distribute this as what normal people would perceive as an application?
- 45:55Well, fortunately, the major Python GUI builder, executable builders support wxPython.
- 46:02So in the book, I use PyInstaller as an example, because it can package up wxPython pretty easily.
- 46:09Okay.
- 46:09You have to give it a special command line argument to tell it that it's a windowed application
- 46:15versus a terminal application.
- 46:16Right.
- 46:17I think maybe the default is to also have a terminal window.
- 46:20It would distribute it, but you have an odd terminal window just to the side of your app.
- 46:25Yeah.
- 46:25So if you have like any debug in your application, it'd show up in the terminal window, which,
- 46:29you know, might not be ideal.
- 46:30Yeah.
- 46:31No, for sure.
- 46:32So I cover that in the book.
- 46:34The nice thing about PyInstallers, it also works for creating executables on Mac and
- 46:38Windows.
- 46:39Not all of them do that.
- 46:40I have used Py2XE pretty extensively over the years, and it works great for Windows.
- 46:45But, you know, again, it's not going to work for anything else.
- 46:48Right.
- 46:48So you found PyInstaller was pretty reliable across the platforms?
- 46:51Yeah, it works really well.
- 46:53The only problem I have is that I think if you do the all-in-one file, Windows Defender
- 46:59will mark it as malicious and delete it.
- 47:02Oh, that's not good.
- 47:03And I think it does that for, you know, whether it's a wxPython file or not.
- 47:07Anytime you create the one file executable with PyInstaller, it's like, oh, that's a bad
- 47:13file.
- 47:13I'm going to delete it for you.
- 47:14Not ideal.
- 47:15No.
- 47:16I think you can...
- 47:16Someone must have used it to try to package up a virus or something at one point, and
- 47:21then it got fingerprinted and that was that.
- 47:23Yeah.
- 47:24I think you can self-sign the file or something to get around that, but I didn't go into that
- 47:29in the book.
- 47:29Yeah.
- 47:29I think you got to register as a developer with Microsoft to get like a signing certificate
- 47:33or something.
- 47:34Mm-hmm.
- 47:34I don't think I've ever done that.
- 47:36So, but there are, like when you say try to run it, you know, same thing on Mac.
- 47:39It could either, sometimes it'll completely block it.
- 47:42Sometimes it'll say that came from the internet, but we kind of recognize that person.
- 47:46Or I guess if you super duper sign it, it'll just run.
- 47:49Yes.
- 47:50Yeah.
- 47:50Depending on the platform.
- 47:52So another thing, you know, one thing that I did is I created this little app that runs
- 47:56in the Mac menu bar, and I created that with Py2App, and then it just gives people a .app
- 48:02file, well, zipped up, but then you unzip it, it's a .app file.
- 48:06Yeah.
- 48:06And then you can just run it, and that's worked well.
- 48:08But like Py2Exe, Py2App is a Mac-only thing, right?
- 48:13Like one platform.
- 48:14I know Py2App also works with WXPython, my experience.
- 48:17Yeah.
- 48:17These sort of packaging utilities, they work pretty well for the different platforms.
- 48:22If you're using .duvx Python.
- 48:23Yes.
- 48:24Yep.
- 48:24I haven't had any problems with them.
- 48:26You can get squirrely things with other packages, but not usually with WX.
- 48:30Yeah.
- 48:30Very cool.
- 48:31All right, Mike.
- 48:31Well, I think about is all the time we have to talk about GUIs and stuff, at least .duvx
- 48:38Python.
- 48:39But give us your verdict.
- 48:40Is there something you enjoy working with, building apps that people are liking with it?
- 48:44I don't know about other people, but I still use it whenever I can.
- 48:47For work, I'll create simple apps to demo whatever I need to demo to my employer or my PM.
- 48:55So, I mean, you can still throw together a really simple app with wxPython and only a hundred lines,
- 49:00or, you know, a couple hundred lines.
- 49:01And they'll show off something that looks awesome across platforms.
- 49:04Yeah, very cool.
- 49:05Yeah, again, I know I keep going on and on, but the native bits just make me happy.
- 49:09A quick couple of questions from the live stream.
- 49:12One is, it doesn't want to show up.
- 49:15There you go.
- 49:16If I purchase the book, wxPython recipes, is it still relevant or outdated?
- 49:20I'm not familiar with this book.
- 49:22Yeah.
- 49:22Is this yours?
- 49:23I have a wxPython cookbook from A-Press.
- 49:25I believe the examples in it still work, but they're kind of like all over the place.
- 49:29I tried to group them intelligently, but I mean, they're helpful, but they're not going to
- 49:35like help you.
- 49:36I don't know how to describe it, but they're more like, these are very specific things.
- 49:40So read the table of contents before you buy that one.
- 49:43If he's talking about Cody Precord's book, which is Dibbix Python recipes from Pact Publishing.
- 49:47I haven't read it in a while, so I don't remember.
- 49:50Yeah.
- 49:51And I have no experience with it either.
- 49:53So, but you can check out this one.
- 49:54This has got at least 10 good little apps in it for sure.
- 49:57Yeah.
- 49:58Okay.
- 49:58So I guess with that, I'll ask you the final two questions that I always ask everyone.
- 50:03If you're going to write some Python code, what editor are you using these days?
- 50:06I'm still a big fan of Wing IDE from Wingware.
- 50:10Cool.
- 50:11So I hear a lot of people on the VS Code wagon these days, like why Wing?
- 50:16For me, I still like that it has a source, what do you call it, a source assistant, which
- 50:22basically shows you the doc strings and links to the documentation live at all times for
- 50:27whatever line of code you're on.
- 50:29So, you know, if you've imported something, it'll show you all that stuff and basically
- 50:32help you learn new modules as you work.
- 50:35The other thing I really like is the debugger.
- 50:37The debugger on it is really good.
- 50:39Yeah.
- 50:39Fantastic.
- 50:39Okay.
- 50:40And then notable PyPI package.
- 50:42I mean, there's always wxPython if you want to throw that one out there, but you got
- 50:46another one in mind.
- 50:47For me, it would probably be OpenPyXL because I've been working with it a lot the last couple
- 50:53of months.
- 50:54So OpenPyXL basically lets you read and write Excel files, the newer format, right?
- 50:59The XLSX version.
- 51:01Yes, it does.
- 51:02And you can do formulas and formatting and everything.
- 51:04Is that right?
- 51:05Am I...
- 51:06Formulas are kind of iffy, but the rest of it is, it does do.
- 51:10Nice.
- 51:10Pretty cool.
- 51:11So many people, I'm sure, receive Excel files all of the time and they want to process
- 51:17it with code rather than with a mouse and keyboard.
- 51:20So very nice.
- 51:21Awesome.
- 51:21Awesome.
- 51:22All right.
- 51:22Well, final call to action.
- 51:24People want to get started with wxPython.
- 51:26What do they do?
- 51:26They can check out my book or you can just go to WXPython.org and get everything you need
- 51:31right there.
- 51:32Awesome.
- 51:32Yeah.
- 51:32And I'll put a link to that in the show notes.
- 51:34So thanks everyone for listening.
- 51:36And Mike, thanks for all you're doing around the GUI stuff.
- 51:39Thank you so much for having me.
- 51:41You bet.
- 51:41Bye.
- 51:41Bye.
- 51:42This has been another episode of Talk Python To Me.
- 51:46Our guest on this episode was Mike Driscoll.
- 51:48And it's been brought to you by Linode, us over at Talk Python Training, and the transcripts
- 51:53are brought to you by Assembly AI.
- 51:54Simplify your infrastructure and cut your cloud bills in half with Linode's Linux virtual machines.
- 52:00Develop, deploy, and scale your modern applications faster and easier.
- 52:03Visit talkpython.fm/Linode and click the create free account button to get started.
- 52:09Transcripts for this and all of our episodes are brought to you by Assembly AI.
- 52:12Do you need a great automatic speech-to-text API?
- 52:15Get human-level accuracy in just a few lines of code.
- 52:18Visit talkpython.fm/assemblyai.
- 52:21Want to level up your Python?
- 52:22We have one of the largest catalogs of Python video courses over at Talk Python.
- 52:26Our content ranges from true beginners to deeply advanced topics like memory and async.
- 52:32And best of all, there's not a subscription in sight.
- 52:34Check it out for yourself at training.talkpython.fm.
- 52:38Be sure to subscribe to the show, open your favorite podcast app, and search for Python.
- 52:42We should be right at the top.
- 52:43You can also find the iTunes feed at /itunes, the Google Play feed at /play,
- 52:48and the direct RSS feed at /rss on talkpython.fm.
- 52:53We're live streaming most of our recordings these days.
- 52:56If you want to be part of the show and have your comments featured on the air,
- 52:59be sure to subscribe to our YouTube channel at talkpython.fm/youtube.
- 53:04This is your host, Michael Kennedy.
- 53:06Thanks so much for listening.
- 53:07I really appreciate it.
- 53:08Now get out there and write some Python code.
- 53:10I'll see you next time.