<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE></TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 5.50.4937.800" name=GENERATOR></HEAD>
<BODY>
<P><FONT size=2>I am working with Tkinter and trying to create a box that has
three buttons (in the Open() function) and these buttons seem to not work.
I am wondering what I am doing wrong. Here is all of the code but I think
that the problem lies within the Open function. The first window pops up
upon running the program but there is nothing in the window. Can you
help!!!</FONT></P>
<P><FONT color=#ff0000 size=2>#Created by dtalaga for Novo Dynamics<BR>import
os<BR>from Tkinter import *<BR>import tkFileDialog<BR>import sys<BR>import
re<BR>import Tkinter</FONT></P>
<P><FONT color=#ff0000
size=2>#---------------------------------------------------------------------------------------<BR>#Define
all variables<BR>global root<BR>root=Tk()<BR>result = 0<BR>sub =
re.sub<BR>#---------------------------------------------------------------------------------------</FONT></P>
<P><FONT color=#ff0000 size=2># define the dialog function to call the dialog
box <BR>def dialog():<BR>
root.withdraw()<BR> initDir =
'C:/windows/desktop'<BR> filetype = [('All files',
'.*')]<BR> fileName =
tkFileDialog.askopenfilename(initialdir=initDir,
filetypes=filetype)<BR> return fileName</FONT></P>
<P><FONT color=#ff0000
size=2>#---------------------------------------------------------------------------------------<BR>#Define
the doDialog function. Uses the dialog function from another file<BR>def
doDialog():<BR> global result<BR> result =
dialog()<BR>
<BR>#---------------------------------------------------------------------------------------<BR>#Define
the List function that displays the list of "cleaned" files<BR>def
Open():<BR> f = Tkinter.Button(root, text = "Find Files", command =
Clean)<BR> f.pack()<BR> l = Tkinter.Button(root, text =
"View List", command = List)<BR> l.pack()<BR> x =
Tkinter.Button(root, text = "Exit", command = sys.exit)<BR>
x.pack<BR>
<BR>#---------------------------------------------------------------------------------------<BR>#Define
function List to be used in the Open() function.<BR>def List():<BR>
S = Tkinter.Scrollbar()<BR> L = Tkinter.Listbox()<BR>
S.pack(side = Tkinter.RIGHT, fill = Tkinter.Y)<BR> L.pack(side =
Tkinter.LEFT, fill = Tkinter.Y)<BR> S.config(command =
L.yview)<BR> L.config(yscrollcommand = S.set)</FONT></P>
<P><FONT color=#ff0000
size=2>#---------------------------------------------------------------------------------------<BR>#Define
function Clean. Clean will take the files and clean them </FONT></P>
<P><FONT color=#ff0000 size=2>def Clean():<BR> if
f:<BR> fileName =
dialog()<BR> in_file =
open(fileName,'r').readlines()<BR> out_file
= open(fileName + '_cleaned.txt', 'w')<BR>
for i in in_file:<BR> tmp =
sub('\x0D','', i)<BR>
out_file.write(tmp)<BR> print 'File
cleaned'<BR>
<BR> if x:<BR>
out_file.close()<BR> if
l:<BR> List()<BR> print
fileName</FONT></P>
<P><FONT color=#ff0000
size=2>#---------------------------------------------------------------------------------------<BR>#Call
the working functions<BR>#Open()</FONT></P><FONT size=2>
<P><FONT face=Arial></FONT><BR><FONT color=#ff0000>
<BR>#---------------------------------------------------------------------------------------<BR>#Make
the path where the cleaned files will be stored<BR>if
os.path.isdir("C:\\Cleaned_Files"):<BR> print "C:\\Cleaned_Files
exists"<BR>else:<BR> os.mkdir("C:\\Cleaned_Files")<BR>
<BR>#---------------------------------------------------------------------------------------
</FONT></P>
<P><FONT color=#ff0000>root.mainloop()<BR></FONT><BR><BR><BR>David
Talaga<BR>dtalaga@novodynamics.com<BR>734-205-9127 </FONT></P></BODY></HTML>