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
100 SEO Tips and More

100 SEO Tips and More

100 SEO Tips EVERY SEO Enthusiast Should Know. This Report 100 SEO Tips will help you to Utilize These Tips to Dominate The Search Engine Today.

Get My Free Ebook


Post a comment