Create the dialog shown in Figure 6.11. It should have the class name Re-sizeDlg, and its initializer should accept an initial width and height. The dialog should provide a method called result(), which must return a two-tuple of the width and height the user has chosen. The spinboxes should have a minimum of 4 and a maximum of four times the width (or height) passed in. Both should show their contents right-aligned.

Figure 6.11 The Image Changer resize dialog

Modify the Image Changer application so that it has a new "edit resize" action. The action should appear on the Edit menu (after the "edit zoom" action). An icon called editresize.png is in the images subdirectory, but will need to be added to the resources.qrc file. You will also need to import the resize dialog you have just created.

The resize dialog should be used in an editResize() slot that the "edit resize" action should be connected to. The dialog is used like this:

form = resizedlg.ResizeDlg(self.image.width(), self.image.height(), self)

width, height = form.result()

Unlike the editZoom() slot, the image itself should be changed, so the size label, status bar, and dirty status must all be changed if the size is changed. On the other hand, if the "new" size is the same as the original size, no resizing should take place.

The resize dialog can be written in less than 50 lines, and the resize slot in less than 20 lines, with the new action just requiring an extra one or two lines in a couple of places in the main window's initializer.

A model solution is in the files chap06/imagechanger_ans.pyw and chap06/resize-dlg.py.

This page intentionally left blank

• Designing User Interfaces

• Implementing Dialogs

• Testing Dialogs

Was this article helpful?

0 0
Tube Jacker

Tube Jacker

Download Tube Jacker And Discover Everything You Need To Know About Jacking Unlimited Traffic From The Video Giant. The drop dead easy way to create winning video campaigns that will FLOOD your website with unstoppable FREE traffic, all on complete and total autopilot. How to exploit a sneaky method of boosting exposure and getting your videos to the top of Google within 72 hours, guaranteed.

Get My Free Ebook

Post a comment