In this episode, Mike Driscoll talks about his latest book, Creating TUI Applications with Textual and Python. Learn about how and why the book came about, what were some pain points in writing the book and how much fun Textual is. You will also learn about some of the current problems in self-publishing tech books. You can purchase Creating TUI Applications with Textual and Python on the following websites: * Amazon (Kindle and Paperback) * Leanpub (eBook) * Gumroad (eBook) Get full access to The Python Show at www.pythonshow.com/subscribe
Audio and video play straight from the show's own hosting. PodSubs stores and serves no media.
Transcript
From the show. Tap a time to play from there.
SPEAKER_00Hello, and welcome to the Python Show with your host, Mike Driscoll. Today, I thought it would be fun to talk about my latest book, Creating TUI Applications with Textual and Python, and just kind of how that book came about and the different challenges that it presented. So I want to say I started working on this book probably back in early 2024, maybe even the very end of 2023. Wilma Googan,
SPEAKER_00the creator of Textual, which is a package used for creating user interfaces in your terminal. He's also the creator of the rich package, which makes coloring your text and doing lots of really fancy things with the output in the terminal. Really cool. Anyway, he contacted me and he was like, hey, this textual project is coming along. I'd like you to write a book about it. And I've had this happen to me a few times before where someone who will just reach out and say, hey, I'd like you to write a book.
SPEAKER_00They approached me, and I'm like, I don't know if I'm interested. But this project looked really cool, and I have a really deep interest in learning user interfaces and creating them with Python. And this one was very unique in that you're creating a user interface in your terminal. So I don't know if you know this or not, but Python comes with its own built-in library called Curses, which also lets you create a terminal application. But the way it's written is really obtuse.
SPEAKER_00The documentation is really sparse in the Python documentation. And the applications that let you create, while they're kind of cool, the few that I've actually seen, they look very much like they're from the 80s or maybe even the 70s. They're kind of like a mainframe DOS type look, which you might have seen in like old TV shows or something where someone's like filling out a form on a black screen or a green screen. That's kind of what you do with curses, at least from what I've seen of it.
SPEAKER_00And I could never figure it out myself. I didn't spend a lot of time on it, but because the documentation was so bad, I just wasn't very interested. So when Will came to me, I was like, this looks like a really cool project. And I agreed that I would put it on my backlog because at that time, I was actually writing a different book. But I did research it and I started planning out different applications. And then I realized there were a couple of key widgets missing. One of them in my mind was kind of key was that there wasn't a multi-line text widget.
And I had a couple of different ideas where a multi-line text widget would be needed to really make it look the way I wanted the app to look and behave.
SPEAKER_00And so I was like, well, If I can't create the apps that I want to create, and I'll just kind of have to shoehorn things together to kind of make compelling apps, at least in my opinion, I'm just going to shelve this and wait to see. Because Will and his team had put together a roadmap that showed they were going to create the widgets that I wanted. So anyway, all that is to say, this was going on and I started watching it. And about, I want to say March of 2024,
I noticed that they'd added the widgets that I wanted and I could actually start
SPEAKER_00working on this. And that was really cool. And so that's when I started working on it like a lot. I started putting together good application ideas. I decided what I wanted to cover because I knew that this book, because it was going to be the first book on the textual library, that I would also need to include probably at least 30% to 50% of the book or just be like introductory material to what textual is. You know, how do you create widgets? How do you lay them out? How do you do all the different things? How do you debug your program?
All those kinds of things need to be in the book as well as how to create applications.
SPEAKER_00So that's what this book ended up being. It ended up being a part one of covering all the basic stuff that you need to know to make a textural app work. And then part two is 10 applications that I thought would be kind of fun. And I purposely made those 10 applications really, really minimal. and offered a lot of ideas throughout the chapter as well as at the end of each chapter of how you could enhance the application that you had made. And to me, I thought that was really cool because you're getting a working
application. It may not do a lot, but it's a really good stepping stone to a fully-fledged need application.
SPEAKER_00And a lot of these, I think, are usable even in their minimal state. So I just thought I'd talk a little bit about that. So when I started working on this, this was actually one of my longest projects. writing projects I've done in a long time, because this one took me about a year, a little over a year to fully put together. I started March 2024, like I mentioned, like full-time working on it. Well, not full-time, but full-time for me for when it comes to book writing. And full-time for me means like, you know, like an hour or two a day. So I started working on this and just trying to get it all
pieced together.
SPEAKER_00In the book, you'll learn how to create a basic calculator, a CSV viewer, a text editor, an MP3 player, ID3 editor. And ID3 is basically the metadata behind an MP3, so you can edit the MP3 files in your MP3 player if you wanted to. I also created a weather application. I decided to wrap pre-commit with the TUI. I created an RSS reader. And there's also a SQLite viewer slash editor of sorts that I created.
SPEAKER_00That's the last project in the book. And it took me more than a month to get that working the way I wanted it to. Most of these apps, you know, it took me a week or two apiece to get them working the way I wanted, but that That database one took a lot longer, and I'll talk about that later. But let's just talk a little bit about how this all came about. So we got the book, figured out. I figured out exactly what I wanted in it. And then as I'm going along working on this and watching as
Textual keeps getting
SPEAKER_00more and more new updates as I'm writing the book, I'm like, shoot, I'm going to have to add more content in these different areas. Or in some cases, I'd have to actually add a brand new chapter because they'd add a new feature that really should be in the book. For example, they added a new kind of markup for working with the colors and doing click events that hadn't been in there. And I was almost done with the book at that point. But they released it about three months before I was ready for release. And I'm like, I'm going to have to add that in there too.
SPEAKER_00And so I rearranged the chapters and added that particular part in. And then, of course, when they released 1.0 of textual content, I think it was actually maybe 2.0, because right after they did 1.0, they broke some things with the 2.0 release, and I had to fix some more code because of that. But in general, it's been pretty smooth, even though they've been releasing constantly. It feels like, well, I've been writing the book. Most of my code examples continue to work. They've only broken a couple of little minor things.
SPEAKER_00There's like a widgets. It's kind of like a combo box where you can add separators. And they broke that at one point. And I had to change a couple of examples. But in general, it's worked out really, really well. But anyway, so the thing I really enjoyed about textural is that it's very Pythonic. It's really well thought out and it's really well documented. Unlike like WX Python and TK Enter or TK Enter,
SPEAKER_00Those things are wrapped around C or C++ libraries, or in the case of TCenter, it's wrapped around a TCL language, TCL. So those have a very different way of writing their programs because they come from those other languages. And they don't really feel like you're writing like a regular Python program. Textual is different because it is actually written from the ground up, you know, with Python developers in mind.
SPEAKER_00Really, the only thing that makes it a lot different than working with those other libraries, though, is that it uses async.io under the covers. And you can write async code yourself if you really, really want to. And in some cases, you have to actually write some async code, depending on what you're doing in the library. For the most part, most of my apps don't need to do that. But there are some weird edge cases where you will need to write some await statements because the UI needs to await to update.
SPEAKER_00Anyway, I just think it's just been a really pleasurable experience. But let's talk about some of the things that are hard when it comes to writing a book. especially a book about a library that is rapidly changing. So, I mean, one of the key challenges is it is rapidly changing. And you're not sure what's going to happen there. I was assured by the textual team that they would avoid most backwards breaking changes. They didn't want to do that. And they usually warned you up front if they're going to break something.
SPEAKER_00So in that respect, most of the code doesn't get broken, even when they have a major version change. It's usually like really minor things that get busted. And in my case, the things that have gotten broken, besides the one weird case with the combo box type problem, the things that got broken didn't affect me because I wasn't using those widgets in those ways, or I wasn't using those widgets at all, or whatever that feature was at all in the book. So in some ways, I was lucky. And in other ways, I just don't use some of the esoteric functions.
SPEAKER_00Another big challenge for me was Sometimes when you're working on an app idea or just a code example, the code example doesn't work the way you want it to. And so you sit there and you iterate on it over and over again. So a good example of that is the database viewer When I first created it, I did a ton of Googling. I wrote all kinds of different ideas. I used Google's Gemini tool a little bit, and I used Stack Overflow a lot,
SPEAKER_00trying to find out ways to basically reflect the SQLite database. How do you get all the table names? How do you get the metadata out of the table? Things like that. And eventually, I realized I was trying to create, I was basically trying to reinvent the wheel. Some of the users on the textual Discord channel actually said, hey, why aren't you using SQL Alchemy for this? And I have used SQL Alchemy a lot. And I was trying to avoid it just because I didn't want another
dependency.
SPEAKER_00But I was like, you know, maybe I should just check this out. And once I did and I updated to the latest SQL Alchemy, I realized, you know what? This makes the code so much cleaner. I don't have to reinvent the wheel. And I was finally able to get past that. But I'd spent weeks trying to solve these different issues with different databases because I was trying to reinvent the wheel. So just let that be a lesson to you that you really don't need to do that. It's a pain in the butt. Go ahead and look for the solution. See if it's already out there and just take it and hopefully it'll work.
SPEAKER_00And if it doesn't, maybe you can contribute back and make it work in the way you want it to work. Yeah, just don't do what I did. Basically, this is what I'm saying. Some of the other ideas I had. It didn't work out quite the way I wanted. I had a neat idea about wrapping the GitHub desktop tool, or no, I guess GitHub CLI. I thought that'd be fun, but it quickly became a bear to wrap all the functionality that I wanted, and so I dropped that from the book, for example.
SPEAKER_00Instead, I did 2e on the pre-commit, which was much easier because pre-commit doesn't have as many command line options that I had to implement in the TUI, which is really nice. And by TUI, I mean text-based user interface. One of the funny things about a text-based user interface is a lot of people think it's just text on the screen. And I mean, it is, but it doesn't look like text. They're using a lot of Unicode and just text characters to create buttons and tables and combo boxes and all these other different widgets.
But they behave like those widgets that you normally see in like a regular GUI. And it's just kind of fun to see how they've implemented that with Textual.
SPEAKER_00Anyway, another issue, and one that was actually pretty bothersome, was that I had decided to do two different types of physical books. I wanted to do a paperback, and I wanted to try doing a hardcover because I thought this book would be worth it. And for the hardcover, I wanted to do some color images because I'd heard recently that Amazon had made it cheaper to do color. And so I was like, we'll give it a try and we'll give it kind of a premium book feel for those who
SPEAKER_00want to get it. The problem is that paperbacks and hardcover books have slightly different page sizes. And I didn't account for that. And so there's slightly different wrapping issues based on those sizes for where code will wrap on the hardcover where it won't wrap on the paperback because the hardcover is just slightly smaller than the paperback sizes. And that was a little bit of a headache.
Another problem I ran into is that because the hardcover is slightly different
SPEAKER_00size, the cover image I had no longer would fit on the hardcover. So I had to have some custom work done just to make the hardcover possible. And the third issue I found out is that the people I used to generate the PDF For the book, originally, a couple of years ago, when you create a PDF, you could generate it in full color with syntax highlighting in all your code examples and everything. And it looked great. And the PDF still has all of that, like the PDF version.
SPEAKER_00But when you create the special print version of the PDF, they stripped all the color out of the syntax highlighting stuff. And so all that doesn't appear in the color version of the book, which in my opinion kind of ruins a lot of what I think is the appeal of having the color book. I wanted the syntax highlighting. I didn't realize they'd stripped it. I do have color screenshots, and those definitely look better in color. You can definitely see a lot more the dynamism of the library of textual,
SPEAKER_00but you don't see the syntax highlighting, which I find really, really annoying. The other problem that I realized is that the color that Amazon provides for hardcover is different than the color options for paperback. And so the hardcover actually is pretty useless to me from a financial point of view. To make any money on a hardcover book of this size, which is about 350 to 380 pages,
SPEAKER_00you'd have to price the book Probably around $90 to $100 to make like $20 of profit, maybe. Currently, I have it priced at $72 on Amazon's website. And at $72, my royalty rate in the U.S. is $0.05. So I get a nickel for anyone who bought the hardcover version, which basically means that that hardcover version doesn't make any sense for me. So I'm probably just going to use that for promotional purposes.
SPEAKER_00My print cost is not $72, but that's how much money it costs to print and distribute for Amazon and still give me some kind of profit, even if it's crap. So I probably won't leave the hardcover version on Amazon's website for a long time. I'll just use it for like a promo offer or kind of like a reward for people. who really, really want it. But then I'll probably just drop it after a few more weeks, maybe a month or two, because it really doesn't make sense for me to leave it on
there since it doesn't
SPEAKER_00fulfill anything for me financially. And personally, I think $72 is a lot of money for our a book that may become obsolete in a couple of years. I'm going to try to make sure it doesn't, but that's still a lot of money for a book, and I just don't think it's worth it, especially since I plan to continue updating the PDF if anything breaks. So, you know, those are kind of the problems. Other things I've noticed that people have said about the book
is that they think
SPEAKER_00that I should have more of a business cover instead of following my usual I like creating covers with fanciful characters on it, usually mice and python, sometimes other things. I think that makes them stand out in the crowd. But it doesn't seem to really work anymore. A lot of people don't buy the books. And I don't know if it's because of that. That kind of fantasy cover or because they look whimsical and childlike or people just don't like that kind of thing.
They just want that boring cover that Pact and O'Reilly and no starch uses.
SPEAKER_00But I'm kind of like, I don't really understand that because... You know, you look at Nostarch, a lot of those are pretty fanciful and kind of fun sketches. Usually you have python on it or some other creature. If you do like rust, it's like a crab. And, you know, O'Reilly is always using sketches. And they're usually detailed sketches, but they're animal sketches. They're just not cartoony. And nobody complains about those as far as I know. But for some reason, people just don't like my covers.
SPEAKER_00They think they're too childlike or something. I personally like them. I still like them. But I am curious, you know, if I changed to a more business format like what Pact and A-Press does, would I sell more volume? I don't know. That's something I might try in the future just as an experiment to see, you know, does this affect anything? Does this make the book sell better? Do people really care about what the cover looks like, as I suspect that they might at this point? Or is it just AI that steals all the sales now?
Which brings us up to kind of the tough thing about book writing right now is that,
SPEAKER_00you know, when I Google for questions or Google for answers, I should say, you know, Gemini or Bing or, you know, ChatGPT or whatever, Claude, they all can answer a lot of my questions. They can't always answer everything that I want to do. Like Textual, they're usually trained to use a really old version of Textual, which isn't up to date. So they don't get the greatest answers. And I was hoping that would help a lot with this particular book, but it really hasn't.
SPEAKER_00Sales have been mediocre ever since I launched a couple of weeks ago. And that's why I bring up the whole AI thing. I think the AI thing is killing a lot of technical book sales because when you go do a Google search or a Bing search, Bing and Google will return the answer with their AI tools and then include also links to a lot of other answers. And because AI answers those questions, a lot of people aren't reading the books. Even though the books are better organized and will teach you
from beginning to
SPEAKER_00end, whereas the AI will only teach you that specific problem solution, sometimes in a good way, mostly in a broken way, A lot of people are relying on the AI solution and chatting with the AI and trying to get them to tell them how to do it. Which is a little disheartening because it makes writing these books, even though they're a joy to write and a lot of fun in my mind intellectually, it makes them very unprofitable. So I'm going to be experimenting some more.
So this is kind of like a segue into what's going off my next writing projects is
SPEAKER_00I'm going to experiment, you know, maybe writing a little bit about AI or AI related topics. Maybe I'll try some of these more boring cover ideas and see if that makes those sell better. I don't know. If this whole tech book thing doesn't work that well, I'm going to have to look at other because people just don't seem to be as interested in that as they used to be. But I am curious, you know, if you're the kind of person who still reads books or wants to
take tech courses,
SPEAKER_00you know, what kinds of things are you interested in? What would you use or want to learn without using AI, you know, like ChatGPT or Cloud or whatever? I hope you'll comment and just let me know. I'm really curious, how do I create content that engages you to the point that you actually spend money to buy it, like a tech course? A lot of people will buy computer vision classes or deep learning classes.
I would assume that can't be just the only two topics that are available anymore.
SPEAKER_00There's got to be other topics. And if you're one of those people who goes, like, let me know what you think, that'd be great. Anyway, you know, that's just kind of out there. But... So right now, my latest book, Creating Two Applications with Textual and Python, is out now. You can buy it on LeanPub, Amazon, and Gumroad. Amazon, of course, has the Kindle version and the paperback and the hardcover right now. And LeanPub and Gumroad have a PDF and a Mobi version without any DRM.
SPEAKER_00I, of course, would make the most money off of LeanPub and Gumroad because they have much higher royalty rates than Amazon does. So those are the ones I personally prefer. But Amazon is really handy because it puts it on your Kindle, which may or may not look the greatest. I've noticed that Kindle doesn't always convert the files as nicely as I'd like it to. So in my opinion, the best reading experience is the PDF, possibly the Mobi. The paperback is probably the best version if you like the
hardcover because I do
SPEAKER_00almost all my paperbacks in letter size, which is eight and a half by 11 inches. I just find that that size is really nice for reading purposes and the code examples are nice and big. The only exception to that is my Python login book, which is a much smaller book. I tried that as an experiment, and people really liked it, but the book size is very different than my other books. Anyway, I feel like I'm rambling now, so I'm going to wrap up.
If you want to check out that book and let me know what you think, that'd be great.
SPEAKER_00If you like listening to me jabber about book writing, please let me know, because I can talk about the current projects I'm working on. That'd be kind of fun. Or if you have other projects you'd like me to talk about, I'm happy to chat about those too. And I'm also thinking for this show, since I haven't been doing a lot, I've been having trouble getting guests lately, and I've been experiencing a little bit of burnout. I think what I'm going to do, or at least for the next few weeks,
SPEAKER_00maybe a month or two, is just kind of do a newsy episode where I'll talk about what's currently going on in the Python ecosystem. What are some new packages? What are some new features that are coming down the pike? I think that'll be really interesting, and hopefully you all will tune in and listen to me talk about those things too. Anyway, thanks so much for listening to me, and I hope to hear from you soon.
In this episode of the Python Show Podcast, I am pleased to have Tim Hopper as my guest. Tim is the author of the Python Developer Tooling Handbook, a free online resource for everyone. We chat about Python tooling,...
In this episode, we hear from two sisters who put together a beginner's book about Python. The unique hook for their book is that one sister wrote the text while the other did the illustrations. Listen in as we learn...
In this episode, we have special guest Paul Everitt on the show to talk about the new Python Documentary that came our last week. Paul is the head of developer advocacy at JetBrains and a “Python oldster”. We chat about...
In this episode, we have the honor of having Nicolas Rougier on our show. Nicolas is a researcher and team leader at the Institute of Neurodegenerative Diseases (Bordeaux, France). We discuss how Nicolas utilizes...
In today’s podcast, we welcome Daniel Voigt Godoy to the show. Daniel is the author of Deep Learning with PyTorch Step-by-Step among other books. We chatted about the following topics: * Favorite Python packages *...