CMS 3D CMS Logo

helpfunctions.py

Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 from Tkinter import *
00003 import os
00004 import string
00005 
00006 def Helpwin(filename,usetext=0,title="Help Information"):
00007 
00008     # If usetext = 1, assume that 'filename' is actually a string
00009     # containing information to be displayed.
00010     # Otherwise, assume filename is a file, and open that file
00011     # to get its contents.
00012     
00013     if usetext==1:
00014         helpfile=filename
00015     else:
00016         if os.path.isfile(filename):
00017             helpfile=open(filename,'r').read()
00018         else:
00019             helpfile = "File '%s' does not exist"%filename
00020     
00021     try:
00022         if usetext == 0:
00023             newwin.title(os.path.basename(filename))
00024         else:
00025             newwin.title(title)
00026         text.delete('1.0',END)
00027         text.insert('1.0',helpfile)
00028         text.focus()
00029 
00030     except:
00031         newwin=Toplevel()
00032         
00033         
00034         if string.find(os.path.basename(filename),"params.dat")>-1:
00035             newwin.geometry('1150x500+20+300')
00036         else:
00037             newwin.geometry('1150x500+20+300')
00038 
00039         if usetext == 0:
00040             newwin.title(os.path.basename(filename))
00041         else:
00042             newwin.title(title)
00043         Button(newwin, text="Close", command=newwin.destroy).pack()
00044         ybar=Scrollbar(newwin)
00045         text=Text(newwin,relief=SUNKEN,bg="grey98")
00046         ybar.config(command=text.yview)
00047         text.config(yscrollcommand=ybar.set)
00048         ybar.pack(side=RIGHT,fill=Y)
00049         text.pack(side=LEFT,expand=YES,fill=BOTH)
00050         text.delete('1.0',END)
00051         text.insert('1.0',helpfile)
00052         text.focus()
00053         text.bind('<Button-3>',(lambda event,x=newwin:
00054                                 x.destroy()))
00055 
00056 
00057 def gracefulexit(win):
00058     win.window.destroy()

Generated on Tue Jun 9 17:32:56 2009 for CMSSW by  doxygen 1.5.4