Tqst DRIVQ

The deliveries program is ready, so it is time for the demo. With the code entered into IDLE, press F5 to fire it up and you should see this:

Vouir éjUI is looki

Hifld<E* Dvlivartn

DopJ

Jlddrpt*:

J Hain Street kny Law* MA

You can enter data into each of the fields, even the multiline address. When you click Save, the fields all get cleared. When you open up the deliveries . txt file, you see that the data you entered into the GUI has been saved.

T\e you

Depot : Seattle, WA Description : Books Address : 1 Main Street Anytown

Congratulations! You've written your first GUI data-entry application.

there-iSpe no

Dumb Questions

Is it possible to put more than one line of text into an Entry box widget?

A/ Yes, you probably could, but if you need to do this, you are much better off using a Text box, because they are designed to handle more than one line of text.

I notice that we are calling the pack() method as part of the label creation code, whereas before we assigned the label to a variable then called pack() on the new variable. Which packing technique should I use and does it really matter?

A" No, it does not really matter which technique you use to call pack(). If it makes sense to pack your widgets as they are created, include the call to pack() as part of the creation code. If it doesn't make sense, assign the widget to a variable and do your packing whenever you need to. If you look at other examples of tkinter code on the Web, you'll see that other programmers use both techniques.

Why can't we just assign a value to an Entry box using the assignment operator (=)? Why do we have to use the insert() method?

A/ The Entry box is a widget object, not a Python variable, so using the assignment operator does not make sense here. When working with objects, you need to use the application programming interface (API) provided by and included with the object, which in this case is the insert () method.

Why do the rows in a Text box start counting from one as opposed to zero (like everything else in Python)?

A/ Beats the hell out of us. No idea.

So, just to be clear, Who is on first?

A/ No. Who is on second. Python is on first.

the other cambridge

Was this article helpful?

0 0

Post a comment