Exemplo n.º 1
0
 def DoSelection(self, event):
     from posixpath import join
     import string
     lb = event.widget
     field = self.fileNameEntry
     field.delete(0, Tkinter.AtEnd())
     field.insert(0, join(self.cwd_print(), lb.get(lb.nearest(event.y))))
     lb.select_clear(0, "end")
     lb.select_anchor(lb.nearest(event.y))
     # ------------------------------------
     # Get some help from the file
     # this could be the __docs__ string from
     # the module, but that would require us to load it
     # and that seems like not a good idea. Maybe better
     # to get data from a text file, or top of .py file
     if field.get()[-3:] == ".py" or field.get()[-6:] == ".world":
         fp = open(field.get(), "r")
         lines = fp.readlines()
         stringlines = string.join(lines, '')
         fp.close()
     else:
         stringlines = "Click the 'OK' button to load."
     self.helpText.config(state='normal')
     self.helpText.delete(1.0, 'end')
     self.helpText.insert('end', stringlines)
     self.helpText.config(state='disabled')