An Intro to StaticBox and StaticBoxSizers

There are many widgets that are included with the wxPython GUI toolkit. One of them is a fairly handy widget called wx.StaticBox. This widget accepts a string and then will draw a box with the string in the upper left-hand corned of the box. However this only works when you use it in conjunction with wx.StaticBoxSizer.

Here is an example of what one might look like:

Simple wx.StaticBox

Now let’s go ahead and write the code you would use to create the example above: Continue reading An Intro to StaticBox and StaticBoxSizers

Creating GUI Applications with wxPython Now Available

My latest book, Creating GUI Applications with wxPython is now available for purchase.

Cover art for Creating GUI Applications with wxPython

Creating GUI Applications with wxPython is a book that will teach you how to use wxPython to create applications by actually creating several mini-programs. I have found that while learning how the various widgets work in wxPython is valuable, it is even better to learn by creating a simple application that does something useful.

In this book, you will be creating the following applications:

  • A simple image viewer
  • A database viewer
  • A database editor
  • Calculator
  • An Archiving application (tar)
  • PDF Merging application
  • XML Editor
  • File search utility
  • Simple FTP application
  • NASA Image downloader

As you learn how to create these applications, you will also learn how wxPython works. You will go over how wxPython’s event system works, how to use threads in wxPython, make use of sizers and much, much more!

The eBook version is on sale on Leanpub for $14.99 until May 15th. You can also purchase the book on Gumroad, or get the paperback or Kindle version on Amazon.

PyDev of the Week: Joel Grus

This week we welcome Joel Grus (@joelgrus) as our PyDev of the Week! Joel is the author of Data Science From Scratch: First Principles with Python from O’Reilly. You can catch up with Joel on his website or on Github. Let’s take some time to get to know Joel better!

Can you tell us a little about yourself (hobbies, education, etc):

In school I studied math and economics. I started my career doing quantitative finance (options pricing, financial risk, and stuff like that). I got very, very good at Excel, and I learned a tiny amount of SQL. But I kind of hated working in finance (and also I got laid off), so I joined an online travel startup as a “data analyst” doing BI stuff (lots of spreadsheets, lots of SQL, some very light scripting). That startup got acquired by Microsoft, who at the time had basically no idea what to do with my more-than-a-financial-analyst-less-than-a-software-engineer skillset. (Nor did I, really.)

Then in 2011 I saw that the winds were blowing toward “data science”, so I sort of BS-ed my way into a data scientist job at a tiny startup. I took a bunch of Coursera courses to fill in gaps in my knowledge, and then I learned to write (ugly) production code and discovered I really enjoyed building software. Through doing well in coding competitions I had the opportunity to interview for a software engineer job at Google, so I spent 6 really hectic weeks cramming computer science and then somehow passed the interview. I spent a couple of years at Google, and then I found I missed doing data and ML stuff, and so now I’m at the Allen Institute for Artificial Intelligence, where I build deep learning tools for NLP researchers. My current job is right at the intersection of deep learning and Python library design, which is a pretty great match for my interests.

I don’t really have time for hobbies 😢. I have an 8-year-old daughter, and I spend a lot of my free time with her, and then I keep agreeing and/or volunteering to write things and give talks and make livecoding videos, which takes up most of the rest. And then I have a podcast and a Twitter to stay on top of. I have long-term hobby goals of (1) learning jazz piano and (2) writing a novel, but I’m not really making much progress on either. Continue reading PyDev of the Week: Joel Grus

Books on Sale for PyCon 2019

In honor of PyCon 2019 that is starting this week, I am putting three of my books on sale. You can get any of the following books for $9.99 through May 6th by clicking on the links:

Python 201 is a fun book for those of you who would be interested in learning intermediate and advanced topics in Python.

My ReportLab book covers how to create PDFs using Python and ReportLab. It also covers many other topics related to PDFs, such as splitting, merging and overlaying PDFs to name a few.

Finally my Jupyter Notebook 101 book is a good way for you to learn about the Jupyter Notebook and many of its capabilities.

PyDev of the Week: Neil Muller

This week we welcome Neil Muller as our PyDev of the Week! Neil is an organizer for Cape Town Python User Group and PyCon ZA. He also speaks at conferences! You can learn more about his open source projects over on Github. Let’s take a few moments to get to know Neil better!

Can you tell us a little about yourself (hobbies, education, etc):

I’m an Applied Mathematician with interests in image processing and numerical computation, currently living and working in the Cape Town area, South Africa. I followed an interest in facial recognition into a PhD from the University of Stellenbosch, and that led to working on a variety of image processing and numerical modelling problems at iThemba LABS.

These days I split my working time between iThemba LABS and Praelexis, a machine learning company (mainly using Python) in Stellenbosch.

In my spare time, I am obsessed with board and card games, especially Vampire: The Eternal Struggle. Continue reading PyDev of the Week: Neil Muller

