O'Reilly logo

WxPython Application Development Cookbook by Cody Precord

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing a data source

For most usages of the grid control, your application must define a custom data source to provide the data on demand when the grid requests to display it. The use of a data source allows virtualizing data storage to prevent duplicating the storage of data in both the control and the backing data field. In this recipe, we will take a look at how to create a custom PyGridTableBase to use as a data source for grid.

How to do it…

Perform the following steps:

  1. First, in this recipe, we will retrieve backing data from the GitHub API, so we need to import a few extra modules from the Python standard library. We will do this as follows:
    import urllib
    import json
    import wx
    import wx.grid as gridlib
  2. Let's start by defining the custom ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required