All posts by Mike

PyDev of the Week: Lorena Mesa

This week we welcome Lorena Mesa (@loooorenanicole) as our PyDev of the Week! Lorena is an organizer for the PyLadies Chicago group and a director at the Python Software Foundation. You can check out some of the things that she is up to on her blog or via her Github page. Let’s spend a few moments getting to know her better!

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

Hmmm … I have been told that I’m a bit eclectic. So let’s start with the basics, in my day to day gig I am a proud member of GitHub’s software intelligence systems team as a data engineer. In my etc hours I do such things as co-organize PyLadies Chicago and serve as a Director for the Python Software Foundation.

Things I do for fun?

  • I’m an avid runner having taken on the Chicago Marathon 13 times now. Why? I encourage you to read Haruki Murakami’s “What I talk about when I talk about running” before you ask me that.
  • Jazz, italo disco, and loud 1980s ballads are equal parts guilty pleasure for me. Meaning of course I’ve been learning the sax and getting pretty good at it lately. (Yes, I can play Careless Whispers).
  • I’m learning Klingon – https://www.kli.org/.

You can find my random musings when I post on my personal blog at lorenamesa.com on such things as traveling, tech, and other tidbits.

Continue reading PyDev of the Week: Lorena Mesa

Sample Chapters from Creating wxPython Applications Book

The Kickstarter campaign for my latest book has been going quite well, so I thought it would be fun to share some sample chapters of the book with you. You can check out the first couple of chapters here as a PDF.

I have also been doing some experiments with regards to some of the ideas that were given about other chapters for the book for the stretch goals of the Kickstarter. I haven’t made any concrete decisions as of yet, but I do think that interacting with the NASA website’s API sounds fun and appears easy to do as well.

I will research the feasibility of the other ideas too.

Thanks so much for your support!

PyDev of the Week: Nina Zakharenko

This week we welcome Nina Zakharenko (@nnja) as our PyDev of the Week! Nina has been active in the Python community for several years and has spoken or keynoted dozens of conferences. She has also contributed to the Python core language! If you’d like to see what she is up to, check out her blog. Let’s spend a few moments getting to know Nina!

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

I’m embarrassed to admit it, but the mid-90s cyberpunk movie Hackers – about a group of hackers framed for deploying a world-threatening computer virus – inspired me to become a programmer at a very young age. Even more embarrassing – I owned a pair of rollerblades growing up. When I was 12, I learned HTML to make websites by reading and deconstructing the source code of sites I visited, and I slowly became more engrossed in technology. As an adult, I studied Computer Science in college, and since then I’ve held a variety of exciting jobs at companies like HBO writing software for satellite control computers, to working for companies like Meetup and at Reddit. This spring, I joined the incredible Cloud Developer Advocacy team at Microsoft as the first Advocate entirely devoted to Python. I love teaching and public speaking. In my spare time I like to snowboard, hike, travel, and tinker with microcontrollers and wearable electronics, such as these Python powered earrings. I tweet at @nnja and occasionally blog and post my talks at nnja.io. Continue reading PyDev of the Week: Nina Zakharenko

Creating GUI Applications with wxPython Kickstarter

I am pleased to announce my latest book project, Creating GUI Applications with wxPython which I am running a Kickstarter campaign for.

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.

The code in this book will be targeted for Python 3 only using wxPython 4.

Creating GUI Applications with wxPython cover

For more information, please check out the Kickstarter.

PyDev of the Week: Lance Bragstad

This week we welcome Lance Bragstad (@LanceBragstad) as our PyDev of the Week! Lance is a core developer of the OpenStack project. You can find out more about his passions via his website or his Github profile. Let’s spend some time getting to know Lance!

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

In 2012, I graduated with a degree in Computer Science from North Dakota State University, located in Fargo (yup, like the movie). Since then I’ve become more and more passionate about open-source software. I spend most of my time in the OpenStack ecosystem.

Besides being passionate about open-source software, I’m an avid outdoorsman. My wife and I train for running events together. I also donate time as a volunteer firefighter for our community of about 700 people. Continue reading PyDev of the Week: Lance Bragstad

PyDev of the Week: Kushal Das

