#! /usr/bin/python2.7 # View a single MIME multipart message. # Display each part as a box. import string from types import * from Tkinter import * from ScrolledText import ScrolledText class MimeViewer: def __init__(self, parent, title, msg): self.title = title self.msg = msg self.frame = Frame(parent, {'relief': 'raised', 'bd': 2}) self.frame.packing = {'expand': 0, 'fill': 'both'} self.button = Checkbutton(self.frame, {'text': title, 'command': self.toggle}) self.button.pack({'anchor': 'w'}) headertext = msg.getheadertext( lambda x: x != 'received' and x[:5] != 'x400-') height = countlines(headertext, 4) if height: self.htext = ScrolledText(self.frame, {'height': height, 'width': 80, 'wrap': 'none', 'relief': 'raised', 'bd': 2}) self.htext.packing = {'expand': 1, 'fill': 'both', 'after': self.button} self.htext.insert('end', headertext) else: self.htext = Frame(self.frame, {'relief': 'raised', 'bd': 2}) self.htext.packing = {'side': 'top', 'ipady': 2, 'fill': 'x', 'after': self.button} body = msg.getbody() if type(body) == StringType: self.pad = None height = countlines(body, 10) if height: self.btext = ScrolledText(self.frame, {'height': height, 'width': 80, 'wrap': 'none', 'relief': 'raised', 'bd': 2}) self.btext.packing = {'expand': 1, 'fill': 'both'} self.btext.insert('end', body) else: self.btext = None self.parts = None else: self.pad = Frame(self.frame, {'relief': 'flat', 'bd': 2}) self.pad.packing = {'side': 'left', 'ipadx': 10, 'fill': 'y', 'after': self.htext} self.parts = [] for i in range(len(body)): p = MimeViewer(self.frame, '%s.%d' % (title, i+1), body[i]) self.parts.append(p) self.btext = None self.collapsed = 1 def pack(self): self.frame.pack(self.frame.packing) def destroy(self): self.frame.destroy() def show(self): if self.collapsed: self.button.invoke() def toggle(self): if self.collapsed: self.explode() else: self.collapse() def collapse(self): self.collapsed = 1 for comp in self.htext, self.btext, self.pad: if comp: comp.forget() if self.parts: for part in self.parts: part.frame.forget() self.frame.pack({'expand': 0}) def explode(self): self.collapsed = 0 for comp in self.htext, self.btext, self.pad: if comp: comp.pack(comp.packing) if self.parts: for part in self.parts: part.pack() self.frame.pack({'expand': 1}) def countlines(str, limit): i = 0 n = 0 while n < limit: i = string.find(str, '\n', i) if i < 0: break n = n+1 i = i+1 return n def main(): import sys import getopt import mhlib opts, args = getopt.getopt(sys.argv[1:], '') for o, a in opts: pass message = None folder = 'inbox' for arg in args: if arg[:1] == '+': folder = arg[1:] else: message = string.atoi(arg) mh = mhlib.MH() f = mh.openfolder(folder) if not message: message = f.getcurrent() m = f.openmessage(message) root = Tk() tk = root.tk top = MimeViewer(root, '+%s/%d' % (folder, message), m) top.pack() top.show() root.minsize(1, 1) tk.mainloop() if __name__ == '__main__': main()
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
AttrDialog.py | File | 14 KB | 0644 |
|
AttrDialog.pyc | File | 18.33 KB | 0644 |
|
AttrDialog.pyo | File | 18.33 KB | 0644 |
|
ManPage.py | File | 6.7 KB | 0644 |
|
ManPage.pyc | File | 6.27 KB | 0644 |
|
ManPage.pyo | File | 6.27 KB | 0644 |
|
MimeViewer.py | File | 4.39 KB | 0755 |
|
MimeViewer.pyc | File | 4.83 KB | 0644 |
|
MimeViewer.pyo | File | 4.83 KB | 0644 |
|
ShellWindow.py | File | 4.07 KB | 0644 |
|
ShellWindow.pyc | File | 5.47 KB | 0644 |
|
ShellWindow.pyo | File | 5.47 KB | 0644 |
|
brownian.py | File | 1.07 KB | 0644 |
|
brownian.pyc | File | 1.59 KB | 0644 |
|
brownian.pyo | File | 1.59 KB | 0644 |
|
brownian2.py | File | 1.35 KB | 0644 |
|
brownian2.pyc | File | 1.74 KB | 0644 |
|
brownian2.pyo | File | 1.74 KB | 0644 |
|
canvasevents.py | File | 6.45 KB | 0755 |
|
canvasevents.pyc | File | 10.46 KB | 0644 |
|
canvasevents.pyo | File | 10.46 KB | 0644 |
|
dialog.py | File | 3.13 KB | 0755 |
|
dialog.pyc | File | 3.11 KB | 0644 |
|
dialog.pyo | File | 3.11 KB | 0644 |
|
electrons.py | File | 2.27 KB | 0755 |
|
electrons.pyc | File | 2.33 KB | 0644 |
|
electrons.pyo | File | 2.33 KB | 0644 |
|
hanoi.py | File | 4.54 KB | 0644 |
|
hanoi.pyc | File | 3.82 KB | 0644 |
|
hanoi.pyo | File | 3.82 KB | 0644 |
|
hello.py | File | 331 B | 0644 |
|
hello.pyc | File | 701 B | 0644 |
|
hello.pyo | File | 701 B | 0644 |
|
imagedraw.py | File | 509 B | 0644 |
|
imagedraw.pyc | File | 1.13 KB | 0644 |
|
imagedraw.pyo | File | 1.13 KB | 0644 |
|
imageview.py | File | 205 B | 0644 |
|
imageview.pyc | File | 570 B | 0644 |
|
imageview.pyo | File | 570 B | 0644 |
|
kill.py | File | 3.79 KB | 0755 |
|
kill.pyc | File | 4.81 KB | 0644 |
|
kill.pyo | File | 4.81 KB | 0644 |
|
listtree.py | File | 991 B | 0644 |
|
listtree.pyc | File | 1.5 KB | 0644 |
|
listtree.pyo | File | 1.5 KB | 0644 |
|
mbox.py | File | 7.3 KB | 0755 |
|
mbox.pyc | File | 8.17 KB | 0644 |
|
mbox.pyo | File | 8.17 KB | 0644 |
|
newmenubardemo.py | File | 1.2 KB | 0755 |
|
newmenubardemo.pyc | File | 1.59 KB | 0644 |
|
newmenubardemo.pyo | File | 1.59 KB | 0644 |
|
optionmenu.py | File | 441 B | 0644 |
|
optionmenu.pyc | File | 594 B | 0644 |
|
optionmenu.pyo | File | 594 B | 0644 |
|
paint.py | File | 1.85 KB | 0644 |
|
paint.pyc | File | 2.19 KB | 0644 |
|
paint.pyo | File | 2.19 KB | 0644 |
|
rmt.py | File | 4.39 KB | 0755 |
|
rmt.pyc | File | 4.93 KB | 0644 |
|
rmt.pyo | File | 4.93 KB | 0644 |
|
solitaire.py | File | 17.37 KB | 0755 |
|
solitaire.pyc | File | 20.41 KB | 0644 |
|
solitaire.pyo | File | 20.41 KB | 0644 |
|
sortvisu.py | File | 18.89 KB | 0755 |
|
sortvisu.pyc | File | 23.18 KB | 0644 |
|
sortvisu.pyo | File | 23.18 KB | 0644 |
|
ss1.py | File | 25.57 KB | 0644 |
|
ss1.pyc | File | 31.67 KB | 0644 |
|
ss1.pyo | File | 31.07 KB | 0644 |
|
svkill.py | File | 4.75 KB | 0755 |
|
svkill.pyc | File | 5.8 KB | 0644 |
|
svkill.pyo | File | 5.8 KB | 0644 |
|
switch.py | File | 1.52 KB | 0644 |
|
switch.pyc | File | 2.85 KB | 0644 |
|
switch.pyo | File | 2.85 KB | 0644 |
|
tkman.py | File | 8.79 KB | 0755 |
|
tkman.pyc | File | 8.88 KB | 0644 |
|
tkman.pyo | File | 8.88 KB | 0644 |
|
wish.py | File | 623 B | 0644 |
|
wish.pyc | File | 737 B | 0644 |
|
wish.pyo | File | 737 B | 0644 |
|