-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathguimixin.py
76 lines (61 loc) · 2.35 KB
/
guimixin.py
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
from tkinter.messagebox import *
from tkinter.messagebox import *
from Useful.launchmodes import PortableLauncher, System
from scrolledtext import ScrolledText
class GuiMixin:
def infobox(self, title, text, *args):
return showinfo(title, text)
def errorbox(self, text):
showerror('Error!', text)
def question(self, title, text, *args):
return askyesno(title, text)
def notdone(self):
showerror('Not implemented', 'Option not available')
def quit(self):
ans = self.question('Verify quit', 'Are you sure want to quit?')
if ans:
Frame.quit(self)
def help(self):
self.infobox('RTFM', 'See figure 1...')
def selectOpenFile(self, file="", dir="."):
return askopenfilename(initialdir=dir, initialfile=file)
def selectSaveFile(self, file='', dir='.'):
return asksaveasfilename(initialfile=file, initialdir=dir)
def clone(self, args=()):
new = Toplevel()
myclass = self.__class__
myclass(new, *args)
def spawn(self, pycmdline, wait=False):
if not wait:
PortableLauncher(pycmdline, pycmdline)()
else:
System(pycmdline, pycmdline)()
def browser(self, filename):
new = Toplevel()
view = ScrolledText(new, file=filename)
view.text.config(height=30, width=85)
view.text.config(fount=('courier', 10, 'normal'))
new.title('Text Viewer')
new.iconname('browser')
'''
def browser(self, filename):
new = Toplevel()
text = ScrolledText(new, height=30, width=85)
text.config(font=('courier', 10, 'normal'))
text.pack(expand=YES, fill=BOTH)
new.title('Text Viewer')
new.iconname('browser')
text.insert('0.0', open(filename, 'r').read())
'''
if __name__ == '__main__':
class TestMixin(GuiMixin, Frame):
def __init__(self, parent=None):
Frame.__init__(self, parent)
self.pack()
Button(self, text='quit', command=self.quit).pack(fill=X)
Button(self, text='help', command=self.help).pack(fill=X)
Button(self, text='clone', command=self.clone).pack(fill=X)
Button(self, text='spawn', command=self.other).pack(fill=X)
def other(self):
self.spawn('D:\\Projects\\Train\\guimixin.py')
TestMixin().mainloop()