-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbrailleGUI.py
More file actions
181 lines (129 loc) · 5.82 KB
/
brailleGUI.py
File metadata and controls
181 lines (129 loc) · 5.82 KB
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
import tkinter as tk
#basically the tkinter CSS
from tkinter import ttk
import brailleConversion
#define a font
LARGE_FONT = ("Verdana", 12)
class printGUI(tk.Tk):
def __init__(self, *args, **kwargs):
tk.Tk.__init__(self, *args, **kwargs)
# choose an icon for the window
tk.Tk.iconbitmap(self, default="ainp.ico")
tk.Tk.wm_title(self, "Braille Printing")
#Set up the container
container = tk.Frame(self)
#if fill space and can expand past that
container.pack(side="top", fill="both", expand= True)
# min, priority
container.grid_rowconfigure(0, weight=1)
container.grid_columnconfigure(0, weight=1)
#contains all the frames, top frame is interacted on
self.frames = {}
for i in (startPage, PageOne, PageTwo):
#start the initial frame
frame = i(container, self)
self.frames[i] = frame
#instead of pack, north south east west
frame.grid(row=0, column=0, sticky="nsew")
#display it
self.show_frame(startPage)
def show_frame(self, cont):
frame = self.frames[cont]
#raises the frame to the front
frame.tkraise()
def qf(param):
#call the text printer on param
param = param.lower()
test = brailleConversion.brailleConverter(param)
brailleConversion.printFormat(test.getCellList())
class startPage(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
label = ttk.Label(self, text= "Braille Printer - Input Printing", font=LARGE_FONT)
#pack to add rather than the grid as small. padding
label.pack(pady=10, padx=10)
frame = tk.Frame(self, height=150, width=1000)
frame.pack()
eLab = tk.Label(self, font=LARGE_FONT, padx=10,
text="Enter the text to be converted: ",
justify= tk.LEFT)
eLab.pack()
entry = tk.Entry(self, bd = 5, font=LARGE_FONT, width= 75)
entry.pack()
frame2 = tk.Frame(self, height=150, width=1000)
frame2.pack()
#calling the function on button call
button1 = ttk.Button(self, text="Print the Text",
command = lambda: qf(entry.get()))
button2 = ttk.Button(self, text="File Printer",
command = lambda: controller.show_frame(PageOne))
#pack the button
button1.pack()
button2.pack(side = tk.RIGHT)
def fileqf(param):
brailleConversion.filePrint(param)
#call the file printer for param
class PageOne(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self,parent)
label = ttk.Label(self, text= "Braille Printer - File Printing", font=LARGE_FONT)
#pack to add rather than the grid as small. padding
label.pack(pady=10, padx=10)
frame = tk.Frame(self, height=150, width=800)
frame.pack()
eLab = tk.Label(self, font=LARGE_FONT, padx=10,
text="Enter file to print: ",
justify= tk.LEFT)
eLab.pack()
entry = tk.Entry(self, bd = 5, font=LARGE_FONT, width= 75)
entry.pack()
frame2 = tk.Frame(self, height=150, width=800)
frame2.pack()
button1 = ttk.Button(self, text="Print the File",
command = lambda: fileqf(entry.get()))
button2 = ttk.Button(self, text="Back to input Printing",
command = lambda: controller.show_frame(startPage))
button1.pack()
button2.pack(side = tk.RIGHT)
class PageTwo(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self,parent)
label = ttk.Label(self, text= "Page 2", font=LARGE_FONT)
#pack to add rather than the grid as small. padding
label.pack(pady=10, padx=10)
frame = tk.Frame(self, height=300, width=800)
frame.pack()
button1 = ttk.Button(self, text="To Page 1",
command = lambda: controller.show_frame(PageOne))
button2 = ttk.Button(self, text="Back to Home",
command = lambda: controller.show_frame(startPage))
button1.pack()
button2.pack()
app = printGUI()
def donothing():
print("nothing")
menubar = tk.Menu(app)
filemenu = tk.Menu(menubar, tearoff=0)
filemenu.add_command(label="New", command=donothing)
filemenu.add_command(label="Open", command=donothing)
filemenu.add_command(label="Save", command=donothing)
filemenu.add_command(label="Save as...", command=donothing)
filemenu.add_command(label="Close", command=donothing)
filemenu.add_separator()
filemenu.add_command(label="Exit", command=app.destroy)
menubar.add_cascade(label="File", menu=filemenu)
editmenu = tk.Menu(menubar, tearoff=0)
editmenu.add_command(label="Undo", command=donothing)
editmenu.add_separator()
editmenu.add_command(label="Cut", command=donothing)
editmenu.add_command(label="Copy", command=donothing)
editmenu.add_command(label="Paste", command=donothing)
editmenu.add_command(label="Delete", command=donothing)
editmenu.add_command(label="Select All", command=donothing)
menubar.add_cascade(label="Edit", menu=editmenu)
helpmenu = tk.Menu(menubar, tearoff=0)
helpmenu.add_command(label="Help Index", command=donothing)
helpmenu.add_command(label="About...", command=donothing)
menubar.add_cascade(label="Help", menu=helpmenu)
app.config(menu=menubar)
app.mainloop()