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 self.columnconfigure(0, weight=1)
163 vscrollbar = tk.Scrollbar(self, orient=tk.VERTICAL)
165 vscrollbar.grid(column=1, row=0, sticky=tk.E+tk.N+tk.S)
167 canvas = tk.Canvas(self, bd=0, highlightthickness=0, yscrollcommand=vscrollbar.set)
169 canvas.grid(column=0, row=0, sticky=tk.W+tk.E)
171 vscrollbar.config(command=canvas.yview)
174 canvas.xview_moveto(0)
175 canvas.yview_moveto(0)
178 self.
interior = interior = tk.Frame(canvas)
180 interior_id = canvas.create_window(0, 0, window=interior, anchor=tk.NW)
185 def _configure_interior(event):
187 size = (interior.winfo_reqwidth(), interior.winfo_reqheight())
188 canvas.config(scrollregion=
"0 0 %s %s" % size)
189 if interior.winfo_reqwidth() != canvas.winfo_width():
191 canvas.config(width=interior.winfo_reqwidth())
192 interior.bind(
'<Configure>', _configure_interior)
194 def _configure_canvas(event):
195 if interior.winfo_reqwidth() != canvas.winfo_width():
197 canvas.itemconfigure(interior_id, width=canvas.winfo_width())
198 canvas.bind(
'<Configure>', _configure_canvas)
205 tk.Frame.__init__(self, master)
207 self.
logger = logging.getLogger(
'SP.ValidationtTkHP')
209 self.grid(sticky=tk.N+tk.S+tk.E+tk.W)
213 self.logger.debug(
"init ValidationTkHP")
219 top=self.winfo_toplevel()
221 top.columnconfigure(0, weight=1)
224 self.columnconfigure(0, weight=1)
235 for key_action, value_action
in self.dict_input.iteritems():
240 label_frame = tk.LabelFrame(self, text=key_action)
242 label_frame.columnconfigure(0, weight=1)
243 label_frame.grid(sticky=tk.E+tk.W, pady=8,padx=5)
253 self.
labf[key_action].grid(sticky=tk.E+tk.W)
266 for key_value, value_value
in value_action.iteritems():
268 print "key_value/ value_value ", key_value, value_value
273 label_values =
' '.join(str(value)
for value
in value_value[
'error'][1])
275 label_error = value_value[
'error'][0]
278 state = value_value[
'repl_add']
295 frame_button = tk.Frame(self)
296 self.
validButton = tk.Button(frame_button, text=
'Valid', command=self.
valid)
299 self.validButton.grid(column=0, row = 0)
300 self.
quitButton = tk.Button(frame_button, text=
'Quit', command=self.quit)
302 self.quitButton.grid(column=1, row=0, sticky=tk.N+tk.S+tk.E+tk.W )
318 for key_action, value_action
in self.dict_choice.iteritems():
320 for value
in self.
dict_choice[key_action].values():
322 if not ((value.get() == 0) | (value.get() == 2)):
327 print "Ok, all selected, Apply the selection"
328 for key_action
in self.dict_choice.keys():
334 print "name, value ", name, value, value.get()
335 self.
dict_input[key_action][name][
'repl_add'] = value.get()
356 labframe.interior.columnconfigure(1, weight=1,minsize=100 )
357 label1 = tk.Label( labframe.interior, text=label_values, fg=color_lab).grid(column=0, row=i+1, sticky=tk.W )
358 label2 = tk.Label( labframe.interior, text=label_error, fg=color_lab).grid(column=1, row=i+1, sticky=tk.W )
363 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)
364 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)
367 if __name__ ==
"__main__":
381 '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]]}},
382 '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]]}}
386 'HistPrice': {0: {
'first_date':
'2015-03-06 00:00:00',
'repl_add': 2,
'first_values': [1425596400, 19.14, 19.16, 18.86, 18.9, 6016200.0],
'last_date':
'2015-02-02 00:00:00',
'error':
'',
'last_values': [1422831600, 19.72, 19.88, 19.59, 19.83, 4641200.0]}},
387 'Div': {0: {
'first_date':
'2015-03-06 00:00:00',
'repl_add': 2,
'first_values': [1425596400, 19.14, 19.16, 18.86, 18.9, 6016200.0],
'last_date':
'2015-02-02 00:00:00',
'error':
'',
'last_values': [1422831600, 19.72, 19.88, 19.59, 19.83, 4641200.0]}}
391 app.master.title(
'Manual Validation')
395 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.