| 1 | #! /usr/bin/env python
|
|---|
| 2 |
|
|---|
| 3 | # View a single MIME multipart message.
|
|---|
| 4 | # Display each part as a box.
|
|---|
| 5 |
|
|---|
| 6 | import string
|
|---|
| 7 | from types import *
|
|---|
| 8 | from Tkinter import *
|
|---|
| 9 | from ScrolledText import ScrolledText
|
|---|
| 10 |
|
|---|
| 11 | class MimeViewer:
|
|---|
| 12 | def __init__(self, parent, title, msg):
|
|---|
| 13 | self.title = title
|
|---|
| 14 | self.msg = msg
|
|---|
| 15 | self.frame = Frame(parent, {'relief': 'raised', 'bd': 2})
|
|---|
| 16 | self.frame.packing = {'expand': 0, 'fill': 'both'}
|
|---|
| 17 | self.button = Checkbutton(self.frame,
|
|---|
| 18 | {'text': title,
|
|---|
| 19 | 'command': self.toggle})
|
|---|
| 20 | self.button.pack({'anchor': 'w'})
|
|---|
| 21 | headertext = msg.getheadertext(
|
|---|
| 22 | lambda x: x != 'received' and x[:5] != 'x400-')
|
|---|
| 23 | height = countlines(headertext, 4)
|
|---|
| 24 | if height:
|
|---|
| 25 | self.htext = ScrolledText(self.frame,
|
|---|
| 26 | {'height': height,
|
|---|
| 27 | 'width': 80,
|
|---|
| 28 | 'wrap': 'none',
|
|---|
| 29 | 'relief': 'raised',
|
|---|
| 30 | 'bd': 2})
|
|---|
| 31 | self.htext.packing = {'expand': 1, 'fill': 'both',
|
|---|
| 32 | 'after': self.button}
|
|---|
| 33 | self.htext.insert('end', headertext)
|
|---|
| 34 | else:
|
|---|
| 35 | self.htext = Frame(self.frame,
|
|---|
| 36 | {'relief': 'raised', 'bd': 2})
|
|---|
|
|---|