<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE></TITLE>

<META content="MSHTML 6.00.2800.1400" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial color=#0000ff size=2></FONT>&nbsp;</DIV>
<BLOCKQUOTE dir=ltr 
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid;
MARGIN-RIGHT: 0px">
  <DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma 
  size=2>-----Original Message-----<BR><B>From:</B> David Talaga 
  [mailto:dtalaga@novodynamics.com]<BR><B>Sent:</B> Tuesday, April 20, 2004 
  11:51 AM<BR><B>To:</B> Python Tutor<BR><B>Subject:</B> [Tutor] Tkinter 
  dilemas<BR><BR></FONT></DIV>
  <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.&nbsp; I am wondering what I am doing wrong.&nbsp; Here is all of the 
  code but I think that the problem lies within the Open function.&nbsp; 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>&nbsp;&nbsp;&nbsp; 
  root.withdraw()<BR>&nbsp;&nbsp;&nbsp; initDir = 
  'C:/windows/desktop'<BR>&nbsp;&nbsp;&nbsp; filetype = [('All files', 
  '.*')]<BR>&nbsp;&nbsp;&nbsp; fileName = 
  tkFileDialog.askopenfilename(initialdir=initDir, 
  filetypes=filetype)<BR>&nbsp;&nbsp;&nbsp; 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>&nbsp;&nbsp; global result<BR>&nbsp;&nbsp; result = 
  dialog()<BR>&nbsp;&nbsp; 
<BR>#---------------------------------------------------------------------------------------<BR>#Define
  the List function that displays the list of "cleaned" files<BR>def 
  Open():<BR>&nbsp;&nbsp; f = Tkinter.Button(root, text = "Find Files",
command 
  = Clean)<BR>&nbsp;&nbsp; f.pack()<BR>&nbsp;&nbsp; l = Tkinter.Button(root, 
  text = "View List", command = List)<BR>&nbsp;&nbsp; l.pack()<BR>&nbsp;&nbsp;

  = Tkinter.Button(root, text = "Exit", command = sys.exit)<BR>&nbsp;&nbsp; 
  x.pack<SPAN class=740133816-20042004><FONT face=Arial 
  color=#0000ff>&nbsp;</FONT></SPAN></FONT></P>
  <P><FONT color=#ff0000 size=2><SPAN class=740133816-20042004><FONT
face=Arial 
  color=#0000ff>Right here you forgot to put the parenthesis on 
  pack</FONT>&nbsp;</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
<BR>#---------------------------------------------------------------------------------------<BR>#Define
  function List to be used in the Open() function.<BR>def 
  List():<BR>&nbsp;&nbsp; S = Tkinter.Scrollbar()<BR>&nbsp;&nbsp; L = 
  Tkinter.Listbox()<BR>&nbsp;&nbsp; S.pack(side = Tkinter.RIGHT, fill = 
  Tkinter.Y)<BR>&nbsp;&nbsp; L.pack(side = Tkinter.LEFT, fill = 
  Tkinter.Y)<BR>&nbsp;&nbsp; S.config(command = L.yview)<BR>&nbsp;&nbsp; 
  L.config(yscrollcommand = S.set)</FONT></P>
  <P><FONT color=#ff0000 
size=2>#---------------------------------------------------------------------------------------<BR>#Define
  function Clean.&nbsp; Clean will take the files and clean 
them&nbsp;</FONT></P>
  <P><FONT color=#ff0000 size=2>def Clean():<BR>&nbsp;&nbsp;&nbsp; if 
  f:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fileName = 
  dialog()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; in_file = 
  open(fileName,'r').readlines()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  out_file = open(fileName + '_cleaned.txt', 
  'w')<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for i in 
  in_file:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tmp = 
  sub('\x0D','', i)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  out_file.write(tmp)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print 'File 
cleaned'<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  <BR>&nbsp;&nbsp;&nbsp; if x:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  out_file.close()<BR>&nbsp;&nbsp;&nbsp; if 
  l:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; List()<BR>&nbsp;&nbsp;&nbsp;
print 
  fileName</FONT></P>
  <P><FONT color=#ff0000 
size=2>#---------------------------------------------------------------------------------------<BR>#Call
  the&nbsp;working functions<BR>#Open()</FONT></P>
  <P><FONT size=2><SPAN class=740133816-20042004><FONT face=Arial 
  color=#0000ff>&nbsp;When I uncommented Open() it ran and showed the buttons 
  with the pack problem above it showed all 
  buttons&nbsp;</FONT></SPAN><BR></FONT><FONT color=#ff0000 
  size=2>&nbsp;&nbsp;&nbsp; 
<BR>#---------------------------------------------------------------------------------------<BR>#Make
  the path where the cleaned files will be stored<BR>if 
  os.path.isdir("C:\\Cleaned_Files"):<BR>&nbsp;&nbsp; print "C:\\Cleaned_Files
  exists"<BR>else:<BR>&nbsp;&nbsp;
os.mkdir("C:\\Cleaned_Files")<BR>&nbsp;&nbsp; 
<BR>#---------------------------------------------------------------------------------------&nbsp;&nbsp;
  </FONT></P>
  <P><FONT size=2><FONT 
  color=#ff0000>root.mainloop()<BR></FONT><BR><BR><BR>David 
  Talaga<BR>dtalaga@novodynamics.com<BR>734-205-9127&nbsp;<SPAN 
  class=740133816-20042004><FONT face=Arial 
  color=#0000ff>&nbsp;</FONT></SPAN></FONT></P>
  <P><FONT size=2><SPAN class=740133816-20042004></SPAN></FONT>&nbsp;</P>
  <P><FONT face=Arial color=#0000ff size=2><SPAN class=740133816-20042004>Your
  clean method will not work.&nbsp; Look on activestate for a shim recipie so 
  you can pass arguments with tkinter.&nbsp;&nbsp;&nbsp;Well I googled&nbsp;I 
  know&nbsp;there is one on AS but here is a url for another page.&nbsp; Look 
  this over you should be able to figure this out.&nbsp; I needed a similar 
  thing&nbsp;in the past.</SPAN></FONT></P>
  <P><FONT face=Arial color=#0000ff size=2><SPAN class=740133816-20042004><A 
href="http://www.astro.washington.edu/owen/TkinterSummary.html#CallbackShims">http://www.astro.washington.edu/owen/TkinterSummary.html#CallbackShims</A></SPAN></FONT></P>
  <P><FONT face=Arial color=#0000ff size=2><SPAN class=740133816-20042004>Good
  luck</SPAN></FONT><FONT size=2><SPAN 
  class=740133816-20042004>&nbsp;</SPAN></FONT></P></BLOCKQUOTE></BODY></HTML>

<P>-------------------------------------------------------------------------------------------<br>
***National City made the following annotations<br>
-------------------------------------------------------------------------------------------<br>
<br>
This communication is a confidential and proprietary business communication.
It is intended solely for the use of the designated recipient(s).  If this
communication is received in error, please contact the sender and delete this
communication.<br>
===========================================================================================</P>