Back to index

python-biopython  1.60
xbb_utils.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # Created: Thu Jul 13 12:09:58 2000
00003 # Last changed: Time-stamp: <00/12/03 12:10:58 thomas>
00004 # thomas@cbs.dtu.dk, http://www.cbs.dtu.dk/thomas
00005 # File: xbb_utils.py
00006 
00007 import sys
00008 sys.path.insert(0, '.')
00009 from Tkinter import *
00010 from FileDialog import SaveFileDialog
00011 
00012 class NotePad(Toplevel):
00013     def __init__(self, master= None):
00014         Toplevel.__init__(self, master)
00015         self.menubar = Menu(self)
00016         self.filemenu = Menu(self.menubar)
00017         self.filemenu.add_command(label = "Save", command = self.save)
00018         self.filemenu.add_separator()
00019         self.filemenu.add_command(label = "Dismiss", command = self.destroy)
00020     
00021         self.menubar.add_cascade(label="File", menu=self.filemenu)
00022         self.configure(menu = self.menubar)
00023         self.yscroll = Scrollbar(self,orient=VERTICAL)
00024         self.tid = Text(self, yscrollcommand = self.yscroll.set)
00025         self.yscroll.configure(command = self.tid.yview)
00026         self.tid.pack(side = LEFT, fill = BOTH, expand = 1)
00027         self.yscroll.pack(side = RIGHT, fill = Y)
00028         
00029 
00030     def text_id(self): return self.tid
00031     def insert(self,start, txt):
00032         self.tid.insert(start, txt)
00033         
00034     def save(self):
00035         fd = SaveFileDialog(self)
00036         file = fd.go(key="test")
00037         if file:
00038             fid = open(file, 'w')
00039             fid.write(self.tid.get(0.0,END))
00040             fid.close()