-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgui.py
137 lines (107 loc) · 4.87 KB
/
gui.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
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
from tkinter import *
from PIL import Image, ImageTk
import functions
class MainWindow(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.parent = parent
self.initUI()
def initUI(self):
self.parent.title("pyTicket")
# CONTEXT MENU ###############################################
self.menu = Menu(self.parent, tearoff=0)
self.menu.add_command(label="Beep", command=self.bell)
self.menu.add_command(label="Exit", command=self.onExit)
self.parent.bind("<Button-3>", self.showMenu)
self.pack()
# CONTEXT MENU ###############################################
# FILE MENU ##################################################
menubar = Menu(self.parent)
self.parent.config(menu=menubar)
fileMenu = Menu(menubar, tearoff=False)
submenu = Menu(fileMenu, tearoff=False)
submenu.add_command(label="New feed")
submenu.add_command(label="Bookmarks")
submenu.add_command(label="Mail")
fileMenu.add_cascade(label='Import', menu=submenu, underline=0)
fileMenu.add_separator()
fileMenu.add_command(label="Exit", command=self.onExit)
menubar.add_cascade(label="File", menu=fileMenu)
# FILE MENU ##################################################
# TOOLBAR ####################################################
toolbar = Frame(self.parent, bd=1, relief=RAISED)
self.img = Image.open("Icons\create_new.png")
eimg = ImageTk.PhotoImage(self.img)
newButton = Button(toolbar, text="New ", image=eimg, compound="left", relief=RAISED, command=self.quit)
newButton.image = eimg
newButton.pack(side=LEFT, padx=2, pady=2)
self.img = Image.open("Icons\edit.png")
eimg = ImageTk.PhotoImage(self.img)
editButton = Button(toolbar, text="Edit ", image=eimg, compound="left", relief=RAISED, command=self.quit)
editButton.image = eimg
editButton.pack(side=LEFT, padx=2, pady=2)
self.img = Image.open("Icons\list_all.png")
eimg = ImageTk.PhotoImage(self.img)
list_allButton = Button(toolbar, text="List All ", image=eimg, compound="left", relief=RAISED, command=functions.ListAllTickets)
list_allButton.image = eimg
list_allButton.pack(side=LEFT, padx=2, pady=2)
self.img = Image.open("Icons\exit.png")
eimg = ImageTk.PhotoImage(self.img)
exitButton = Button(toolbar, text="Exit ", image=eimg, compound="left", relief=RAISED, command=self.quit)
exitButton.image = eimg
exitButton.pack(side=RIGHT, padx=2, pady=2)
self.img = Image.open("Icons\startupcheck.png")
eimg = ImageTk.PhotoImage(self.img)
startupButton = Button(toolbar, text="Re-Check ", image=eimg, compound="left", relief=RAISED, command=self.StartUpChecker)
startupButton.image = eimg
startupButton.pack(side=RIGHT, padx=2, pady=2)
toolbar.pack(side=TOP, fill=X)
self.parent.config(menu=menubar)
self.pack(anchor=N, side=TOP, fill=X, expand=False)
# TOOLBAR ####################################################
# TEXTBOX ####################################################
self.textbox = Text(self, wrap="word", height=5)
self.textbox.pack(side="bottom", fill="both", expand=True)
self.textbox.tag_configure("TextBox", foreground="#b22222")
self.pack(anchor=S, side=BOTTOM, fill=BOTH, expand=True)
# TEXTBOX ####################################################
# TEXTBOX2 ###################################################
b1 = Entry(self)
b1.pack(anchor=W, fill=X, expand=False)
# TEXTBOX2 ###################################################
sys.stdout = TextRedirector(self.textbox, "stdout")
sys.stderr = TextRedirector(self.textbox, "stderr")
# Functions ###################################################
def StartUpChecker(self):
self.clear_text()
#functions.StartUpChecker()
def clear_text(self):
self.textbox.delete("1.0", END)
def showMenu(self, e):
self.menu.post(e.x_root, e.y_root)
def onExit(self):
self.quit()
def print_stdout(self):
'''Illustrate that using 'print' writes to stdout'''
print("this is stdout")
def print_stderr(self):
'''Illustrate that we can write directly to stderr'''
sys.stderr.write("this is stderr\n")
class TextRedirector(object):
def __init__(self, widget, tag="stdout"):
self.widget = widget
self.tag = tag
def write(self, str):
self.widget.configure(state="normal")
self.widget.insert("end", str, (self.tag,))
self.widget.configure(state="disabled")
def main():
root = Tk()
#Width X Height
root.geometry("500x300+300+300")
root.update()
root.minsize(400,200)
app = MainWindow(root)
root.mainloop()
if __name__ == '__main__':
main()