This week we welcome Kushal Das (@kushaldas) as our PyDev of the Week! Kushal is a core developer of the Python programming language and a co-author of PEP 582. You can learn more about Kushal by checking out his blog or his Github profile. Let’s take a few moments to get to know Kushal better!

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

I am a staff member of Freedom of the Press Foundation. We are a non-profit that protects, defends, and empowers public-interest journalism in the 21st century. We work on encryption tools for journalists and whistleblowers, documentation of attacks on the press, training newsrooms on digital security practices, and advocating for the the public’s right to know.

I am also part of various Free Software projects through out my life. I am a core developer of CPython, and a director of the Python Software Foundation. I am part of the core team of the Tor project. I am a regular contributor to Fedora Project for over a decade now.

I co-ordinate https://dgplug.org along with a large group of friends and fellow contributors in various projects. We spend time together in learning new things and helping out each other on the #dgplug IRC channel on Freenode server. Feel free to visit the channel and say “Hi” to us.

I try to write about the things I learn regularly on my blog. Continue reading PyDev of the Week: Kushal Das

wxPython: Changing Custom Renderers for Columns / Rows

The wxPython GUI toolkit has a very rich and powerful Grid widget that I have written about previously on this blog. It allows you to create sheets of cells similar to those in Microsoft Excel.

There is also a neat mixin that allows you to apply a custom renderer to the labels on the columns and rows of the grid.

Let’s take a look at that and see how it works:

import wx
import wx.grid as grid
import wx.lib.mixins.gridlabelrenderer as glr
 
class MyGrid(grid.Grid, glr.GridWithLabelRenderersMixin):
 
    def __init__(self, *args, **kw):
        grid.Grid.__init__(self, *args, **kw)
        glr.GridWithLabelRenderersMixin.__init__(self)
 
class MyColLabelRenderer(glr.GridLabelRenderer):
 
    def __init__(self, bgcolor):
        self._bgcolor = bgcolor
 
    def Draw(self, grid, dc, rect, col):
        dc.SetBrush(wx.Brush(self._bgcolor))
        dc.SetPen(wx.TRANSPARENT_PEN)
        dc.DrawRectangle(rect)
        hAlign, vAlign = grid.GetColLabelAlignment()
        text = grid.GetColLabelValue(col)
        self.DrawBorder(grid, dc, rect)
        self.DrawText(grid, dc, rect, text, hAlign, vAlign)
 
class MyPanel(wx.Panel):
 
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
 
        grid = MyGrid(self, size=(100, 100))
        grid.CreateGrid(numRows=10, numCols=10)
 
        for col in range(0, 10, 3):
            grid.SetColLabelRenderer(
                col+0, MyColLabelRenderer('#e0ffe0'))
            grid.SetColLabelRenderer(
                col+1, MyColLabelRenderer('#e0e0ff'))
            grid.SetColLabelRenderer(
                col+2, MyColLabelRenderer('#ffe0e0'))
 
        main_sizer = wx.BoxSizer(wx.VERTICAL)
        main_sizer.Add(grid, 1, wx.EXPAND)
        self.SetSizer(main_sizer)
 
class MyFrame(wx.Frame):
 
    def __init__(self):
        wx.Frame.__init__(self, None, title='Custom Grid Renderers')
        panel = MyPanel(self)
        self.Show()
 
if __name__ == '__main__':
    app = wx.App(False)
    frame = MyFrame()
    app.MainLoop()

Let’s break this down a bit. You will notice at the top of the code that we need to import the Grid widget separately in wxPython. We also need to import a mixin called GridWithLabelRenderersMixin. We subclass the Grid class and add in the mixin and then initialize both.

Next we create a subclass of GridLabelRenderer, which is also from the mixin. This allows us to create a spacing Draw method that will give us the ability to apply different colors or fonts to the labels in our Grid. In this case, I just made it so that we could change the color of the text in the labels.

The last piece of code that we are interested in is in the MyPanel class where we actually instantiate the Grid and change the color of the background of the labels in the columns. Here is what the grid ended up looking like:

wxPython Grid widget with colored columns
Custom Grid Column Renderers

Wrapping up

The wxPython toolkit has dozens of pre-built widgets that you can use to create cross-platform user interfaces. The wxPython demo has a much more involved example than this article does that you might also find interesting. If you haven’t given wxPython a try, you really should go get it. It is pip installable from PyPI and compatible with Python 3.