PyDev of the Week: Dane Hillard

This week we welcome Dane Hillard (@easyaspython) as our PyDev of the Week! Dane is the author Practices of the Python Pro, an upcoming book from Manning. He is also a blogger and web developer. Let’s take some time to get to know Dane!

Can you tell us a little about yourself (hobbies, education, etc):

I’m a creative type, so many of my interests are in art and music. I’ve been a competitive ballroom dancer, and I’m a published musician and photographer. I’m proud of those accomplishments, but I’m driven to do most of this stuff for personal fulfillment more than anything! I enjoy sharing and discussing what I learn with others, too. When I have some time my next project is to start exploring foodways, which is this idea of exploring food and its cultural impact through written history. I’ve loved cooking (and food in general) for a long time and I want to get to know its origins better, which I think is something this generation is demanding more from industries as a whole. Should be fun! Continue reading PyDev of the Week: Dane Hillard

Mozilla Announces Pyodide – Python in the Browser

Mozilla announced a new project called Pyodide earlier this week. The aim of Pyodide is to bring Python’s scientific stack into the browser.

The Pyodide project will give you a full, standard Python interpreter that runs in your browser and also give you access to the browsers Web APIs. Currently, Pyodide does not support threading or networking sockets. Python is also quite a bit slower to run in the browser, although it is usable for interactive exploration.

The article mentions other projects, such as Brython and Skulpt. These projects are rewrites of Python’s interpreter in Javascript. Their disadvantage to Pyodide is that they cannot use Python extensions that were written in C, such as Numpy or Pandas. Pyodide overcomes this issue.

Anyway, this sounds like a really interesting project. I always thought the demos I used to see of Python running in Silverlight in the browser were cool. That project is basically dead at this point, but Pyodide sounds like a really interesting new hack at getting Python into the browser. Hopefully it will go somewhere.

Creating a GUI Application for NASA’s API with wxPython

Growing up, I have always found the universe and space in general to be exciting. It is fun to dream about what worlds remain unexplored. I also enjoy seeing photos from other worlds or thinking about the vastness of space. What does this have to do with Python though? Well, the National Aeronautics and Space Administration (NASA) has a web API that allows you to search their image library.

You can read all about it on their website.

The NASA website recommends getting an Application Programming Interface (API) key. If you go to that website, the form that you will fill out is nice and short.

Technically, you do not need an API key to make requests against NASA’s services. However they do have rate limiting in place for developers who access their site without an API key. Even with a key, you are limited to a default of 1000 requests per hour. If you go over your allocation, you will be temporarily blocked from making requests. You can contact NASA to request a higher rate limit though.

Interestingly, the documentation doesn’t really say how many requests you can make without an API key.

The API documentation disagrees with NASA’s Image API documentation about which endpoints to hit, which makes working with their website a bit confusing.

For example, you will see the API documentation talking about this URL:

  • https://api.nasa.gov/planetary/apod?api_key=API_KEY_GOES_HERE

But in the Image API documentation, the API root is:

  • https://images-api.nasa.gov

For the purposes of this tutorial, you will be using the latter. Continue reading Creating a GUI Application for NASA’s API with wxPython

PyDev of the Week: Pierre Denis

This week we welcome Pierre Denis as our PyDev of the Week! Pierre is the creator of Lea, a probabilistic programming package in Python. He can be found on LinkedIn where you can see his CV and learn more about some of the things he is up to. Let’s take a few moments to get to know Pierre better!

Can you tell us a little about yourself (hobbies, education, etc):

I’ve a Master in Computer Science from UCL Louvain-la-Neuve, Belgium, where I reside. I’m working since 20 years as software engineer in [Spacebel](http://www.spacebel.be), a company developing systems for Space. Basically, I like everything creative and elegant. Beside arts, music, literature, I ‘m looking for this in physics, algorithmic, GUI and mathematics. I love programming, especially in Python. So far, I have initiated three open-source Python projects: UFOPAX (textual virtual universe), Unum (quantities with unit consistency) and Lea (probabilistic programming). For these developments, I tend to be perfectionist and consequently slow: I’m the kind of guy that re-write the same program ten times, just for the sake of inner beauty!

Beside programming, I’m doing research in number theory (twin primes conjecture). Also, I’m writing short stories in French, my mother tongue, with some reference to the ‘Pataphysics of Alfred Jarry and a lot of nonsense. Incidentally and fortunately, programs can be good for producing nonsense, as I showed in my bullshit generator! Continue reading PyDev of the Week: Pierre Denis

Python Used to Take Photo of Black Hole

Scientists have used a new algorithm to take a photo of a black hole. One of the most exciting parts about it to me is that they used a lot of Python libraries to do the magic.

Here’s a list mentioned in their paper:

They also used their own custom Python code which is available on Github

If you’re interested in a more laymen’s explanation of the ideas behind taking the photo, there’s a nice TED talk on it from one of the researchers:


Related Links