PyUI Sheets

  1. Introduction
  2. Example
  3. The Boat Classes


Introduction

The Sheet class is a flexible, generalized table widget for spreadsheet-like applications. It is made up of rows and columns with headings on each and can be scrolled in all directions. Cells in the sheet can hold values that are displayed as text and these values can be edited in place.

The Sheet class does not use PyUI widgets for each of the cells inside of it. This makes it much faster than a generalized table class but restricts what can be displayed to just text-like values.

Columns and Rows can be set to be readonly by calling setColumnReadOnly and setRowReadOnly.

Example

This example shows a Sheet widget in a frame and examples the two callback methods that the Sheet will invoke when users interact with it. When the user enters a value in an empty cell, the insertHandler method will be called with the x and y positions of the cell and the value entered. When the user changes the value in an occupied cell, the changeHandler will be called with the same arguments.

import pyui

def onChanged(x, y, value):
    print "Cell (%d,%d) Set to <%s>" % ( x, y, value)

def onInserted(x, y, value):
    print "Cell inserted (%d,%d) Set to <%s>" % ( x, y, value)
    
pyui.init(800,600,"p3d")
w = pyui.widgets.Frame(50, 50, 400, 400, "spreadsheet")
w.setLayout(pyui.layouts.GridLayoutManager(1,1,0))
b = pyui.sheet.Sheet(changeHandler = onChanged, insertHandler = onInserted)
b.setColumnTitle(3,"A very Long one")
b.setColumnTitle(2,"Table name")
b.setColumnTitle(1,"Something goes here....")
w.addChild(b)
w.pack()

pyui.run()
pyui.quit()

After entering some text, this should look something like:

The Boat Classes

The Boat Classes are a set of classes for interacting with Twisted Enterprise Row objects. Twisted is a network/server framework written in python that includes a database access module called Twisted Enterprise.

The Boat classes are:

There is an example "boatTest.py" in the pyui/tests directory that shows using PyUI and Twisted in the same application. Both libraries have update/iterate methods that must be called and have cleanup that must be done to exit correctly.


(C) Sean Riley 2002