Python is taking over much of the development world as it quickly is becoming one of the,
or simply the most, widely used programming languages.
But that does not mean that Python is without its weaknesses.
In my mind, there are three such weaknesses.
Number one, GUI applications, desktop applications, that kind of thing.
Number two, a native general purpose mobile app for iOS and Android framework that we can
build that in Python.
And number three, deployment.
So that is a single binary or set of binary and resource files that I can send either
to a mobile device or to a desktop app or to a server.
And it just runs regardless of what they have installed on their system.
This episode is primarily about number one, the GUI frameworks.
One of the best frameworks out there looking to make Python a better language for desktop
applications is Qt, namely Qt for Python.
This week, you'll meet Christian Mareria Fredes from Qt to tell us all about the revitalization
of Qt in the Python space.
But you'll also learn they have aspirations to make Qt for Python an option for mobile
app development and to solve the deployment problem as well.
That hits all three of the weak spots I was telling you about.
We could only be rooting for them to solve these problems.
This is Talk Python To Me, episode 183, recorded October 10th, 2018.
Welcome to Talk Python To Me, a weekly podcast on Python, the language, the libraries, the ecosystem
and the personalities.
This is your host, Michael Kennedy.
Follow me on Twitter where I'm @mkennedy.
Keep up with the show and listen to past episodes at talkpython.fm and follow the show on Twitter
via at Talk Python.
Christian, welcome to Talk Python To Me.
Thank you very much.
It's great to have you here.
I'm very much looking forward to talking about Python GUIs, something I would love to spread
the word about, something I would like to see more options for.
And it seems like you are doing great work around that.
Yeah, totally.
I mean, that's why I'm here.
I mean, Qt for Python is something kind of new for the Qt project itself.
So I'm looking forward to discuss more things about it.
Yeah, exactly.
It seems like there's a real revitalization around that project, which is awesome.
Before we get to that, though, let's start with your story.
How did you get into programming in Python?
Well, everything started when I started in the university.
I had no knowledge of programming whatsoever.
I still remember the first class on the blackboard.
There was an X equals to X plus one.
It made no mathematical sense to me.
And yeah, it was mainly in C.
But on the second year, there was some weird class talking about Python that you didn't
know.
And from that day on, I mean, I started to do things by myself.
And then here I am.
That's really awesome.
So you had a formal computer science degree program you went through?
Yeah.
Back in my country, I'm from Chile.
There is something called informatics engineer.
So there is more like computer science, which I do a bit more of how company works and everything
like that.
So it's like a six year or something of study.
Oh, that sounds like a really cool project or study, course, study.
Yeah, totally.
Yeah.
And so how about today?
What are you doing now?
Well, we are currently approaching the official release of Qt for Python.
So we are really excited about it.
But of course, you will understand that there are many things to do.
So we are, you know, I mean, today was like a normal day, something, some bucks and trying
to bring all the features for the final release that will happen at the end of the year.
I'm very excited for that.
So you work for the Qt company that makes Qt.
Yes.
Yeah, exactly.
I recently, well, not recently, at the beginning of this year, I am here currently in Berlin.
I was doing my PhD here.
And then I decided to move it back to industry.
So I started to work for the Qt company because I was aware of it.
I mean, since like 2009 or something, I had some small projects and I was really curious about it, what they were doing.
And there was this opening, I apply and I started to work here in the Qt company.
Excellent.
So I guess a good place to start is just what is Qt?
Because we have things like PySide and PyQt and Qt for Python.
But Qt is a UI framework much larger than just Python, right?
Right.
I mean, to be honest, I mean, when I first started to work in Qt, for me, it was just a library to do interfaces, right?
So, but with all the other years of experience, I started to notice that it's really more than a cross-platform application framework.
And I mean, I noticed that even for C++ users, you are able to write some scripts and combine and have some tools for SQL or any like sockets and modules for everything that you can imagine.
I mean, the modules are really a lot and the things that you can do are really imaginable.
So let me see if I have my conception correct.
Yeah, I'll bounce this off you.
You let me know.
So for me, it seems like Qt is a framework for building cross-platform applications.
Much of that is GUI, but there's also things like custom threading things and, like you said, other libraries as well.
Is that a pretty good summary?
Yeah, I don't know.
That's a good summary.
That's a summary when I start my talks.
All right, perfect.
Yeah, so I guess I have a pretty good conception of it.
And I feel like the apps built in Qt are really nice because they seem like they belong on the OS or platform they're running on.
I feel like so many of these cross-platform things just stand out like a sore thumb.
One, a lot of them look like they're from, like, you know, 1990.
The other is you're like, whoa, that's not what a button looks like on macOS or on Windows or whatever it happens to be here on, right?
Exactly.
Yeah, my first experience, for example, I remember when I was learning Python, I wanted to do some simple application.
I tried to use TK, you know, TK Inter.
Yeah.
I mean, I admire the work, but, I mean, Inter interface doesn't look really well there.
And then I started to move around and everything.
And, of course, I'm aware that you know that, for example, one of the biggest projects that uses Qt is KDE.
And at least when I started with Linux, it was the most, like, you know, graphical appealing environment for me.
So, yeah.
Yeah, that's really nice.
That's really great.
So, let's bring this conversation over to Python now.
And maybe we could do a quick tour of what are our options for building Python GUIs at all.
I mean, you brought up TK Inter.
Well, obviously, we have Qt for Python nowadays.
There's other things like WX Python.
Do you want to give us a quick tour of what our options are?
Well, I mean, you mentioned, like, the main ones, right?
I mean, if you go into the Wiki page, for example, you can see that the list is, like, over 30 different modules to do different things.
But, of course, not all of them are active now.
So, personally, the ones that I am aware of that they are currently developed are, like, TK Inter.
I mean, the WX Python.
There is also PyQt, another set of bindings for Qt.
And also, there is another one called, what's the name, Kiwi, that also, lately, I have heard a lot of Hacker News and Reddit.
So, I think it is quite becoming a little bit famous.
Yeah, that's good.
Yeah, Kiwi's doing good stuff.
I feel like it's really focused on more on, like, game experiences.
And something like Qt, you could build, you know, a traditional application, right?
You could build Visual Studio Code or PyCharm or a web browser or something like that.
Yeah, I mean, as you can see, at the beginning, of course, for me, KDE was the biggest and only project.
But with the time, I mean, you can notice that nowadays, with all this data science boom, you can find, like, tools like Tableau, for example, that is written in using Qt or the latest version of VirtualBox and VLC.
I'm not even there.
I mean, because she's enjoying the company.
I noticed that, okay, I mean, when I was saying that this is a company, I mean, do we have other clients or outside, you know, open source project?
And I noticed that, for example, many companies in the automotive industry are using it right now.
I mean, of course, since we're in Germany, there's Mercedes.
And also lately, Peugeot announced something like that.
They were including Qt.
But most importantly, at least for me, for my geek standards, the cockpit of the Tesla car, for example, is designed using one of the Q technologies.
So that was really impressive.
Yeah, it was really impressive for me.
Yeah, Tesla is definitely one of the more, you know, turned on car companies in terms of technology.
So that's pretty awesome.
Yeah.
And you also have, you said that it's in LG smart TVs.
Is that right?
Yeah.
I mean, also, I mean, there is a couple of these TVs that have some manual.
I don't know how to describe it, but it's on the button that you have, like, different elements of the menu and stuff.
And that's also written with Qt.
And there is also some entertainment system by different electronic companies.
And, I mean, this is not just the official clients of Qt, right?
I mean, you know, it's an open source project also.
So there are many companies out there.
And luckily, on the latest conference that I went, for example, I met people of the biggest companies that approached me as,
ah, yes, we are using Qt for some internal project and everything.
So, of course, we have a lot of open source clients, too.
That's really cool.
I've talked to some companies even thinking about using it for devices, little embedded devices and stuff.
Yeah.
That's really a hard topic right now.
And, I mean, I didn't have the luck yet to work on embedded systems, but there is a lot of people doing a lot of work on embedded devices.
So, and every time that there are conferences, I mean, those are the things that steal the show.
I mean, all these embedded systems that we have in comparison with other technologies.
But, yeah, sadly, I am not an expert on that field, but maybe next time we can go further.
Yeah, that'd be great.
Yeah, it feels like Kickstarter should be involved.
A little cute, a little Kickstarter.
Yeah.
And something awesome could be launched.
Yeah.
Very, very cool.
So, the reason I reached out to you guys is we did this overview of the various GUI options.
And, you know, those folks who listen to my other podcast, Python Bytes, know that we've gone over so many options.
And there are a bunch of them.
But I feel like, like I said, Qt is one of the more, it looks native and it seems like you can build really nice apps with it.
But for a while, there had been this, I don't know, this sort of almost discontent where we had, what, PySide?
We had PySide 2.
Yeah.
You know, PyQt for Qt 4 and then Qt 5.
And it was like, well, what is the license model?
What one is up to date?
What should we do?
Can you just sort of let us know, you know, why did you guys work on Qt for Python?
And, you know, what is the state of that whole conversation there?
Yeah, well, I mean, the story is a little bit longer, but it mainly started with like, there was some collaborations of Qt in a different country.
I think it was Brazil.
And they decided to start a new set of bindings for Qt.
And the PySide project was born.
And then...
Maybe just find that real quick for folks.
Like when you say binding, what do you mean?
These are like Python libraries that we can use in Python, but they talk to the C API?
Exactly.
There is some CPython code that will be like connected to C libraries.
So that's why we can expose this C++ framework to Python world.
So we have some glue in the middle that maybe later we can discuss.
But yeah, I mean, I know that it's confusing about the names, but I mean, it's really depending on the changes of the Qt projects.
Because, I mean, there was some Nokia related things going on in the middle.
And then there was like no Nokia.
And then the project started to evolve.
The Qt was Qt 4 back then.
And then they said, okay, but now it's Qt 5.
So what do we do?
And there was some effort by the community to start to port it.
And that's why PySide 2 was born.
Because now there was support for Qt 5.
But the problem is that at the company, we didn't want to focus just in the module.
And this is really important for me to say because Qt 4 Python is not just the module.
I mean, we have a lot of ideas and things going on that will try to complement this PySide 2 module that currently we have.
Okay.
That sounds very interesting.
So where does Qt 4 Python fit?
Is this just you taking over the PySide 2 project?
Is this something different?
Yeah.
Well, that's the thing.
I mean, at the beginning it was associated with Qt, but not officially supported.
So now the move, all this noise that we have been generating is because we are officially supporting PySide 2 as a module in one of the Qt products.
So that means that any person that wants to start to use Qt by open source will have the options to get PySide 2 as a module, also to play around with Python.
Or if you're a client, for example, and you want to have some commercial license and everything, you will have the option also to get these officially supported bindings that allows you to use Qt from Python.
That sounds awesome.
I'm really excited to hear that you're focusing full effort on this GUI platform for Python.
Yeah, totally.
Yeah, it's going to be great.
And you said the official first release of this Qt for Python update is targeted at the end of the year?
Yeah.
Well, at the moment, the project was being heavily developed, and we decided to give it a try.
So we generated the first set of wheels that we released on PyPy, like in June, I think.
But of course, this was under the technical preview label.
So of course, use it at your own risk.
But we are currently reaching a maturity stage that we are sure that by the end of the year, which is the release of Qt 5.12, we will include the official wheels without the technical preview tag.
So yeah, we're really looking forward to it.
Oh, that's going to be super cool.
Now, you're talking about wheels.
So that's when I pip install a thing, you know, downloads it and installs it in a nice, simple, Pythonic way.
Exactly.
I believe previously in the PySide, PyQt days, that was harder to basically deploy an app that was built on Qt or one of those frameworks, right?
Right, right.
So, go ahead.
Yeah, no, but I mean, if you, well, even before, I mean, I don't know, I mean, I know that you have been using Python for a lot of time, but even the time with X, you remember that X was first before the wheel, it was quite complicated to generate this kind of like project and stuff.
And I always was struggling with this.
But yeah, at the moment, for example, many users ask us like how to deploy applications, how to move these things around.
But yeah, we usually encourage people to use PyInstaller.
So, yeah, spoiler alert, that's one of the things that we are currently working on, like to try to help the users to provide ways to deploy the application in a more easy way.
Because Qt is cross-platform, so, of course, you would like to have some binary that you can, like, move around and try to execute and try to don't worry about on which platform you are running.
Oh, you guys would take it up a level if you did that.
I mean, if there was a build my project for macOS, build my project for Linux, and here's the thing you give your users or you put on your website.
Seriously, that, I mean, you already have one of the best cross-platform frameworks.
And if you could solve the deployment problem for Python, it would be all.
Yeah.
There are a few options out there.
I mean, currently, there was some, or a blog, there was a story of another system that was called FBS, which is a guy that we had the pleasure to talk with.
And they also have some small project that is starting to attack this problem because it's really, I mean, it's like every day someone on IRC is asking about, like, how do I deploy my application?
How can I integrate this with other tools and everything?
Yeah, yeah, that's the Fman build system from Michael Herman.
That's pretty awesome.
Yeah, so that's a pretty promising project.
And if you could get some sweet integration where, you know, a lot of, yeah, it seems really, really nice.
And he's doing a lot of stuff with Qt.
Yeah.
So that's cool that you guys are talking.
Yeah.
I think it's already, though, it's already better that you can pip install -r requirements.txt or, you know, pip inf your world, and you just get the Qt runtime.
I'm at a cute runtime, excuse me, which it doesn't mean, like, oh, go get this weird installer from some other place that you're not really sure, install that, right?
It's nice to have it just come already.
And if you could get, like, a true binary, then that would solve, I think that would really be something.
Yeah, even internally, I mean, there were many people, I mean, since it's a longstanding company using C++, I mean, a couple of people that were recently joining the company when they first tried it.
And then we said, like, I just pip installed PySight 2, and I have everything now from Python.
I mean, which kind of magic is this?
I mean, they were not even aware of, like, how fast can be.
And I think this is one of the main reasons that why the Qt company wanted to officially support Python, right?
Because, I mean, this is a podcast about Python, so we don't need to convince people about it.
You would be surprised.
There's a lot of people that listen that maybe Python is not their main language, or they're just getting started, and they're still exploring.
You'd be surprised.
So there's probably a lot of people who, you know, still, even if they've been doing Python for 20 years, maybe they're like, well, it's great for websites and backends, but I'm not going to build my UI in Python, right?
So convince us, yeah, convince us by Python.
I think it's great if you can do it.
Yeah.
Yeah, well, I mean, every single person that is touching code at some point is aware of Stack Overflow.
And, for example, I remember that this year's Stack Overflow Insights were showing how popular Python was becoming.
And after all these years, I remember back in the day that in the university, I was, like, there were the Perl people and the Python people.
And, of course, all the Perl people are the devil, and we will not talk about Perl.
But currently, you can see that even some index that, like, measure the amount of questions or, I don't know, search queries about programming, like the TOB index, for example, they were showing Python approaching the top three.
Yeah.
It's amazing.
Not even that, not even, like, general users, because, I mean, I have also some background in academia when I was doing my PhD.
I encountered that most of the old researchers were using programming languages like Fortran, for example.
But all the new ones were using Python.
And that's how we have now the IPython notebooks that now are called Jupyter project and all these data science-related things that it's mainly using with Python.
I mean, and you cannot, like, expect for some, like, new position data science to ask for, I don't know, C or Fortran.
That's really, really, really in the past.
I think that's the key.
This portion of Talk Python To Me is brought to you by Linode.
Are you looking for bulletproof hosting that's fast, simple, and incredibly affordable?
Look past that bookstore and check out Linode at talkpython.fm/Linode.
That's L-I-N-O-D-E.
Plans start at just $5 a month for a dedicated server with a gig of RAM.
They have 10 data centers across the globe.
So no matter where you are, there's a data center near you.
Whether you want to run your Python web app, host a private Git server, or file server,
you'll get native SSDs on all the machines, a newly upgraded 200-gigabit network, 24-7 friendly support, even on holidays, and a 7-day money-back guarantee.
Do you need a little help with your infrastructure?
They even offer professional services to help you get started with architecture, migrations, and more.
Get a dedicated server for free for the next four months.
Just visit talkpython.fm/Linode.
Yeah.
Is the Q company largely a C++ organization, given that a lot of the main product is in C?
Yeah.
Of course, we have some automations and internal tools, but you can find that people knowing about many other programming languages.
I mean, I know that they're like also Perl experts or guys using Python for automating tasks, or maybe they have some system built with Go and everything like that.
But I mean, it's the majority of the users and the community around is like purely C++ experts.
Right, right.
I feel like the package management aspect, you know, pip install, anti-gravity, for example, type of things, really is something that Python brings.
It's so special compared to, say, C and C++, right?
It's just a different level of productivity entirely.
Yeah, exactly.
And that's one of the reasons that we're trying to use, for example, to try to, not to convince, but to bring Python to C++ developer.
I mean, how fast something could be to start something.
I mean, even if you want to have a small GUI that does something with clicking some buttons, you know that in C++, at least you have writing the code, compiling the code, and executing.
And if you want to skip one of these steps, which is to just write your code and execute it, I think that's really amazing.
And that's one of the main reasons why I started to even spread the word about Python in general when I was studying and my PhD also.
And yeah, that's the main motivation that we currently have as a company.
Yeah, that's cool.
I agree.
I think you missed a step.
It's also the figure out why that seg fault is happening.
Yeah, well, that's the thing.
I mean, day by day, all the people at the team is dealing with all the seg faults just to provide users for a seg fault-free environment.
I mean, you know, we're combining two worlds.
I mean, we have the same nightmares that sometimes have happened.
And on the other side, we have all the CPython structures.
So we try to combine these two things.
So debugging the development of Kube for Python is challenging, but at the same time, it's a nice source of knowledge.
Yeah, so let's dig into how it works a little bit.
And I want to follow up on this, you know, how you bridge these two worlds.
There's a lot of interesting possibilities there.
Yeah.
So how do we go from Qt code, Qt headers, and widgets and stuff to generating what is at code level called PySide 2?
Okay, so the thing that we do is that the original idea was to extract all this information from the Qt headers.
And for this, we use Clang.
And also we have some internal tool that's called Shiboken that allows us to modify these headers.
Because, I mean, you know, sometimes you have in C++ some void star or, you know, some double star pointers and stuff like that.
So we need to manually transform all these things and bring everything to the Python world.
Right.
Because Python doesn't have a void star star type, right?
Exactly.
So we need to do some black magic inside and under the hood that allows you to use the method that includes some void star things.
Yeah, for sure.
Okay, so there's the C++ definition of how to directly natively work with Qt.
And then use this thing called Shiboken, which generates modules that interact that are basically for CPython that can then talk to it.
So are you using like CFFI or the C API?
How does that work?
That's the magic.
I mean, back in the day when the developers started with PySty, they started to use BoostPython that personally I know that I have been using.
But I don't know if you have experience with it.
I have not.
No, what's BoostPython?
BoostPython is just the same idea.
And it allows you to generate bindings for Python from some C++ project.
But the problem with this is that, and it was the main problem back then, is that there is a lot of use of templates in C++, which is one of the obscure areas of C++ world.
And this also increased the size of the binaries that you're generating.
So the developers back then, they said, okay, what is the best solution right now?
Let's write our own binding generator.
So it was heavily inspiring BoostPython and trying to remove the template situation.
And there is this type system thing that I mentioned.
It's just a pure XML file with some directives of modifying signatures, for example, of the methods.
And then you can use this to generate the CPython code that you can compile and transform in Python module.
Okay.
It sounds very interesting.
And I recently learned that you can take this, Shavokin, and you can apply it to any C library, potentially.
It's not just for Q, right?
So this could be a useful tool for people who actually don't care about UIs.
Yes, exactly.
I mean, as soon as we started to release the official set of wheels, we started to get people like, I want to generate the bindings for my project and everything.
And yeah, it's possible to.
I mean, I encourage people to take a look in our blog that there was a post there to write Python bindings for a C++ project without any queue on it.
So, of course, I mean, it's something that is still under development and it's open source.
So there is still some incompatibilities.
For example, we have some issues with templates, if your project has some templates, and also maybe smart pointers and things like that.
But in general, at least for us, it do the work.
And we are planning now that once the release official releases out, that the open source community will react and will help us to improve Shavokin itself.
Yeah, it sounds like a really useful tool on its own.
Help me understand why or how this might differ from, saying, using something like Cython or something like that.
Would another reasonable path be to write part of your code in Cython and directly interact with the C part?
Well, Cython is just to, at least I use it just for optimizing some Python code.
But since we needed to create this bridge, you know, to have this glue between C++ and Python world, I think that the generator was needed.
And there are other options like that, I mean, out there that you mentioned, for example, the CFFI.
And also there is a nice, what was the name of this module?
PyBind 11, that also allows you to, you know, to generate the link between these two worlds.
So I think that Shavokin will be one of the nice options out there.
But still, I think that we need to, there's a lot of things to be done there.
Yeah, yeah, of course.
Okay, interesting.
Let's talk first at a high level about what some of the modules are.
You touched on this a little bit, but what do we get?
What do we have to work with when we work with PySide 2?
Yeah, well, it's sometimes can be really overwhelming for people to meet Qt in the sense of that there are so many things to do.
But I mean, for the users that are starting with generating graphical user interfaces, we have like three main modules in Qt that are, of course, exposed in Qt for Python.
So the Qt core, the one that has all the like basic definitions of types and classes that you will use.
And then we have some GUI elements that, for example, you can encounter there some like debase of how a widget is created.
For example, pixels or, you know, lines and stuff like that.
And then you have widgets, which is the more general one that exposes, you know, pre-made things.
Like if you have a button, a group box, a checkbox and everything.
So usually all the examples code that we currently have, most of them use these three modules for different functionalities.
But a normal user, I think I will play around Qt widgets and maybe Qt core for getting a few things.
Right.
You also have things like Qt charts, Qt multimedia.
Yeah.
And testing even, right?
Yeah, well, that's the thing.
I mean, there are many other modules that allow you to do things with Qt that sometimes are exposed in Python natively.
For example, we decided to, there is a few mathematical modules that we decided not to expose to Qt for Python directly.
Because, of course, you have the math module in Python or you have any other numerical library there.
Right.
So, but Qt charts, for example, is the one that gets more of our attentions.
At least there is a couple of nice examples in our code base that really brings people to joy to say, oh, my God, yes, it's so easy.
And they can combine it with any other numerical or data sources that they have.
That's cool.
So if I was doing like scikit, numpy, those types of things, I could take that data and visualize it and say like a Qt chart or something like that or a Qt chart.
Yeah, yeah, exactly.
I mean, that's one of the nice things that we are doing.
Of course, since all the API that we use is C++ based, we are now in a moment of defining like how to break this API, but not in a bad sense, but in the sense of like bringing Qt for Python in a more compatible way for Python world.
So nowadays, for example, there is a lot of research being done of like allowing numpy or scipy types into Qt methods and classes.
No, that is awesome because it's in C, in numpy, for example, right?
Like why does it have to go into Python, then back out into another C layer, right?
Like if you could just say, hey, you're all down there, figure that out.
Yeah, exactly.
That's the thing that we need to see what is underneath all these amazing numpy arrays and see how we can make it compatible with the signatures of the method, for example.
And pandas and whatnot.
Yeah, that's really cool.
Yeah, exactly.
Yeah.
All right.
So one of the things that really appeals to me with building GUI applications is a visual designer.
I know you can write code and I know you can specify it out, but being able to say, here's a button, I'm going to put that button next to that input box, you know, and just drag it there.
And then like, I'd like to, you know, I have this method called when I click it.
So I wire up a event to, you know, a callback to it.
So the Qt project has something like this, right?
Yeah, exactly.
So there is a, we have our own IDE, which is called Qt Creator.
And inside this IDE, I mean, I was, I confess, I mean, even when I started to work there, I was really not into this IDE because I prefer to use Veeam, for example.
But I started to discover the amount of things that you can do inside and it's quite remarkable.
I mean, it's my, for example, way to go for debugging applications nowadays.
And, but now that you mentioned the designer, you also have the ability of design interfaces, like, you know, the principle, what you see is what you get.
So you start to drag and drop things, move things around, then you generate some kind of scheme, right?
So this scheme will be translated into a UI file, which is something, of course, internally of Qt.
And then with this UI file, you can do as you want.
I mean, you can use it in your C++ project or you can use it for Python, for example.
You can load it dynamically or even generating some Python code from this UI file.
This portion of Talk Python To Me is brought to you by Rollbar.
Got a question for you.
Have you been outsourcing your bug discovery to your users?
Have you been making them send you bug reports?
You know, there's two problems with that.
You can't discover all the bugs this way.
And some users don't bother reporting bugs at all.
They just leave, sometimes forever.
The best software teams practice proactive error monitoring.
They detect all the errors in their production apps and services in real time and debug important errors in minutes or hours,
sometimes before users even notice.
Teams from companies like Twilio, Instacart, and CircleCI use Rollbar to do this.
With Rollbar, you get a real-time feed of all the errors so you know exactly what's broken in production.
And Rollbar automatically collects all the relevant data and metadata you need to debug the errors so you don't have to sift through logs.
If you aren't using Rollbar yet, they have a special offer for you and it's really awesome.
Sign up and install Rollbar at talkpython.fm/Rollbar.
And Rollbar will send you a $100 gift card to use at the Open Collective,
where you can donate to any of the 900 plus projects listed under the Open Source Collective or to the Women Who Code organization.
Get notified of errors in real time and make a difference in Open Source.
Visit talkpython.fm/Rollbar today.
When you start talking about editors, that's a very sensitive thing for me as well, right?
Yeah.
It sounds to me like I can take the Qt Creator, which is what that IDE you're talking about is called, right?
I can take that and I can define my UI files, but then I could still use my other editor to write the main code or something like this if I wanted.
Well, I mean, yes, but again, that's another spoiler alert.
No, but I mean, we are working on a proper integration with Qt Creator.
At the moment, I mean, you can use it to code your applications and everything and everything is there.
Syntax highlight.
And now we have even some testing phase for auto-completion.
But the problem is that we don't want to just provide a nice editor and that's it.
I mean, we want to integrate more options and a more like a better integration with the Qt project.
So just the thing that you mentioned about deployment or maybe transfer or creating base projects in Python.
So everything of this is in our like to-do list of like what is the future of the project.
So that's why we are so looking forward to releasing as soon as possible to start to work on these features.
And now, I mean, lately in the last post that we have from Qt for Python, we had some intern that was working with us and he managed to, for example, even extend the same IDE, Qt Creator, with Python scripts.
And this is something that is really new because in the past it was just C++.
But now, since we have PySide 2, you are allowed or you will be allowed to modify the IDE even with Python.
So we are Pythonizing everything.
That is cool.
So basically, I could write like extensions or plugins or whatever you call it for Qt Creator in Python.
Exactly.
That's the idea.
That's cool.
So I guess that brings up another thought for me is, you know, so much of Qt is in C and the entire API is C++ based and whatnot.
Do you see people writing part of their application in C++, but then maybe hosting the CPython runtime so that other people can extend their applications with Python?
Or does that not really happen?
Yeah.
To be honest, I mean, I was expecting less people doing this, but it's crazy by the amount of questions that we receive every day.
Most of the people out there with some companies and even like some startups and stuff, they are trying to extend C++ application in the same idea that we are presenting for Qt Creator and they are trying to use PySide for it.
So we have, for example, the same idea of writing plugins for your application is being done by any other project.
One of our clients, for example, which is the graphical effects industry, it's called Autodesk.
They also allow users to extend the application itself, writing the plugins with PySide.
And also, like I have heard some stories of people also with some big C++ projects trying to allow users to write Python stuff.
So, yeah, this is totally possible.
Okay.
How interesting.
So I guess some other areas you might try to work on is we talked about embedded systems a little bit.
What about mobile?
Yeah.
Well, mobile is something that every time that we go to some conference or talk, there is the question about what about mobile support?
People pull up their phone and they're like, here.
Exactly.
I want it here.
Billions of people are here.
How do I do this?
Are you working on this?
Yeah.
Well, this is something that at least would be like also another thing in our to-do list.
But we are focusing on the previous topic before.
But, yeah, it's something that we need to do.
We need to achieve.
I mean, at the moment, you have the option to go around with iOS or Android with Qt.
There are some options, even in Qt Creator to deploy C++ applications to it.
But, yeah, it's something that is really pending on us.
But it's something that we totally would like to do.
Because even though if you don't have the same feeling and you cannot compete with a native stuff like Android and Java and stuff, there's a lot of things to be done there.
I mean, you can see, like, all the revolution that Kotlin has after it was introduced in Android that, of course, is kind of getting rid of all the Java ugly code and bringing some new stuff on it.
So, yeah, we are totally going to be a part of that movement, too.
I would love for you guys to be part of that if you're bringing Python along for the party.
That'd be cool.
It's really kind of surprising to me that Kotlin, which is a language created by JetBrains, maybe the last five years, it's not very old, actually almost displaced Java over in the Android space, which is quite interesting.
Yeah, I mean, if you have some experience with Java, I mean, you will understand the pain.
I mean, sadly, I have some experience, too.
But, I mean, it was really frustrating even to writing small pieces of code.
And at least for me, Kotlin, I always have the same idea that the person behind Kotlin, the people behind Kotlin, like, really decided to write something in a more Python-y way.
I mean, we cannot deny it.
I mean, it really has a lot of Python on it.
And even the way of writing some stuff is like, hmm, this sounds like Python.
So, yeah, I'm pretty sure that they tried and they had Python in mind when trying to write it.
Yeah, interesting.
I really haven't done very much with Kotlin.
So, maybe I should check it out.
Yeah, it's quite nice.
It sounds interesting.
Yeah, there was an article.
I can't remember where it was.
It was on some major unexpected, you know, magazine or news source that was talking about the future of programming languages.
And it says, you know, one of the predictions was that Python is going to be the great-grandfather of many, many programming languages.
I think that's probably true.
And this sounds a little bit like that.
You have Swift as well.
Yeah, yeah, yeah.
Right, exactly.
Well, I haven't tried Swift, but I think it's, yeah, Python is a whole new starting point for the future generations and programming.
Because it's bringing something that is simplicity, right?
I mean, you know, I mean, the first time that I encountered Python, it was so easy to do things.
I mean, you didn't even know, like, oh, there was a semicolon or what, or, you know, open brackets, closing brackets, or what is the stars?
Yeah.
You know, it was simple.
That's the way that people started moving for, yeah.
It's so interesting that when you come from one of these C-based languages or something like C++, C#, Java, whatever, even JavaScript, you feel like, oh, all these curly braces are required.
All these parentheses around the if statement are required.
And then you come work on Python, and, you know, it's a bit of a shock to the system, for sure.
You're like, wait a minute, spacing matters?
There's no curly braces?
Where's it?
But then, you know, after just a week, if you go back to the other language, you're like, what is all this stuff?
Like, you're right.
These parentheses here are not necessary.
Why do I have to type all this stuff?
Yes.
And I remember back in the university, even teaching C, it was really a nightmare.
Because, I mean, we all write code and even write normal, like, with handwriting and stuff differently.
But having this space requirements, it's something that is so enlightened for writing code.
And, I mean, it's really difficult to write ugly Python code.
But I have seen, like, I mean, maybe you're aware of even, like, these obfuscated code tournaments that you have.
Yes, that's so interesting.
Yeah, tell people about that.
Because I remember just being blown away from it.
Well, the whole idea of obfuscated code is that to write code that can, when you see the code, it resembles something.
And usually are really cryptic things and moving bytes around and stuff.
And, for example, I remember the one more shocking to me was something about, like, a circle made with dots and a slash and stuff like that.
And then when you compile the circle and you execute it, you get the value of P.
And I was like, what?
That is beautiful.
It's really weird.
I mean, with Python, I mean, luckily we will not have this kind of obfuscated tournaments or something.
Because that would be a nice thing.
Yeah, it definitely goes against the Xen of Python for sure.
Totally.
Really cool.
So, speaking of styles and stuff coming together and worlds clashing, something that was surprising to me and I'd like to ask you about is when I look at the PySide 2 or just PySide, the APIs here, they all look C style.
You know, lowercase first variable and then uppercase second as the first letter, then uppercase second, like, compacted word or composite word.
Yeah.
As opposed to snake, you know, in the snake case with the underscores and all lowercase.
So, what's the story with this semi-non-Pythonic Python API?
This is really a hot topic.
Every time that I bring the talk about Qt for Python with C++ developers, Java developers, or even Python developers, everyone is hard to fight to each other.
Because there is some things that we cannot break in the sense of, like, the reason, for example, for keeping the camel case for the Qt API is because every person that already knows Qt or has some project in Qt, it will be so easy for them to just rewrite code in a Python way using the same API.
Because if we start to replace all the camel cases for underscore, which is the Python way of doing it, we will break everything.
And people will start to run examples, for example, from C++, and will be unable to decipher how to write these things in Python.
So, we said, okay, we need to settle somewhere.
So, everything, every time that we use the Qt API, we'll use camel case.
But everything else will be following all the peps that we want and the Python styling.
So, that's why the examples look a little bit mixed.
But, yeah, I mean, I think it is the best balance for the two worlds.
And we are not the ones, the only ones.
I think that there is asyncio or I don't know.
There is another module in Python that uses camel case for the API.
I'm not sure about it.
But, I mean, I think that is a nice solution.
Yeah, I have seen it before.
I can't remember where it was either.
But I'm like, wait, why is this library, you know, got this style?
And I think it was in the standard library.
That's funny.
Ian, that makes sense to me.
It's a bit of a trade-off, right?
Like, you've already got this code that exists.
And if you're going to generate it, there's this sort of easiest to generate exactly the same names.
If you don't have to necessarily do the documentation as differently.
Yeah.
And even for us, for translating examples, for example, we have like, we graph any function written in C++.
Then we copy it to the Python.
We remove the brackets.
We check the consistency.
We remove all the semicolons.
And that's it.
I mean, there you have it.
Look at all the complicated stuff.
You take it away.
All the unnecessary symbolic stuff that's hanging around.
And look.
It's the Python version.
Interesting.
Yeah.
I've seen other frameworks like where they have something.
Ultimately, it's a C API underneath.
And it supports different languages.
And they've taught basically the equivalent of their Shibokin to say,
if I'm generating Python, it looks like this.
If I'm generating JavaScript, JavaScript has this coding convention.
But I can see the argument also for just saying,
most of the people who are coming to this world are coming from the C++ world.
And their code looks like this.
Let's not shock them too much.
Yeah, exactly.
Totally.
Yeah.
But you have this debate often, huh?
Yeah.
I know.
It's something that is, even when we are writing the code base of the projects,
we have people that are really into Python, people that really comes from C++.
So when we are doing all the code reviews, we start to clash, you know, between like,
ah, you need to live in a space.
No, it's not CPython standard.
No, that's C++ standard.
So we need to even agree with you among us.
So yeah.
Yeah.
Interesting.
So one thing that I saw showing up in the documentation and the API and stuff was this
thing called signals and slots.
Yeah.
What's this and how does this look in Python?
So yeah.
I mean, signals and slots are the base of queued.
So the idea behind this is that we treat every single element of the interface and also underneath
as an object, as a queue object.
So these objects can interact between them.
And the idea of signals and slots is like that.
I mean, an object will have something that will trigger something else.
So let's put it like simple.
If you have a button, then a button is also a queue object.
And this button will have a special signal that it will call, for example, clicked.
Of course, because you can click the button.
And then this click signal will trigger something else.
So then you can have another function or method, or what you want to call it, that will be the
slot of it.
So every time that you click the button, you will do something.
So it's a really basic principle.
But I mean, this is the base of the whole Qt framework.
So that will be roughly the same in Qt for Python.
And we follow the same idea.
We are not adding new signals or removing old ones.
I mean, it's just keeping the same API.
So that's really nice of it.
Yeah, okay.
So this is a way to basically wire up functions to be called for user interface events.
Mouse over, click, whatever.
Exactly.
The hover, trigger, everything, like check, everything.
So what's the performance look like if I've got a non-trivial C++ application written in Qt,
and then I were to rewrite that in Qt for Python, what would my experience be like?
For general applications, like even big ones, like for example, a browser.
Personally, I haven't performed any like a real test, you know, which are milliseconds, etc.
But I kind of noticed any like lag or delays on having something written in Python.
And the only problem with time that will come will see something only if you are writing Python code that is slow.
So if you start to iterate a list of lists in the wrong way and then are accessing all the time to all the data,
maybe you will of course encounter some bad speedup for your application.
But roughly, for example, there is a couple of browsers are reading as an example inside a Qt code that we had the Python version,
and we couldn't notice like any difference of like executing the C++ and the Python versions,
because they're quite simple.
And there's again fast, because after all, I mean, we are just calling the C++ methods and functions underneath.
That's a really interesting bit there.
I feel like when people talk about performance of Python, a lot of times they say, oh, it's way slower than C or whatever.
But much of the time, if you're doing say like data science stuff, or in the case of Qt,
you're doing a little bit of Python orchestration around objects that are executing in C directly, right?
So like in your web browser example, you might say like if somebody types in the address bar and hits enter,
you want it to drive the web browser widget to go to that address.
But really the only Python code that executes is got a string, tell the C library to go drive the thing to this URL, right?
And so it's only if you're actually doing like lots of computation directly in Python, right?
Yeah, I think most of these statements come from people that really are not really experienced on Python in the sense of like,
they try to rewrite Java or C++ code in the same way.
So you are aware of it that, of course, that if you write, for example, iterations on Python list or list comprehension,
or maybe you have some ways of optimizing your code, you can even reach like the same levels.
And I think that this will just depend on the amount of knowledge that the user can have, right?
Because I mean, of course, if you translate any C++ application with a lot of loops and everything into Python, it would be way slower.
So we need to rethink the algorithms to use Python in a better way.
Yeah, for sure.
And I brought up the import anti-gravity.
You know, so much of what I think would happen if you're coming from one of these other libraries
that doesn't have as many foundational things to use is you just copy the code over
and then you try to execute it on CPython.
But instead of maybe some great big loop, you pip install a thing that has some optimized part of it and you just call that, right?
And that completely changes the story.
So it's pretty interesting.
So you think it's a pretty reasonable thing to do to write acute application, GUI applications in Python.
It's not going to be a complete night and day thing?
Yeah, totally.
I mean, at least that's my personal opinion.
I'm looking forward for having some real cases of people that are doing like really weird things about like populating tables of like 1 million by time, 1 million.
And they have some speed issues.
But I think that we are open to it.
We had a case recently of there was a bug.
There was some person that was populating a table.
I think like 100 times on the table was like a huge.
And of course, I mean, the user brought the bug on it.
But I mean, we didn't understand what was the real use of this.
But we were quite open about it.
And then we decided to start to optimize our code and some C++, even optimizations, for example, going to vectors instead of list and things like this.
So we were quite open about it.
And every time that someone brings some speed issues to the IRC channel, we try to figure it out and try to solve it.
Seems like you're doing a good job.
It sounds great.
All right.
Are you ready for a tough question?
Yes, I am.
All right.
So you said that this is available for open source projects for free or there's a license that I can buy.
So for open source license, for open source, it's under what?
GPL?
LGPL?
LGPL.
So if I write, like, let's suppose I write a database management application, right?
I want to have a new designer and graphical designer for, like, working with databases.
I'm going to write that in Qt for Python.
That would mean my application would have to be open source.
Well, I mean, that's just following the LDPL.
Right.
So, yeah.
But if I don't want that, what do I do?
If I want to sell that product, for example.
That's the thing.
I mean, since, of course, Qt is based on this open source idea, but we're also a company.
We need to have some customers with some, you know, support and everything.
We sell license for commercial use.
So this will allow you to build whatever you want in Qt and sell it as your own product and everything.
So that's one of the things that the Qt for Python project will bring to new customers that with the same license, you will be allowed to build any application using the PySide 2 module and sell it if your business is about it.
So that's one of the nice things.
And, of course, and always, we will keep all the code open source and LGPL related.
So, yeah.
Right.
Okay.
What does that cost me?
I really don't know the prices at the moment, but I can point you to any salesperson.
Yeah, yeah.
No, but it really depends, I think, the size of the amount of licenses that you want to buy.
Do you know how it's apportioned?
Like, is it the number of customers I have?
Is it the number of developers working on the project?
I really don't know about it.
I think that it's based on the developers, but I don't know that well either.
Okay.
But there is a, if I want to build commercial applications, there's a path for that.
And if I want to build open source applications, there's a path for that.
Exactly.
Okay.
Well, that sounds good.
I guess, you know, you've touched on some of these things, but maybe just give you a chance to summarize it or bring anything we haven't mentioned yet.
Where's this going?
So, at the end of the year-ish, we're going to have Qt 5.12 with Qt for Python out and things like that.
Then what?
So, yeah.
I mean, the future that the only restriction that we currently have, the only constraint is that we would like to have more people on board about it.
Because we have a lot of ideas.
And, but we don't have enough time as usual.
So, yeah.
I mean, our number one, I think, task is the Qt creator integration.
So, to have a proper IDE to be compatible with Qt and then to be able to deploy the applications and try to have everything on the same ecosystem, right?
I mean, the designer and then build your UI files into Python files and everything.
So, I think that's one of the high priority.
And this comes, of course, at the hands of all the deployment aspects that we want to cover.
After that, it really will be depending on the users that we have.
I mean, we are really, really open about it.
And every time on IRC, sometimes we ask, what do you think that would be better for the next step?
Personally, I mean, I would like to go into, after the Qt creator and deployment, maybe for embedded system.
Because I have been approached by many people that says, I have this Raspberry Pi, I have an application, and I really want to start to use Qt for Python.
So, please, what do I need to do?
So, there are a lot of people doing this.
And after that, after embedded system, which is one of the strong features of Qt, I think that we should, we can totally go to mobile.
Because I think it is something that people is asking for, and currently with the development of them, it's a smartphone that we get every day and everything.
It's something that would be really nice to combine having your Qt desktop application, but also run on mobile, tablets, and phones, and everything.
I think if you guys can nail the deployment thing, I push a button and I have a macOS.app that I can give to people, that would be a game changer.
Similarly, if you say, I can push a button, and here's the thing I put in the iOS or Android app store, Google Play, also, you know, massively a game changer.
So, I'm excited to hear this, and I wish you good luck on the journey, because we all need it.
Yeah, thank you.
Yeah, pretty cool.
All right, well, I think we've pretty much covered the topic.
I know there's a lot more we could go into, but it's a good introduction for people.
So, Q for Python, I'm super excited that you all are working on it.
Let me ask you the two questions before you get out of here.
If you're going to write some Python code, what editor do you use?
Vim, forever.
I cannot get out of it.
No, no.
Yeah, have you tried?
I mean, I usually recommend for people starting it to use, there is nice, like Eric, for example, this small IDE or Visual Code or PyCharm, for example.
But if you, I mean, I am really used to Vim, so I cannot get out of it in all sense.
So, please, if you know, help me.
No, but it's my ecosystem.
So, I think that's the only thing that I require to do everything.
Yeah, cool.
And then notable PyPI packages, maybe not necessarily the most popular, but one that you've come across, like, oh, people should know about this.
Yeah, well, of course, PySci2.
Of course.
No, but during my studies, I think that all this, the SciPy suite is something that is, it was a must.
I mean, I couldn't do anything without NumPy, MatplotLeave, all these things.
So, I am really trying to follow in all the developments of data science, for example, or the Jupyter notebooks.
I think that those are amazing for the Python community.
And lately, I think that the other day, listening to one of your podcasts, I discovered black for modifying the code, and it was really a game changer.
Yeah, black is cool.
Because it had a couple of files, and it was really, really nice.
So, yeah.
Cool.
Those are definitely good ones.
All right, Christian.
People are excited about Qt for Python.
Final call to action.
What do they do?
So, okay.
So, at the moment, you can go to your terminal and just install PySci2 and start to try all the examples that we have inside.
We are quite active on IRC.
I personally promise you that I will be there at least in working hours or something.
But I try to answer all the questions.
We have a lot of users since we started the first wheel set.
So, if you have any questions, just go on IRC, and we will be there.
And also, it's quite important now that by the end of the year, we have the Qt World Summit, which is the yearly event of Qt.
A lot of people go there, all the clients, all the new users, everything.
And we have two dates.
One is in Boston, the 29th and 30th of October.
Also, we will have the same event in Berlin.
So, I will be giving a talk on Qt for Python, which is called Mastering Qt for Python in 20 minutes.
So, if you really want to go to these events, maybe later you can share the link or something.
I think it is a really nice event to know about Qt for Python and Qt in general.
All right.
Yeah, those are great.
Are you going to be at PyCon 2019?
No, no.
No, I didn't have a chance to go there.
But, yeah, I'm totally planning for next year because since the release was this year, we wanted to go there and try to talk once the product is out, right?
So, I think we will give it a try next year to maybe go to a couple of Pycons in the U.S. if we can.
And EuroPython maybe here in Europe.
Excellent.
Well, I hope to see you there.
And definitely your conference's Qt World Summit sounds interesting as well.
So, thank you so much.
I really appreciate you being on the show and keep up the good work.
I can't wait for that build deploy button.
Thanks to you.
It was really a pleasure to be here.
So, yeah, we are looking forward to it.
Stay tuned.
Great.
Talk to you later.
Thank you very much.
Bye.
This has been another episode of Talk Python To Me.
Our guest on this episode has been Christian Marrera-Fredes.
And it's been brought to you by Linode and Rollbar.
Linode is bulletproof hosting for whatever you're building with Python.
Get four months free at talkpython.fm/linode.
That's L-I-N-O-D-E.
Rollbar takes the pain out of errors.
They give you the context and insight you need to quickly locate and fix errors that might have
gone unnoticed until your users complained, of course.
Track a ridiculous number of errors for free as Talk Python To Me listeners at talkpython.fm/rollbar.
Want to level up your Python?
If you're just getting started, try my Python jumpstart by building 10 apps or our brand new
100 days of code in Python.
And if you're interested in more than one course, be sure to check out the Everything Bundle.
It's like a subscription that never expires.
Be sure to subscribe to the show.
Open your favorite podcatcher and search for Python.
We should be right at the top.
You can also find the iTunes feed at /itunes, Google Play feed at /play, and direct RSS feed at /rss on talkpython.fm.
This is your host, Michael Kennedy.
Thanks so much for listening.
I really appreciate it.
Now get out there and write some Python code.
I really appreciate it.
Thank you.
you
Thank you.