20 class ValidationTkinter(tk.Frame):
23 tk.Frame.__init__(self, master)
26 self.grid(sticky=tk.N+tk.S+tk.E+tk.W)
35 top=self.winfo_toplevel()
36 top.columnconfigure(0, weight=1)
39 self.columnconfigure(0, weight=1)
49 for key_action, value_action
in self.dict_input.iteritems():
56 labf[key_action] = tk.LabelFrame(self, text=key_action)
58 labf[key_action].grid( sticky=tk.E+tk.W, pady=8,padx=5 )
67 for key_value, value_value
in value_action.iteritems():
70 old_value = value_value[
'xml_value']
71 new_value = value_value[
'new_value']
72 state = value_value[
'repl_add']
78 frame_button = tk.Frame(self)
82 self.validButton.grid(column=0, row=0, sticky=tk.E, pady=5)
84 self.
quitButton = tk.Button(frame_button, text=
'Quit', command=self.quit)
85 self.quitButton.grid(column=1, row=0, sticky=tk.W, pady=5)
95 for key_action, value_action
in self.dict_choice.iteritems():
98 if not ((value.get() == 0) | (value.get() == 2)):
100 self.
popupmsg(
"All entries must be selected as Accepted or Rejected to continue,\nor press Quit to validate the default")
104 for key_action
in self.dict_choice.keys():
112 self.
dict_input[key_action][name][
'repl_add'] = value.get()
127 labframe.columnconfigure(2, weight=1,minsize=100 )
128 tk.Label( labframe, text=name).grid(column=0, row=i, sticky=tk.W, padx=5, pady=2)
129 tk.Label( labframe, text=str(old_value)).grid(column=1, row=i, sticky=tk.W, padx=5, pady=2)
131 tk.Label( labframe, text=str(new_value)).grid(column=2, row=i, sticky=tk.W, padx=5, pady=2)
133 tk.Radiobutton( labframe, text=
'Rej.', variable=var, value=0).grid(column=3, row=i, sticky=tk.E)
134 tk.Radiobutton( labframe, text=
'Acc.', variable=var, value=2).grid(column=4, row=i, sticky=tk.E)
139 popup = tk.Toplevel(takefocus=
True)
140 popup.title(
'Message')
141 tk.Label( popup, text=msg).grid( padx=10, pady=10)
142 tk.Button(popup, text=
'Ok', command=popup.quit).grid( pady=10 )
150 """A pure Tkinter scrollable frame that actually works!
151 * Use the 'interior' attribute to place widgets inside the scrollable frame
152 * Construct and pack/place/grid normally
153 * This frame only allows vertical scrolling
157 tk.Frame.__init__(self, parent, *args, **kw)
160 vscrollbar = tk.Scrollbar(self, orient=tk.VERTICAL)
161 vscrollbar.pack(fill=Y, side=RIGHT, expand=FALSE)
162 canvas = tk.Canvas(self, bd=0, highlightthickness=0,
163 yscrollcommand=vscrollbar.set)
164 canvas.pack(side=LEFT, fill=BOTH, expand=TRUE)
165 vscrollbar.config(command=canvas.yview)
168 canvas.xview_moveto(0)
169 canvas.yview_moveto(0)
172 self.
interior = interior = tk.Frame(canvas)
173 interior_id = canvas.create_window(0, 0, window=interior, anchor=tk.NW)
177 def _configure_interior(event):
179 size = (interior.winfo_reqwidth(), interior.winfo_reqheight())
180 canvas.config(scrollregion=
"0 0 %s %s" % size)
181 if interior.winfo_reqwidth() != canvas.winfo_width():
183 canvas.config(width=interior.winfo_reqwidth())
184 interior.bind(
'<Configure>', _configure_interior)
186 def _configure_canvas(event):
187 if interior.winfo_reqwidth() != canvas.winfo_width():
189 canvas.itemconfigure(interior_id, width=canvas.winfo_width())
190 canvas.bind(
'<Configure>', _configure_canvas)
198 tk.Frame.__init__(self, master)
200 self.
logger = logging.getLogger(
'SP.ValidationtTkHP')
202 self.grid(sticky=tk.N+tk.S+tk.E+tk.W)
206 self.logger.debug(
"init ValidationTkHP")
212 top=self.winfo_toplevel()
214 top.columnconfigure(0, weight=1)
217 self.columnconfigure(0, weight=1)
228 for key_action, value_action
in self.dict_input.iteritems():
233 label_frame = tk.LabelFrame(self, text=key_action)
235 label_frame.columnconfigure(0, weight=1)
236 label_frame.grid(sticky=tk.E+tk.W, pady=8,padx=5)
247 self.
labf[key_action].grid(sticky=tk.E+tk.W)
260 for key_value, value_value
in value_action.iteritems():
262 print "key_value/ value_value ", key_value, value_value
267 label_values =
' '.join(str(value)
for value
in value_value[
'error'][1])
269 label_error = value_value[
'error'][0]
272 state = value_value[
'repl_add']
286 frame_button = tk.Frame(self)
290 self.validButton.grid(column=0, row = 0)
291 self.
quitButton = tk.Button(frame_button, text=
'Quit', command=self.quit)
293 self.quitButton.grid(column=1, row=0, sticky=tk.N+tk.S+tk.E+tk.W )
309 for key_action, value_action
in self.dict_choice.iteritems():
311 for value
in self.
dict_choice[key_action].values():
313 if not ((value.get() == 0) | (value.get() == 2)):
318 print "Ok, all selected, Apply the selection"
319 for key_action
in self.dict_choice.keys():
326 self.
dict_input[key_action][name][
'repl_add'] = value.get()
347 labframe.interior.columnconfigure(1, weight=1,minsize=100 )
348 label1 = tk.Label( labframe.interior, text=label_values, fg=color_lab).grid(column=0, row=i+1, sticky=tk.W )
349 label2 = tk.Label( labframe.interior, text=label_error, fg=color_lab).grid(column=1, row=i+1, sticky=tk.W )
354 rb1 = tk.Radiobutton( labframe.interior, text=
'Rej.', variable=var, value=0).grid(column=3, row=i+1, sticky=tk.N+tk.S+tk.E+tk.W)
355 rb2 = tk.Radiobutton( labframe.interior, text=
'Acc..', variable=var, value=2).grid(column=4, row=i+1, sticky=tk.N+tk.S+tk.E+tk.W)
358 if __name__ ==
"__main__":
379 'HistPrice': {0: {
'repl_add': 0,
'error': [
'volume 0', [1425510000, 4929.04, 4974.64, 4926.09, 4963.51, 0.0]]}, 1: {
'repl_add': 0,
'error': [
'volume 0', [1425423600, 4882.94, 4917.35, 4856.14, 4917.35, 0.0]]}, 2: {
'repl_add': 2,
'error': [
'', [1425337200, 4922.43, 4936.47, 4863.92, 4869.25, 116619800.0]]}, 3: {
'repl_add': 2,
'error': [
'', [1425250800, 4937.43, 4950.59, 4900.11, 4917.32, 149942900.0]]}, 4: {
'repl_add': 2,
'error': [
'', [1424991600, 4905.77, 4951.48, 4903.09, 4951.48, 120717900.0]]}, 5: {
'repl_add': 2,
'error': [
'', [1424905200, 4884.89, 4910.62, 4877.24, 4910.62, 105228900.0]]}, 6: {
'repl_add': 2,
'error': [
'', [1424818800, 4885.0, 4894.6, 4863.22, 4882.22, 117214700.0]]}, 7: {
'repl_add': 2,
'error': [
'', [1424732400, 4865.68, 4899.52, 4843.96, 4886.44, 106329800.0]]}, 8: {
'repl_add': 2,
'error': [
'', [1424646000, 4872.13, 4875.97, 4832.36, 4862.3, 102128000.0]]}, 9: {
'repl_add': 2,
'error': [
'', [1424386800, 4821.38, 4837.93, 4780.81, 4830.9, 140055500.0]]}, 10: {
'repl_add': 0,
'error': [
'volume 0', [1424300400, 4788.4, 4841.69, 4770.17, 4833.28, 0.0]]}},
380 'Div': {0: {
'repl_add': 0,
'error': [
'volume 0', [1425510000, 4929.04, 4974.64, 4926.09, 4963.51, 0.0]]}, 1: {
'repl_add': 0,
'error': [
'volume 0', [1425423600, 4882.94, 4917.35, 4856.14, 4917.35, 0.0]]}, 2: {
'repl_add': 2,
'error': [
'', [1425337200, 4922.43, 4936.47, 4863.92, 4869.25, 116619800.0]]}, 3: {
'repl_add': 2,
'error': [
'', [1425250800, 4937.43, 4950.59, 4900.11, 4917.32, 149942900.0]]}, 4: {
'repl_add': 2,
'error': [
'', [1424991600, 4905.77, 4951.48, 4903.09, 4951.48, 120717900.0]]}, 5: {
'repl_add': 2,
'error': [
'', [1424905200, 4884.89, 4910.62, 4877.24, 4910.62, 105228900.0]]}, 6: {
'repl_add': 2,
'error': [
'', [1424818800, 4885.0, 4894.6, 4863.22, 4882.22, 117214700.0]]}, 7: {
'repl_add': 2,
'error': [
'', [1424732400, 4865.68, 4899.52, 4843.96, 4886.44, 106329800.0]]}, 8: {
'repl_add': 2,
'error': [
'', [1424646000, 4872.13, 4875.97, 4832.36, 4862.3, 102128000.0]]}, 9: {
'repl_add': 2,
'error': [
'', [1424386800, 4821.38, 4837.93, 4780.81, 4830.9, 140055500.0]]}, 10: {
'repl_add': 0,
'error': [
'volume 0', [1424300400, 4788.4, 4841.69, 4770.17, 4833.28, 0.0]]}}
383 app.master.title(
'Manual Validation')
387 print "\n== Test Output ", test
def create_one_input_xml
Fill the frame specific to xml data: Info / Fundamental.
A pure Tkinter scrollable frame that actually works!.
def valid
Check Validation is valid (all radiobuttons selected)
def valid
Check all radio buttons have been selected and update repl_add entry with _var_radiob.
Small GUI, specific for dealing with list_csv.
def popupmsg
Message indicating that some entries have not been validated.