1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
from Tkinter import *
import Shells, ButtonBox
from ui_config import config
class CommandButton(Button):
def __init__(self, master, text, command):
Button.__init__(self, master=master, text=text,
font=config["command-font"], padx=1, pady=0,
command=command)
self.pack(side=LEFT)
class ModalDialog(Shells.Modal):
def terminate(self):
Shells.Modal.terminate(self)
self.top.update()
def show(self):
apply(Shells.NonModal.show, (self,))
self.initFocus()
self.top.waitvar(self.waitVar)
return self.result
def initFocus(self):
pass
class PgpUsernameDialog(ModalDialog):
def __init__(self, infrontof, default_value):
ModalDialog.__init__(self, infrontof)
self.top.title("Enter PGP username")
self.top.iconname("Enter PGP username")
Label(self.top, text="Please enter the PGP username").pack()
self.entry = Entry(self.top, width=40)
self.entry.pack()
self.entry.bind("<Key-Return>", self.ok)
self.entry.bind("<Key-Escape>", self.cancel)
b = ButtonBox.T(self.top,
("OK", self.ok), ("Cancel", self.cancel))
self.default_value = default_value
def ok(self, event=None):
self.terminate()
self.result = self.entry.get()
def cancel(self, event=None):
self.terminate()
self.result = None
def initControls(self):
self.entry.delete('0', 'end')
self.entry.insert('0', self.default_value)
def initFocus(self):
self.entry.focus_set()
class PasswordDialog(ModalDialog):
def __init__(self, infrontof):
ModalDialog.__init__(self, infrontof)
self.top.title("Enter PGP Passphrase")
self.top.iconname("Enter PGP Passphrase")
Label(self.top, text="Please enter the PGP passphrase").pack()
self.entry = Entry(self.top, show="*", width=40)
self.entry.pack()
self.entry.bind("<Key-Return>", self.ok)
self.entry.bind("<Key-Escape>", self.cancel)
b = ButtonBox.T(self.top,
("OK", self.ok), ("Cancel", self.cancel))
def ok(self, event=None):
self.terminate()
self.result = self.entry.get()
def cancel(self, event=None):
self.terminate()
self.result = None
def initControls(self):
self.entry.delete('0', 'end')
def initFocus(self):
self.entry.focus_set()
class YesNoDialog(ModalDialog):
def __init__(self, infrontof, question, title=None):
ModalDialog.__init__(self, infrontof)
if not title:
title = question
self.top.title(title)
self.top.iconname(title)
Label(self.top, text=question).pack()
b = ButtonBox.T(self.top,
("OK", self.ok), ("Cancel", self.cancel))
def ok(self):
self.result = 1
self.terminate()
def cancel(self):
self.result = 0
self.terminate()
class NonModalDialog(Shells.NonModal):
def terminate(self):
Shells.NonModal.terminate(self)
self.top.update()
class InfoBox(NonModalDialog):
def __init__(self, infrontof, title, text):
NonModalDialog.__init__(self, infrontof)
self.top.title(title)
self.top.iconname(title)
Message(self.top, text=text, width=250).pack()
Button(self.top, text="Dismiss", command=self.terminate).pack()
class ErrorBox(InfoBox):
def __init__(self, infrontof, title, text):
InfoBox.__init__(self, infrontof, "Error: " + title, text)
class FolderInfoEditor(ModalDialog):
def __init__(self, infrontof, foldername, is_inbox_now):
ModalDialog.__init__(self, infrontof)
self.top.title("Folder settings")
self.top.iconname("Folder settings")
Label(self.top, text="Settings for folder %s" % foldername).pack()
frame = Frame(self.top)
frame.pack(fill=X)
Label(frame, text="Scan for new messages?").pack(side=LEFT)
self.var = BooleanVar()
self.var.set(is_inbox_now)
self.is_inbox = Checkbutton(frame, variable=self.var,
command=self.setOnOffText)
self.is_inbox.pack(side=LEFT)
frame = Frame(self.top)
frame.pack(fill=X)
Button(frame, text="OK", command=self.ok).pack(side=LEFT)
Button(frame, text="Cancel", command=self.cancel).pack(side=LEFT)
self.setOnOffText()
def setOnOffText(self):
if self.var.get() == 0:
text = "No"
else:
text = "Yes"
self.is_inbox.config(text=text)
def ok(self):
self.result = self.var.get()
self.terminate()
def cancel(self):
self.result = None
self.terminate()
|