Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
This week, we're updating our course layouts and descriptions. Presentation and materials always gently change over time, but just occasionally there's a need to make a step change to clear out some of the old and roll in the new. That's now happening - but over a long and complex site it's not instant and you'll see sections of the site changing up to and including 19th September.

See also [here] for status update
 
read data from file and display at tk entry

Posted by dee00zee (dee00zee), 11 July 2005
I have one gui to ask user to input her name, passport number and address.
These information will be saved in a file called data

Later when she invoke the gui again, she wants to see the info that she entered before.

Is it possible for gui to read data from a file(data) and display the content at the right entries?
Any example how to do this?

Posted by admin (Graham Ellis), 12 July 2005
Code:
#!/usr/bin/wish

set fh [open demo.txt r]
gets $fh rupert
gets $fh phonenumber
close $fh

entry .name -textvariable rupert -width 20
entry .number -textvariable phonenumber -width 20
button .done -text completed -command {
       set fh [open demo.txt w]
       puts $fh $rupert
       puts $fh $phonenumber
       exit;
       }

pack .name .number .done -expand y -fill both


This example takes the current name and number from a data file, lets the user modify them, and saves them back to the same file when the done button is clicked.

The file demo.txt needs to exist before you run the program for the first time, and contain two lines of data which will be used to "seed" the application.



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2014: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho