Commit daf28f9fcb4c12384494cebce740a90ff30d5ebd

Authored by Brice Colombier
1 parent 140b94d3ed
Exists in master

Tabbed prototype working

Showing 4 changed files with 158 additions and 172 deletions

1   -# Author: Brice Colombier
2   -# Laboratoire Hubert Curien
3   -# 42000 Saint-Etienne - France
4   -# Contact: b.colombier@univ-st-etienne.fr
5   -# Project: Demonstrator
6   -# File: app.py
7   -# Date: 2016-10-13
8   -
9   -from Tkinter import *
10   -from ttk import *
11   -import tkFileDialog
12   -import random
13   -
14   -import build_menu
15   -import declare_initialize_variables
16   -import declare_pack_frames
17   -import add_frame_elements
18   -
19   -
20   -class App:
21   -
22   - """Main class for the demonstrator GUI app"""
23   -
24   - def __init__(self, master):
25   -
26   - s = Style()
27   - s.configure("Green.TLabelframe.Label",
28   - foreground="darkgreen")
29   -
30   - master.maxsize(width=770, height=480)
31   - master.minsize(width=770, height=480)
32   - master.resizable(width=False, height=False)
33   - master.title("Crazy logic modifier")
34   -
35   - # Menu bar
36   - build_menu.build_menu(self, master)
37   -
38   - # Variables
39   - declare_initialize_variables.declare_initialize_variables(self)
40   -
41   - # Frames
42   - declare_pack_frames.declare_pack_frames(self, master)
43   -
44   - # Frame elements
45   - add_frame_elements.add_frame_elements(self)
46   -
47   - def open_file(self):
48   -
49   - ftypes = [("BENCH files", ".txt"),
50   - ("BLIF files", ".blif"),
51   - ("SLIF files", ".slif"),
52   - ("EDIF files", ".edf"),
53   - ("Xilinx EDIF files", ".edf"),
54   - ("RTL VHDL files", ".vhd"),
55   - ("Structural VHDL files", ".vhd"),
56   - ("RTL Verilog files", ".v"),
57   - ("Structural Verilog files", ".v")]
58   -
59   - self.filepath.set(tkFileDialog.askopenfilename(filetypes=ftypes))
60   - if self.filepath.get():
61   - self.filename.set(self.filepath.get().split("/")[-1])
62   -
63   - def round_masking(self, _): # Dummy second argument
64   - self.masking_overhead.set(int(round(self.masking_overhead.get())))
65   -
66   - def round_locking(self, _): # Dummy second argument
67   - self.locking_overhead.set(int(round(self.locking_overhead.get())))
68   -
69   - def get_PUF_reference_response(self):
70   - self.PUF_reference_response.set(hex(random.randint(0, 2**256))[2:-1])
71   - self.PUF_reference_response.set(" ".join(self.PUF_reference_response.get()[i:i+4] for i in range(0, len(self.PUF_reference_response.get()), 4)))
72   - # To be continued
73   - self.reconciliation_performed.set(False)
74   - self.reference_response_available.set(True)
75   -
76   - def check_reference_response_available(self, a, b, c): # a, b, c dummy variables
77   - if self.reference_response_available.get():
78   - self.perform_reconciliation_button.configure(state="normal")
79   - self.reconciliation_parameter_initial_block_size_spinbox.configure(state="normal")
80   - self.reconciliation_parameter_number_of_passes_spinbox.configure(state="normal")
81   -
82   - def perform_reconciliation(self):
83   - # To be continued
84   - self.reconciliation_performed.set(True)
85   -
86   - def check_reconciliation_performed(self, a, b, c):
87   - if self.reconciliation_performed.get():
88   - self.masking_button.configure(state="normal")
89   - self.locking_button.configure(state="normal")
90   - self.masking_overhead_spinbox.configure(state="normal")
91   - self.locking_overhead_spinbox.configure(state="normal")
92   - self.modify_design_button.configure(state="normal")
93   - else:
94   - self.masking_button.configure(state="disabled")
95   - self.locking_button.configure(state="disabled")
96   - self.masking_overhead_spinbox.configure(state="disabled")
97   - self.locking_overhead_spinbox.configure(state="disabled")
98   - self.modify_design_button.configure(state="disabled")
99   -
100   - def pop_up_about(self):
101   - self.top = Toplevel()
102   - self.top.title("About")
103   -
104   - self.msg = Label(self.top, text="About")
105   - self.msg.pack()
106   -
107   - def pop_up_license(self):
108   - self.top = Toplevel()
109   - self.top.title("License")
110   - try:
111   - self.License_file = open("LICENSE.txt", 'r')
112   - self.License_text = self.License_file.read()
113   - self.License_file.close()
114   - except:
115   - self.License_text = "Cannot find LICENSE.txt"
116   - self.msg = Label(self.top, text=self.License_text, background="white")
117   - self.msg.pack()
118   -
119   - def connect(self):
120   - self.com_port_button_connect.configure(state=DISABLED)
121   - self.com_port_button_disconnect.configure(state=NORMAL)
122   - self.connected.set(True)
123   - self.com_port_status_text.configure(text="Connected",
124   - foreground="darkgreen")
125   -
126   - def disconnect(self):
127   - self.com_port_button_disconnect.configure(state=DISABLED)
128   - self.com_port_button_connect.configure(state=NORMAL)
129   - self.connected.set(False)
130   - self.com_port_status_text.configure(text="Disconnected",
131   - foreground="red")
132   -
133   -
134   -def every_second():
135   - if str(app.com_port_status_text.cget("foreground")) == "red":
136   - app.com_port_status_text.configure(foreground="black")
137   - elif str(app.com_port_status_text.cget("foreground")) == "black":
138   - app.com_port_status_text.configure(foreground="red")
139   - fenetre.after(1000, every_second)
140   -
141   -if __name__ == "__main__":
142   -
143   - fenetre = Tk()
144   -
145   - app = App(fenetre)
146   -
147   - fenetre.after(1000, every_second)
148   - fenetre.mainloop()
149   -
GUI/build_menu.py View file @ daf28f9
... ... @@ -17,9 +17,6 @@
17 17 self.menubar = Menu(master)
18 18  
19 19 self.filemenu = Menu(self.menubar, tearoff=0)
20   - self.filemenu.add_command(label="Open")
21   - self.filemenu.add_command(label="Save")
22   - self.filemenu.add_separator()
23 20 self.filemenu.add_command(label="Exit", command=master.quit)
24 21 self.menubar.add_cascade(label="File", menu=self.filemenu)
25 22  
GUI/declare_pack_frames.py View file @ daf28f9
... ... @@ -10,30 +10,30 @@
10 10 from ttk import *
11 11  
12 12  
13   -def declare_pack_frames(self, master):
  13 +def declare_pack_frames(self, tab_logic_modifier, tab_activation):
14 14  
15 15 """Declare the main GUI frames and pack them"""
16 16  
17   - self.motherboard_frame = LabelFrame(master, text="HECTOR motherboard")
  17 + self.motherboard_frame = LabelFrame(tab_activation, text="HECTOR motherboard")
18 18 self.motherboard_frame.pack(side=TOP, fill=X)
19 19  
20   - self.daughterboard_frame = LabelFrame(master, text="HECTOR daughterboard")
  20 + self.daughterboard_frame = LabelFrame(tab_activation, text="HECTOR daughterboard")
21 21 self.daughterboard_frame.pack(side=TOP, fill=X)
22 22  
23   - self.PUF_frame = LabelFrame(master, text="PUF")
  23 + self.PUF_frame = LabelFrame(tab_activation, text="PUF")
24 24 self.PUF_frame.pack(side=TOP, fill=X)
25 25  
26   - self.file_frame = LabelFrame(master, text="Current design")
  26 + self.file_frame = LabelFrame(tab_logic_modifier, text="Current design")
27 27 self.file_frame.pack(side=TOP, fill=X)
28 28  
29   - self.modify_design_frame = LabelFrame(master, text="Modify design")
  29 + self.modify_design_frame = LabelFrame(tab_logic_modifier, text="Modify design")
30 30 self.modify_design_frame.pack(fill="both", expand="yes")
31 31  
32   - self.generate_modified_design_frame = LabelFrame(master,
  32 + self.generate_modified_design_frame = LabelFrame(tab_logic_modifier,
33 33 text="Generate modified design")
34 34 self.generate_modified_design_frame.pack(fill="both", expand="yes")
35 35  
36   - self.program_daughterboard_frame = LabelFrame(master,
  36 + self.program_daughterboard_frame = LabelFrame(tab_activation,
37 37 text="Program HECTOR daughterboard")
38 38 self.program_daughterboard_frame.pack(fill="both", expand="yes")
GUI/tabbed_app.py View file @ daf28f9
  1 +# Author: Brice Colombier
  2 +# Laboratoire Hubert Curien
  3 +# 42000 Saint-Etienne - France
  4 +# Contact: b.colombier@univ-st-etienne.fr
  5 +# Project: Demonstrator
  6 +# File: app.py
  7 +# Date: 2016-10-13
  8 +
1 9 from Tkinter import *
2 10 from ttk import *
  11 +import tkFileDialog
  12 +import random
3 13  
4   -root = Tk()
5   -note = Notebook(root)
  14 +import build_menu
  15 +import declare_initialize_variables
  16 +import declare_pack_frames
  17 +import add_frame_elements
6 18  
7   -tab1 = Frame(note)
8   -tab2 = Frame(note)
9   -tab3 = Frame(note)
10   -Button(tab1, text='Exit', command=root.destroy).pack(padx=100, pady=100)
11 19  
12   -note.add(tab1, text = "Tab One", compound=TOP)
13   -note.add(tab2, text = "Tab Two")
14   -note.add(tab3, text = "Tab Three")
15   -note.pack()
16   -root.mainloop()
17   -exit()
  20 +class App:
  21 +
  22 + """Main class for the demonstrator GUI app"""
  23 +
  24 + def __init__(self, master):
  25 +
  26 + s = Style()
  27 + s.configure("Green.TLabelframe.Label",
  28 + foreground="darkgreen")
  29 +
  30 + master.maxsize(width=770, height=480)
  31 + master.minsize(width=770, height=480)
  32 + master.resizable(width=False, height=False)
  33 + master.title("Crazy logic modifier")
  34 +
  35 + # Tabs bar
  36 + note = Notebook(master)
  37 + tab_logic_modifier = Frame(note)
  38 + note.add(tab_logic_modifier, text="Logic modifier", compound=TOP)
  39 + tab_activation = Frame(note)
  40 + note.add(tab_activation, text="Activation")
  41 + note.pack()
  42 + # Menu bar
  43 + build_menu.build_menu(self, master)
  44 +
  45 + # Variables
  46 + declare_initialize_variables.declare_initialize_variables(self)
  47 +
  48 + # Frames
  49 + declare_pack_frames.declare_pack_frames(self, tab_logic_modifier, tab_activation)
  50 +
  51 + # Frame elements
  52 + add_frame_elements.add_frame_elements(self)
  53 +
  54 + def open_file(self):
  55 +
  56 + ftypes = [("BENCH files", ".txt"),
  57 + ("BLIF files", ".blif"),
  58 + ("SLIF files", ".slif"),
  59 + ("EDIF files", ".edf"),
  60 + ("Xilinx EDIF files", ".edf"),
  61 + ("RTL VHDL files", ".vhd"),
  62 + ("Structural VHDL files", ".vhd"),
  63 + ("RTL Verilog files", ".v"),
  64 + ("Structural Verilog files", ".v")]
  65 +
  66 + self.filepath.set(tkFileDialog.askopenfilename(filetypes=ftypes))
  67 + if self.filepath.get():
  68 + self.filename.set(self.filepath.get().split("/")[-1])
  69 +
  70 + def round_masking(self, _): # Dummy second argument
  71 + self.masking_overhead.set(int(round(self.masking_overhead.get())))
  72 +
  73 + def round_locking(self, _): # Dummy second argument
  74 + self.locking_overhead.set(int(round(self.locking_overhead.get())))
  75 +
  76 + def get_PUF_reference_response(self):
  77 + self.PUF_reference_response.set(hex(random.randint(0, 2**256))[2:-1])
  78 + self.PUF_reference_response.set(" ".join(self.PUF_reference_response.get()[i:i+4] for i in range(0, len(self.PUF_reference_response.get()), 4)))
  79 + # To be continued
  80 + self.reconciliation_performed.set(False)
  81 + self.reference_response_available.set(True)
  82 +
  83 + def check_reference_response_available(self, a, b, c): # a, b, c dummy variables
  84 + if self.reference_response_available.get():
  85 + self.perform_reconciliation_button.configure(state="normal")
  86 + self.reconciliation_parameter_initial_block_size_spinbox.configure(state="normal")
  87 + self.reconciliation_parameter_number_of_passes_spinbox.configure(state="normal")
  88 +
  89 + def perform_reconciliation(self):
  90 + # To be continued
  91 + self.reconciliation_performed.set(True)
  92 +
  93 + def check_reconciliation_performed(self, a, b, c):
  94 + if self.reconciliation_performed.get():
  95 + self.masking_button.configure(state="normal")
  96 + self.locking_button.configure(state="normal")
  97 + self.masking_overhead_spinbox.configure(state="normal")
  98 + self.locking_overhead_spinbox.configure(state="normal")
  99 + self.modify_design_button.configure(state="normal")
  100 + else:
  101 + self.masking_button.configure(state="disabled")
  102 + self.locking_button.configure(state="disabled")
  103 + self.masking_overhead_spinbox.configure(state="disabled")
  104 + self.locking_overhead_spinbox.configure(state="disabled")
  105 + self.modify_design_button.configure(state="disabled")
  106 +
  107 + def pop_up_about(self):
  108 + self.top = Toplevel()
  109 + self.top.title("About")
  110 +
  111 + self.msg = Label(self.top, text="About")
  112 + self.msg.pack()
  113 +
  114 + def pop_up_license(self):
  115 + self.top = Toplevel()
  116 + self.top.title("License")
  117 + try:
  118 + self.License_file = open("LICENSE.txt", 'r')
  119 + self.License_text = self.License_file.read()
  120 + self.License_file.close()
  121 + except:
  122 + self.License_text = "Cannot find LICENSE.txt"
  123 + self.msg = Label(self.top, text=self.License_text, background="white")
  124 + self.msg.pack()
  125 +
  126 + def connect(self):
  127 + self.com_port_button_connect.configure(state=DISABLED)
  128 + self.com_port_button_disconnect.configure(state=NORMAL)
  129 + self.connected.set(True)
  130 + self.com_port_status_text.configure(text="Connected",
  131 + foreground="darkgreen")
  132 +
  133 + def disconnect(self):
  134 + self.com_port_button_disconnect.configure(state=DISABLED)
  135 + self.com_port_button_connect.configure(state=NORMAL)
  136 + self.connected.set(False)
  137 + self.com_port_status_text.configure(text="Disconnected",
  138 + foreground="red")
  139 +
  140 +
  141 +def every_second():
  142 + if str(app.com_port_status_text.cget("foreground")) == "red":
  143 + app.com_port_status_text.configure(foreground="black")
  144 + elif str(app.com_port_status_text.cget("foreground")) == "black":
  145 + app.com_port_status_text.configure(foreground="red")
  146 + fenetre.after(1000, every_second)
  147 +
  148 +if __name__ == "__main__":
  149 +
  150 + fenetre = Tk()
  151 +
  152 + app = App(fenetre)
  153 +
  154 + fenetre.after(1000, every_second)
  155 + fenetre.mainloop()