The NoteBook widget is useful for displaying information from more than one file at a time. The example below makes use of both Tkinter and Bwidget widgets.

   1 import bwidget, Tkinter, sys, os
   2 
   3 app = Tkinter.Tk(); app.wm_title("pybwidget demo")
   4 notebook = bwidget.NoteBook(app, arcradius=2); notebook.pack()
   5 
   6 files = sys.argv[0], Tkinter.__file__, bwidget.__file__
   7 for i, f in enumerate(files):
   8     if f.endswith(".pyc"): f = f[:-1]
   9     page = notebook.insert(Tkinter.END, i, text=os.path.basename(f))
  10     sw = bwidget.ScrolledWindow(page)
  11     text = Tkinter.Text(sw)
  12     text.insert(Tkinter.END, open(f).read())
  13     sw.setwidget(text)
  14     sw.pack(side=Tkinter.TOP, fill=Tkinter.BOTH, expand=True)
  15 notebook.compute_size()
  16 
  17 app.mainloop()

Screenshot:

bwNotebook1.png


Several other Notebook implementations are available, including worthwhile ones from the Cookbook, ...: http://www.google.com/search?q=tkinter+notebook&start=0&ie=utf-8&oe=utf-8.

tkinter: NoteBook (last edited 2010-07-26 11:59:12 by localhost)