-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinitGUI.py
85 lines (70 loc) · 3.22 KB
/
initGUI.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
# -*- coding: cp1252 -*-
import Tkinter as tk
import ttk
import Tkconstants, tkFileDialog
import pickle
import tkFileDialog
from FileDialog import LoadFileDialog
import attributes
global data
class FilenameEntry(tk.Frame):
"""a widget for displaying a input edit box and a browser to choose a file """
def __init__(self, master, text):
tk.Frame.__init__(self, master,background='white')
tk.Label(self, text=text,width=15,background='white').pack(side="left")
self.filename = tk.StringVar()
tk.Entry(self, textvariable=self.filename, width=40,background='white').pack(side="left", fill="x",padx=15)
tk.Button(self, text="Browse...",background='black',foreground='white', command=self.choiceDirectory).pack(side="right")
def browse(self):
file = LoadFileDialog(self).go(pattern='*')
if file:
self.filename.set(file)
def choiceDirectory(self):
self.dir = tkFileDialog.askdirectory()
if len(self.dir) > 0:
self.filename.set(self.dir)
def get(self):
return self.filename.get()
def put(self,val):
self.filename.set(val)
class BinSelect(tk.Frame):
"""a widget for displaying a input edit box and a browser to choose a file """
def __init__(self, master, text):
tk.Frame.__init__(self, master,background='white')
tk.Label(self, text=text,width=15,background='white').pack(side="left")
self.select = tk.StringVar()
tk.Entry(self, textvariable=self.select, width=40,background='white').pack(side="left", fill="x",padx=15)
def get(self):
return self.select.get()
def put(self,val):
self.select.set(val)
class Example(tk.Frame):
def __init__(self, parent):
self.create_widgets(parent)
def create_widgets(self, parent):
#frame editation
tk.Frame.__init__(self, parent, bg='white',relief="raised", bd=2,width=100,height=200)
#object creation
self.filename = FilenameEntry(self, "Directory Path: ")
self.binSelection=BinSelect(self, "Discretization Bins: ")
self.buildButton = tk.Button(self,borderwidth=2, text="Build",width=10, command=self.build)
self.clasify = tk.Button(self,borderwidth=2, text="Classify",width=10, command=self.choiceDirectory)
tk.Label(self, text='Naive Bayes Classifier', font=('Helvetica', 12, 'italic bold'),background='black', foreground='white').pack(side="top", expand="no", fill="x")
#objet implemantage
tk.Label(self, text="\nEnter a filename and " + "select an action",background='white').pack(side="top")
self.filename.pack(side="top", fill="x")
self.binSelection.pack(side="top", fill="x")
self.buildButton.pack( padx=3,pady=3)
self.clasify.pack( padx=3,pady=3)
def build(self):
data=attributes.readDATA(str(self.filename.get()))
print(self.filename.get()+"\n"+self.binSelection.get())
def choiceDirectory(self):
self.rep = tkFileDialog.askdirectory()
if len(rep) > 0:
self.resultLabel.configure(text=str(rep))
if __name__ == "__main__":
root = tk.Tk()
root.title("Naive Bayes Classifier")
Example(root).pack(fill="both", expand=True)
root.mainloop()