Jan-03-2019, 04:33 PM
why the option Retrieve Report in this code does not record a number in the variable WO-rep after enter it.? like WO entry does.
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 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
#!/usr/bin/python #imports =========================================================================================== from tkinter import * from tkinter import ttk import tkinter as tk import tkinter.messagebox from tkinter.messagebox import showinfo from Test_1 import * from Test_2 import * from Test_3 import * from Test_4 import * from Test_5 import * from Test_6 import * from view_report import * from save_USB import * from print_report import * from help_window import * from about_window import * from fail_database import * from FAQ_window import * from Exit_ATP import * from ending_session import * import os, time # Create instance CDU = tk.Tk() def window(CDU): CDU.title( 'ATA: 34-61-14, Liquid Crystal Display Control Display Unit' ) CDU.wm_attributes( '-type' , 'splash' ) CDU.resizable( False , False ) # prevent the GUI from being resizable, the same for (0,0) f = open ( "report.rep" , 'a+' ) def donothing(): print ( "ok, ok I won't" ) def about(): showinfo(title = 'About' , message = 'Application developed in Python with Tkinter by AQS\nAny problem or suggestion, please contact (941) 726-6632' ) def start_progressbar(): progress_bar.start() def stop_progressbar(): progress_bar.stop() def ending_session(): # print("Work Order: %s\n" % (UUT_wo.get())) os.rename( 'report.rep' , '%s.rep' % (UUT_wo.get())) CDU.destroy() sys.exit() # os.execv('//media/pi/ROOT/GUI_CDU_2__1_2_2019.py', ['']) def run_progressbar(): progress_bar[ "maximum" ] = 100 for i in range [ 101 ]: sleep( 0.05 ) progress_bar[ "value" ] = i #increment progressbar progress_bar.update() #have to call update() in loop progress_bar[ "value" ] = 0 #reset / clear progressbar def retrieve_report(): Label(CDU, text = "WO Report:" ,font = ( 'Arial' , 13 , "bold" ), fg = 'darkblue' ).grid(row = 12 , column = 3 , sticky = 'e' ) WO_rep = tk.Entry(CDU, width = 30 ) WO_rep.grid(row = 12 , column = 4 , sticky = 'w' ) print ( "WO: %s\n" % (UUT_wo.get())) print ( "WO Retrieve: %s\n" % (WO_rep.get())) def test_procedure(): atp = tk.Tk() atp.geometry( '800x480+0+0' ) atp.overrideredirect( 1 ) menubar = Menu(atp) atp.config(menu = menubar) menubar.config(font = ( 'Arial' , 16 , "bold" )) def exit_ATP(): f = open ( 'report.rep' , 'a' ) f.write( "===========================================================\n" ) f.write( "Closing session\n" ) d = datetime.now() f.write( "{:%H:%M:%S}\n" . format (d)) f.write( "\n" ) f.write( " ...Bye\n" ) f.close() atp.destroy() def complete_test(): print ( "Complete Test!" ) f = open ( "report.rep" , 'a' ) f.write( "Developing All Tests\n" ) # create a pulldown menu, and add it to the menu bar atpmenu = Menu(menubar, tearoff = 0 ) atpmenu.configure(font = ( 'Arial' , 16 , "bold" )) atpmenu.add_command(label = "Complete test" , command = complete_test) stepsmenu = Menu(atpmenu, tearoff = 0 ) stepsmenu.configure(font = ( 'Arial' , 16 , "bold" )) stepsmenu.add_command(label = "Test No1" , command = Test_1) stepsmenu.add_command(label = "Test No2" , command = Test_2) stepsmenu.add_command(label = "Test No3" , command = Test_3) stepsmenu.add_command(label = "Test No4" , command = Test_4) stepsmenu.add_command(label = "Test No5" , command = Test_5) stepsmenu.add_command(label = "Test No6" , command = Test_6) atpmenu.add_cascade(label = "Step by step" , menu = stepsmenu) atpmenu.add_separator() atpmenu.add_command(label = "Exit" , command = exit_ATP) menubar.add_cascade(label = "Test Procedure" , menu = atpmenu) reportmenu = Menu(menubar, tearoff = 0 ) reportmenu.configure(font = ( 'Arial' , 16 , "bold" )) reportmenu.add_command(label = "View (display)" , command = view_report) reportmenu.add_separator() reportmenu.add_command(label = "Save to USB" , command = save_USB) reportmenu.add_command(label = "Print..." , command = print_report) menubar.add_cascade(label = "Reports" , menu = reportmenu) helpmenu = Menu(menubar, tearoff = 0 ) helpmenu.configure(font = ( 'Arial' , 16 , "bold" )) helpmenu.add_command(label = "Help..." , command = help_window) helpmenu.add_command(label = "FAQ" , command = FAQ_window) helpmenu.add_command(label = "Failures database" , command = fail_database) helpmenu.add_separator() helpmenu.add_command(label = "About..." , command = about_window) menubar.add_cascade(label = "Help" , menu = helpmenu) # display the menu atp.config(menu = menubar) print ( "===========================================================" ) print ( "Work Order: %s\nUUT_PN: %s\nUUT SN:%s\nTechnician:%s" % (UUT_wo.get(), UUT_pn.get(), UUT_sn.get(), WO_tech.get())) if radVar.get() = = 1 : print ( "Work Requested: Bench Check" ) elif radVar.get() = = 2 : print ( "Work Requested: Repair" ) elif radVar.get() = = 3 : print ( "Work Requested: Overhaul" ) print ( "===========================================================" ) print ( "Acceptance Test Procedure" ) print ( "Liquid Crystal Display Control Display Unit" ) print ( "174101 Model 2584" ) print ( "ATA 34-61-14, ATLAS Test Specification 552353-10-01" ) print ( "===========================================================" ) from datetime import datetime d = datetime.now() print ( "{:%Y-%m-%d %H:%M:%S}" . format (d)) f = open ( "report.rep" , 'a' ) f.write( "Acceptance Test Procedure\n" ) f.write( "Liquid Crystal Display Control Display Unit\n" ) f.write( "174101 Model 2584\n" ) f.write( "ATA 34-61-14, ATLAS Test Specification 552353-10-01\n" ) f.write( "Date:" ) f.write( "{:%m-%d-%Y %H:%M:%S}\n" . format (d)) f.write( "===========================================================\n" ) f.write( 'WO:' + UUT_wo.get()) f.write( "\nUUT_PN: %s\nUUT SN:%s\nTechnician:%s" % (UUT_pn.get(), UUT_sn.get(), WO_tech.get())) f.write( "\n===========================================================\n" ) f = open ( "report.rep" , 'a' ) #========================================================================================== #window(CDU)=========================================================================================== # Add a title, size and disabling resize CDU.attributes( '-type' , 'dock' ) CDU.geometry( '800x480+0+0' ) CDU.title( 'ATA: 34-61-14, Liquid Crystal Display Control Display Unit' ) # Adding Labels and Entries widgets ======================================================================= Label(CDU, text = "UUT PN:" ,font = ( 'Arial' , 16 , "bold" ), fg = 'darkblue' ).grid(row = 1 , column = 3 , sticky = 'e' ) Label(CDU, text = "Work Order:" ,font = ( 'Arial' , 16 , "bold" ), fg = 'darkblue' ).grid(row = 2 , column = 3 , sticky = 'e' ) Label(CDU, text = "UUT SN:" ,font = ( 'Arial' , 16 , "bold" ), fg = 'darkblue' ).grid(row = 3 , column = 3 , sticky = 'e' ) Label(CDU, text = "Technician:" ,font = ( 'Arial' , 16 , "bold" ), fg = 'darkblue' ).grid(row = 5 , column = 3 , sticky = 'e' ) UUT_pn = tk.Entry(CDU, width = 30 ) UUT_wo = tk.Entry(CDU, width = 30 ) UUT_sn = tk.Entry(CDU, width = 30 ) WO_tech = tk.Entry(CDU, width = 18 ) #WO_retrieve = tk.Entry(CDU, width=30) UUT_pn.grid(row = 1 , column = 4 , sticky = 'e' ) UUT_wo.grid(row = 2 , column = 4 , sticky = 'e' ) UUT_sn.grid(row = 3 , column = 4 , sticky = 'e' ) WO_tech.grid(row = 5 , column = 4 , sticky = 'w' ) CDU.focus_force() # Radiobuttons =========================================================================================== # Radiobuttons Callback def radCall(): radSel = radVar.get() if radSel = = 1 : CDU.configure() elif radSel = = 2 : CDU.configure() elif radSel = = 3 : CDU.configure() # Create three Radiobuttons using one variable radVar = IntVar() Label(CDU, text = "Work Requested:" ,font = ( 'Arial' , 16 , "bold" ), fg = 'darkblue' ). grid(row = 7 , column = 3 , sticky = 'w' ) benchtest = Radiobutton(CDU, text = "Bench Test" , font = ( 'Arial' , 16 , "bold" ),variable = radVar, value = 1 , command = radCall) benchtest.grid(row = 7 , column = 4 , columnspan = 2 , sticky = 'w' ) repair = Radiobutton(CDU, text = "Repair" , font = ( 'Arial' , 16 , "bold" ), variable = radVar, value = 2 , command = radCall) repair.grid(row = 8 , column = 4 , columnspan = 2 , sticky = 'w' ) overhaul = Radiobutton(CDU, text = "Overhaul" , font = ( 'Arial' , 16 , "bold" ), variable = radVar, value = 3 , command = radCall) overhaul.grid(row = 9 , column = 4 , columnspan = 4 , sticky = 'w' ) # Canvas ================================================================================================= canvas_width = 291 canvas_height = 387 canvas = Canvas(CDU, width = canvas_width, height = canvas_height) canvas.grid(row = 1 , column = 0 , rowspan = 11 , columnspan = 2 , sticky = 'n' ) img = PhotoImage( file = "174101_2.gif" ) canvas.create_image( 20 , 20 , anchor = NW, image = img) Label(CDU, text = "").grid(row = 12 , column = 18 , sticky = 'e' ) # Functions =============================================================================================== Button(CDU, text = " Test Procedure " ,font = ( 'Arial' , 16 , "bold" ), command = test_procedure).grid(row = 10 , column = 4 , sticky = 'e' , padx = 2 ) Button(CDU, text = " Retrieve Report " ,font = ( 'Arial' , 16 , "bold" ), command = retrieve_report).grid(row = 12 , column = 1 , sticky = 'e' ) Button(CDU, text = " About..." ,font = ( 'Arial' , 16 , "bold" ), command = about).grid(row = 15 , column = 1 , sticky = 'e' , padx = 2 ) Button(CDU, text = " Close Session " ,font = ( 'Arial' , 16 , "bold" ), command = ending_session).grid(row = 15 , column = 4 , sticky = 'e' , padx = 2 ) window(CDU) #========================================================================================== #Start GUI CDU.mainloop( ) |