Note the grid manager used to place the labels in a column. The bottom frame is no more complicated, and consists of only three widgets: two LabEntry widgets for showing the state of the transaction both sent and received and a button to actually perform the processing.
The button is bound to the processTransaction routine, which is straightforward. See Listing 3. The only thing left to do is to start the event processing, which should look familiar by this time:. To configure the file dialog boxes, each routine needs a list of the file types to accept:. See Figure 1. To actually execute the dialog, simply call getSaveFile:.
You can specify the initial file name for the dialog, as shown above. Only if the user answers affirmatively will the filename be returned. Once we have the filename, we can then save and load the configuration. We are using an extremely simple file format, basically a mini-Perl program, thanks to the Data::Dumper module.
This is where the interpreted nature of Perl shines. To write out the file, we open it, print the text provided by Dumper, and then close it. Reading it back in is simple as well. Slurp up the file, and then use the eval function to interpret the file. One really cool widget in the pTk system is the NoteBook see Figure 4. The doConfig callback subroutine actually implements the system. The -ipad options tell the system how much internal padding to leave around the widgets contained within the box.
To actually use the NoteBook, you must now add pages to it:. Again, we use the LabEntry widget to make a labeled text-entry box. The return value is the text of the button that the user pressed to end the dialog. That just about covers the example program, which is available electronically in the listings archive for this issue. To run the program under Windows, double-click on the file name ptkpos.
The ActiveState installation program for Windows associates the. Under Linux, you first need to make the program executable. You can then use the K file manager and click on the program, or execute it from the command line directly. This module simulates the transaction process by providing data that you could expect to receive if you were to send the data to a real validation system.
It does, however, check to see if the credit card could be a valid card: if so, it returns an authorization code, otherwise it will be declined. To use the application for real transactions, you must replace the stub with an active link to a real online gateway system. To configure the system, select File Configuration from the menu bar. Fill in the User and Password fields as provided by PaymentNet, or leave it blank to use the simulator.
For testing, leave test. Port is the default and should never need to be changed. If you are processing transactions from behind a firewall always a good idea when doing electronic commerce you need to set the Proxy settings.
Consult the PaymentNet documentation for full details on how to do this. The application supports only a limited subset of the PaymentNet system. In particular, PaymentNet supports various forms of check processing. It should be possible to support other payment gateways relatively easily, though doing so is not currently planned. You can find more information as well as the payment-transaction module on how to do so at the Commerce-Store.
There are quite a few exploration tools available for both Perl and pTk. I encourage you to take a look at some of the Web sites presented here, as well as the example programs that come with the distribution. Nick Temple is an entrepreneur who has recently relocated to Silicon Valley to pursue the startup dream. The founder of The Temple Group, Ltd. It appears that tkFileDialog. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams?
Collectives on Stack Overflow. Learn more. How to select a directory and store the location using tkinter in Python Ask Question. Asked 9 years, 6 months ago. Active 2 years, 8 months ago.
Viewed k times. Improve this question. Cristian Ciupitu It may be specified as a colour name from rgb. Default is 'black'. If set to 1 it forces the ColourChooser to only return colours as hex numbers in Tk format ' HHHHHH' ; if set to 0 it returns colours as names if they are named in rgb.
Transparent is always returned as 'None' however. Default is 0. If set to 0 it stops ColourChooser offering the Transparent button so that only valid colours may be chosen - or cancel. Default is 1. If set to 1 it shows the hex value of the colour in the title bar. Transparent Pressing Transparent will return the string 'None' which is xpm's name for transparent. Let the window wait for any events.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics. Previous Python askopenfile function in Tkinter. Next Python GUI - tkinter. Recommended Articles. Article Contributed By :. Easy Normal Medium Hard Expert.
0コメント