Exercise

Create a dialog-style application for adding, editing, and deleting records in a reference table, like the one shown in Figure 15.7. The application should create the reference.db database the first time it is run, with a single, empty table:

CREATE TABLE reference (

id INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE NOT NULL, category VARCHAR(30) NOT NULL, shortdesc VARCHAR(20) NOT NULL, longdesc VARCHAR(80))

In addition to offering Add and Delete buttons, provide a Sort button that has a pop-up menu with three sort order options: by ID, by category, and by short description. All three could be connected to a single method using lambda or functools.partial. To make any new sort (or filter) take effect, you must call select() on the model. Use a QDialogButtonBox for all the buttons.

Category

Short Desc.

Long Desc.

1

Actions 1

Wait

Wait for Information

2

Actions 1

Progress

Progress to Next Stage

El

Actions

iscalate

Send to Supervisor

h

Add

Delete

Sort Close

Figure 15.7 The Reference Data dialog

Figure 15.7 The Reference Data dialog

If the user clicks Delete, pop up a yes/no message box, and delete only if they click the Yes button. The application is similar to the ReferenceDataDlg from the Asset Manager application, and can be written in about 130 lines.

A solution is provided in chap15/referencedata.pyw.

Was this article helpful?

0 0
Tube Traffic Ninja

Tube Traffic Ninja

Discover How You Can Quickly And Easily Dominate Google and YouTube... With Simple Cash Generating Videos. Did you know that YouTube is the second largest search website on the entire Internet? YouTube gets more daily searches than Bing and Yahoo. In fact, there is only one search engine that gets more action.

Get My Free Ebook


Post a comment