Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
File Dialog and Textbox example easygui
02-01-2010, 06:05 AM
Post: #1
File Dialog and Textbox example easygui
Code:
from easygui import *
import sys;

#retrieve any file name select that end with a .txt
filename = fileopenbox("Select a plain text file","","*",['*.txt', "Text Files"]);

#exit if no file selected
if filename == None:
    sys.exit(0);

#open the file for reading  
fout = open(filename,'r');

#display error message if the file could not be open to read
if fout == None:
    msgbox("Error: unable to read file");
    sys.exit(1);
    
#read the file data
data = fout.readlines();

#display the data in a textbox
textbox("Data from " + filename,filename,data);

#close file
fout.close();


Attached File(s)
.zip  textbox.zip (Size: 18.4 KB / Downloads: 1)
Visit this user's website Find all posts by this user
Quote this message in a reply
02-01-2010, 03:54 PM
Post: #2
RE: File Dialog and Textbox example easygui
This is very good. You even made error handling. Great work !

"I dont know with what weapons World War 3 will be fought with, but i know World War 4 will be fought with stones and sticks" - Albert Einstein
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


 Quick Theme: