Python is generally used to write pure scripts, but it can also be used to produce products with views, such as web pages and client tools. The advantage of making a tool is that it can be used by people who don’t know the code, and there is no need to modify the parameters in the code. If it is used frequently, it can even save time compared to pure scripts; the biggest advantage is that it can run on any It can also run on any computer that does not have python installed on the computer that installs the python third-party package in the script. Below is the source code of the first test tool I made with tkinter a long time ago.
This part is tkinter code, run the code directly, you can pop up the interface.
1 # -*- coding: utf-8 -*- 2 from Tkinter import * 3 from PIL import Image, ImageTk 4 import urllib 5 import urllib2 6 #import http.cookiejar 7 import base64 8 import cookielib,time,sys 9 #import mysql.connector 10 import MySQLdb 11 12 13 14 15 class post(): ##########This cookie method is slightly more complicated, the script is written too early, it is urllib2, using requests will simplify a lot 16 def __init__(self, values): 17 self. values=values 18 def qinqiu(self): 19 # Get the cookie from the file and visit 20 cookie = cookielib. MozillaCookieJar() 21 #Read the cookie content from the file to the variable 22 cookie.load('cookie.txt', ignore_discard=True, ignore_expires=True) 23 #Use the build_opener method of urllib2 to create an opener 24 #print 'saddsafsdafdsf', cookie 25 opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookie)) 26 27 url ="http://www.xxxx.cn/test/yuanzhao/controls/api.php" 28 29 data = base64.b64encode(self.values) #######Depending on the situation, the interface parameters of general companies do not need base64 encoding 30 #print data# 31 req = urllib2. Request(url, data) 32 response = opener. open(req) 33 the_page = response. read() 34 print the_page 35 return the_page 36 37 38 class select(): #### You can directly request some specific interfaces without using mysql, and you can also take out the return value we need. 39 def __init__(self,sql): 40 self. sql=sql 41 def chaxun(self): 42 conn=MySQLdb.connect(host='112.xx.xx.xx', user='root', passwd='**************', db ='ld_logistic_sys_******',port=3307) 43 cur = conn. cursor() 44 try: 45 #sql='select settlement_ID, payableAccount from bus_waybill, bus_waybill_fee where bus_waybill.waybillCode=bus_waybill_fee.waybillCode and bus_waybill.waybillCode=' + str(yundanhao) 46 sql=self.sql 47 cur. execute(sql) 48 data = cur. fetchall() 49 except: 50 print u'not found' 51 52 53 #print data 54 cur. close() 55 conn. close() 56 return data 57 58 59 def tanchu(str1,height): ##### pop up from the tkinter main interface 60 top = Toplevel() 61 h=int(height) 62 top.title('Prompt') 63 Label(top, text=str1, fg='yellow', bg='red').pack() 64 top.geometry('400x' + str(h) + ' + 700 + 500') 65 returns 66 67 #tanchu('hello',500) 68 69 70 71 72 def fun2(): 73 74 ydgs1 = ydgs. get() 75 if ydgs1=='': 76 print u'Please fill in the shipment number' 77 tanchu(u'Please fill in the shipping number',100) 78 returns 79 print "Create %s waybills"%(ydgs1) 80 81 if ydnx.get()==u'cargo consignment document': 82 ydnx1=0 83 elif ydnx.get()==u'hoisting accept bill': 84 ydnx1=1 85 else: 86 ydnx1=2 87 #print ydnx1 88 89 90 if jsfs.get()==u'pay now': 91 jsfs1=0 92 elif jsfs.get()==u'withdraw': 93 jsfs1=1 94 elif jsfs.get()==u'receipt payment': 95 jsfs1=2 96 else: 97 jsfs1=3 98 #print jsfs1 99 100 yundanneixin=ydnx1 101 jiesuanfangshi=jsfs1 102 yundangeshu=ydgs1 103 fhkhid1 = fhkhid. get() 104 str1='Created waybill' 105 for i in range (int(yundangeshu)): 106 #Create waybill 107 108 values = '{"opFrom":"1","userName":"testy","psd_v":"0","waybillType":" ' + str(yundanneixin) + '","originatingStation":"25","destinationStation":"27","goodsNO":"The name is very long Item No. a1",\ 109 "deliveClientName":"' + str(fhkhid1) + '","deliveClientPhone":"13156983698","deliveClientAdd":"Detailed address of financial shipping customer 1 Detailed address of financial shipping customer 1","receiptClientName":"101",\ 110 "receiptClientPhone":"13698563214","receiptClientAdd":"Detailed address of financial receipt client 2 Detailed address of financial receipt client 2 Detailed address of financial receipt client 2"," settleAccountType":"' + str(jiesuanfangshi) + '","receivable":40,\ 111 "buisnessList":[{"buisnessType":"Business Type 1 Business Type 1","articleName":"Long article name long article name long article name long","articleNO": "Long product number long product number long product number long","count":"1","weight":"1.11","volume":"1.12" ,\ 112 "pack":"long package 1 long package 1 long package","freight":"1.13","handlingCharges":"1.14","transportationCharges": "1.15","delayUnloadCharges":"2","advanceCharges":"3",\ 113 "other":"5.22","tax":"12.32%","paymentDay":"165 days a year, 12 months"},{"buisnessType\ ":"Business Type 2 Business Type 2","articleName":"Long 2 Long Article Name Long Article Name Long","articleNO":"Long No. 2 Long Article No. Long No. 2 Long ",\ 114 "count":"2","weight":"11","volume":"","pack":"","freight ":"5","handlingCharges":"",\ 115 "transportationCharges":"6","delayUnloadCharges":"","advanceCharges":"","other":"",\ 116 "tax":"","paymentDay":"265 days a year and 12 months"},{"buisnessType":"","articleName":\ "","articleNO":"Article No. 3",\ 117 "count":"","weight":"","volume":"","pack":"","freight" :"",\ 118 "handlingCharges":"","transportationCharges":"","delayUnloadCharges":"","advanceCharges":"","other" :"","tax":"","paymentDay":""},\ 119 {"buisnessType":"Business Type 4Business Type 4","articleName":"","articleNO":"","count":"\ ","weight":"","volume":"","pack":"Long Pack 4 Long Pack 4 Long Pack",\ 120 "freight":"7.36","handlingCharges":"","transportationCharges":"8","delayUnloadCharges":"","advanceCharges ":"","other":"","tax":"",\ 121 "paymentDay":""}],"receipted":10,"settler":"18","receiptStatus":0,"performance":" ","remark":"Remarks on the waybill Chinanews.com, October 13th, according to Agence France-Presse's report on the 13th\ 122, the United Nations General Assembly officially appointed ","method":"new_waybill"}' 123 124 cjyd=post(values) 125 the_page=cjyd.qinqiu() 126 str1 = str1 + the_page 127 128 #print str1 129 tanchu (str1,400) 130 131 132 ################################################### #######Scheduling Function ########################################## ########### 133 def diaodu(): 134 if ddjsfs.get()==u'pay now': 135 jiesuanfangshi=0 136 elif ddjsfs.get()==u'receipt payment': 137 jiesuanfangshi=2 138 else: 139 jiesuanfangshi=3 140 141 #print jiesuanfangshi 142 143 global ydksid 144 global ydjsid 145 if ydksid.get()=='' : 146 tanchu(u'Please fill in the start and end id',100) 147 print u'Please fill in the start and end id of the waybill statement' 148 149 returns 150 if ydjsid.get()=='' : 151 print u'Please fill in the start and end id of the waybill' 152 153 top = Toplevel() 154 top.title('Prompt') 155 Label(top, text='Please fill in the start and end id of the waybill!').pack() 156 top.geometry('400x300 + 700 + 500') 157 returns 158 159 ydksid1=int(ydksid. get()) 160 ydjsid1=int(ydjsid.get()) + 1 161 162 163 driverid=jsyid. get() 164 gongyinshangid=gysid.get() 165 vehicleid = cphid. get() 166 167 168 169 print u'scheduling' 170 for i in range(ydksid1,ydjsid1): 171 172 if jiesuanfangshi==0: ####The settlement method of the waybill is 0 is cash payment, and the request parameters will be slightly different 173 174 175 176 177 values='{"opFrom":"1","userName":"ydf","psd_v":"0","supplierCompany":" ' + str(gongyinshangid) + '","predictArriveDate":"2016-10-20","driverID":"' + str(driverid) + '", "vehicleID":"' + str(vehicleid) + '","dispatchNO":\ 178 "The dispatch number is very, very long aaaa111111","dispatchCharges":"5","packCharges":0,"handlingCharges":"2.22","forkliftCharges ":0,"otherCharges":"4.44","settleType":"' + str(jiesuanfangshi) + '","settleStatus":\ 179 "0","dispatchTotalCharges":"11.66","paidDispatchTotalCharges":"11.66","receivableKickback":"9.99","paidKickback":" "9.99","settler":"32",\ 180 "remark":"http://www.xxxx.cn/test/yuanzhao/admin/view/index.html#/dispatch/dispatchlistdispatch/522","waybillIDList":["\ ' + str(i) + '"],"method":"add_dispatch"}' 181 else: 182 values='{"opFrom":"1","userName":"ydf","psd_v":"0","supplierCompany":" ' + str(gongyinshangid) + '","predictArriveDate":"2016-10-20","driverID":"' + str(driverid) + '", "vehicleID":"' + str(vehicleid) + '","dispatchNO":\ 183 "The dispatch number is very, very long aaaa111111","dispatchCharges":"5","packCharges":0,"handlingCharges":"2.22","forkliftCharges ":0,"otherCharges":"4.44","settleType":"' + str(jiesuanfangshi) + '","settleStatus":\ 184 "0","dispatchTotalCharges":"11.66","paidDispatchTotalCharges":"6.66","receivableKickback":"9.99","paidKickback":" "8","settler":"32",\ 185 "remark":"http://www.xxxx.cn/test/yuanzhao/admin/view/index.html#/dispatch/dispatchlistdispatch/522","waybillIDList":["\ ' + str(i) + '"],"method":"add_dispatch"}' 186 187 188 #print values 189 dd=post(values) 190 the_page=dd.qinqiu() 191 192 if '{"errorCode":"0","errorMsg":"","dispatchID":' in the_page: 193 tanchu(u'scheduled successfully',100) 194 195 196 197 198 199 ###################################Query the waybill number function according to the waybill id ####### #################################################### ### 200 def idchayundan(): 201 global dyydh 202 id=cxdydid. get() 203 if id=='': 204 tanchu(u'Please enter the waybill id',100) 205 returns 206 sql='select waybillCode from bus_waybill where ID=' + str(id) 207 208 idcyd=select(sql) 209 the_page=idcyd.chaxun() 210 211 print the_page 212 213 dyydh1=the_page[0][0] 214 dyydhe.set(dyydh1) 215 216 217 218 219 220 def fahuo(): 221 yundanhao = fhydh. get() 222 devicename=imei.get() 223 if yundanhao=='': 224 tanchu(u'Please fill in the waybill number',100) 225 print (u'Please fill in the waybill number') 226 returns 227 228 print u'Shipment' 229 230 values = '{"deviceName":"' + str(devicename) + '","list":[{"waybillNO":"' + str(yundanhao) + '"}],"method":"deliver","opFrom":"0","psd_v":"0","userName": "testy"}' 231 fh=post(values) 232 the_page=fh.qinqiu() 233 if '"errorCode":"0"' in the_page: 234 tanchu(u'shipping successfully',100) 235 236 def faduanxin(): 237 yundanhao=fdxydh. get() 238 if yundanhao=='': 239 tanchu(u'Please enter the waybill number',100) 240 returns 241 print u'send text messages' 242 243 values = '{"waybillNO":"' + str(yundanhao) + '","method":"send_msg","opFrom":"0" ,"psd_v":"0","userName":"testy"}' #### Calling this interface will send a text message to the consignee 244 fdx=post(values) 245 fdx. Qinqiu() 246 247 def shouhuo(): 248 yundanhao=shydh. get() 249 if yundanhao=='': 250 tanchu(u'Please enter the waybill number',100) 251 returns 252 sql='select settlement_ID, payableAccount from bus_waybill, bus_waybill_fee where bus_waybill.waybillCode=bus_waybill_fee.waybillCode and bus_waybill.waybillCode=' + str(yundanhao) 253 shsql=select(sql) 254 data=shsql.chaxun() 255 256 #print data 257 258 jsfs=data[0][0] 259 ispaid=0 260 if jsfs==0: 261 ispaid=1 262 elif jsfs==1: 263 ispaid=1 264 elif jsfs==2: 265 ispaid=0 266 elif jsfs==3: 267 ispaid=0 268 #print ispaid 269 270 rece=data[0][1] 271 #print rece 272 273 274 275 276 print u'receipt' 277 278 values = '{"consignee":"errrr","imgUrl":"http://www.xxxx.cn/test/yuanzhao/controls/image/IMG_20160621_163048.jpg" ,\ 279 "isPaid":"' + str(ispaid) + '","receivableMoney":"' + str(rece) + '","waybillNO":\ "' + str(yundanhao) + '","method":"get_receive_detail","opFrom":"0","psd_v":"0", "userName":"testy"}' 280 281 shpost=post(values) 282 the_page=shpost.qinqiu() 283 284 if '"errorCode":"0"' in the_page: 285 286 tanchu('received successfully',100) 287 288 ######################################## query waybill status******* *************************''' 289 def chaxunyundanzt(): 290 global ydzte 291 global cxydh 292 293 cxydh1 = cxydh. get() 294 if cxydh1=='': 295 print u'Please enter the waybill number' 296 297 tanchu(u'Please enter the waybill number',100) 298 returns 299 300 301 #print cxydh1 302 sql='select status, ID from bus_waybill where waybillCode=' + str(cxydh1) 303 cxydh2=select(sql) 304 data=cxydh2.chaxun() 305 306 307 print data 308 309 data3=data[0][1] 310 print data3,'**********' 311 312 313 data1='' 314 315 if data[0][0]==1: 316 data1=u'to be scheduled' 317 elif data[0][0]==2: 318 data1=u'to be shipped' 319 elif data[0][0]==3: 320 data1=u'in transit' 321 elif data[0][0]==4: 322 data1=u'to be signed for' 323 elif data[0][0]==5: 324 data1=u'to be settled' 325 elif data[0][0]==6: 326 data1=u'complete' 327 328 329 ydzte. set(data1) 330 yddid. set(data3) 331 332 333 '''********************************************** ****tkinter******************************************** ***************************************************** ***************************************************** *************************************************''\ ' 334 root = Tk() 335 root.geometry('580x680 + 200 + 100') 336 root. resizable(width = False, height = False) 337 root.title("Warrior") 338 root.iconbitmap('yuanzhao.ico') 339 340 #create waybill ************************************************* *Create Waybill********************************************** *********************** 341 lb=Label(root, text = u'create waybill', fg = 'purple', bg = 'green', width=77) 342 lb.pack(side = LEFT, padx = 0, pady = 0) 343 lb.place(x=20,y=5) 344 345 346 lb=Label(root, text = u'create', fg = 'red') 347 lb. pack() 348 lb.place(x=20,y=40) 349 350 e = StringVar() # transport a single number 351 ydgs = Entry(root, width = 5, textvariable = e, bg='#FFD700') 352 ydgs. pack() 353 e.set('10') 354 ydgs. place(x = 50, y = 40) 355 356 lb=Label(root, text = u'waybill type is', fg = 'red') 357 lb. pack() 358 lb.place(x=90,y=40) 359 360 ydnx = StringVar(root) #Type of waybill, 361 ydnx.set(u'hoisting acceptance and issuing documents') 362 om = OptionMenu(root,ydnx,u'cargo consignment document',u'hoisting acceptance bill',u'other acceptance bill') 363 om. pack() 364 om.place(x=170,y=30) 365 366 lb=Label(root, text = u'The settlement method is', fg = 'red') 367 lb. pack() 368 lb.place(x=300,y=40) 369 370 jsfs = StringVar(root) #payment method 371 jsfs.set('receipt payment') 372 om = OptionMenu(root,jsfs,u'cash payment',u'withdrawal payment',u'receipt payment',u'monthly payment') 373 om. pack() 374 om.place(x=370,y=30) 375 376 lb=Label(root, text = u'shipping customer id is', fg = 'red') 377 lb. pack() 378 lb.place(x=450,y=40) 379 380 e = StringVar() #Shipping customer id 381 fhkhid = Entry(root, width = 5, textvariable = e, bg='#FFD700') 382 fhkhid. pack() 383 e.set('100') 384 fhkhid. place(x = 525, y = 38) 385 386 387 lb=Label(root, text = u'waybill', fg = 'red') 388 lb. pack() 389 lb.place(x=20,y=70) 390 391 392 button = Button(root, text = u"OK to create", fg = 'blue', bg = '#00bfff', width = 8, height = 1, command = fun2) 393 button. pack(side = RIGHT) 394 button. place(x = 500, y = 62) 395 396 397 #Scheduling************************************************ Scheduling *************************************************** ********************* 398 lb=Label(root, text = u'dispatch waybill', fg = 'purple', bg = 'green', width=77) 399 lb.pack(side = LEFT, padx = 0, pady = 0) 400 lb.place(x=20,y=90) 401 402 lb=Label(root, text = u'The id of the dispatched waybill is from', fg = 'red') 403 lb. pack() 404 lb.place(x=20,y=120) 405 406 e = StringVar() #waybill start id 407 ydksid = Entry(root, width = 6, textvariable = e) 408 ydksid. pack() 409 #ydgs.set('10') 410 ydksid.place(x = 110, y = 120) 411 412 lb=Label(root, text = u'to', fg = 'red') 413 lb. pack() 414 lb.place(x=150,y=120) 415 416 e = StringVar() #The waybill ends and starts id 417 ydjsid = Entry(root, width = 6, textvariable = e) 418 ydjsid. pack() 419 #ydgs.set('10') 420 ydjsid. place(x = 170, y = 120) 421 422 lb=Label(root, text = u'scheduled supplier id is ', fg = 'red') 423 lb. pack() 424 lb.place(x=250,y=120) 425 426 e = StringVar() #Supplier id 427 gysid = Entry(root, width = 4, textvariable = e, bg='#FFD700') 428 gysid. pack() 429 e.set('51') 430 gysid.place(x = 360, y = 120) 431 432 lb=Label(root, text = u'The settlement method of scheduling is', fg = 'red') 433 lb. pack() 434 lb.place(x=20,y=150) 435 436 ddjsfs = StringVar(root) #Scheduling settlement method 437 ddjsfs.set('pay now') 438 om = OptionMenu(root,ddjsfs,'cash payment','receipt payment','monthly payment') 439 om. pack() 440 om.place(x=120,y=140) 441 442 lb=Label(root, text = u'driver id is', fg = 'red') 443 lb. pack() 444 lb.place(x=220,y=150) 445 446 e = StringVar() #driver id 447 jsyid = Entry(root, width = 4, textvariable = e, bg='#FFD700') 448 jsyid. pack() 449 e.set('32') 450 jsyid. place(x = 290, y = 150) 451 452 lb=Label(root, text = u'the license plate number id is', fg = 'red') 453 lb. pack() 454 lb.place(x=350,y=150) 455 456 e = StringVar() #license plate number id 457 cphid = Entry(root, width = 4, textvariable = e, bg='#FFD700') 458 cphid. pack() 459 e.set('14') 460 cphid. place(x = 420, y = 150) 461 462 button = Button(root,text = u"OK schedule",fg = 'blue',bg ='#00bfff',width = 8,height = 1,command = diaodu) 463 button. pack(side = RIGHT) 464 button. place(x = 500, y = 145) 465 466 ##################################id check waybill number ############ ######################################## 467 lb=Label(root, text = u'id is', fg = 'purple') 468 lb.pack(side = LEFT, padx = 0, pady = 0) 469 lb.place(x=20,y=180) 470 471 e = StringVar() #waybill id 472 cxdydid= Entry(root, width = 6, textvariable = e) 473 cxdydid. pack() 474 #ydgs.set('10') 475 cxdydid. place(x = 50, y = 180) 476 477 lb=Label(root, text = u'The waybill number is', fg = 'purple') 478 lb.pack(side = LEFT, padx = 0, pady = 0) 479 lb.place(x=90,y=180) 480 481 dyydhe = StringVar() #corresponding waybill number 482 dyydh= Entry(root, width = 16, textvariable = dyydhe, fg='#006400', bg='tan') 483 dyydh. pack() 484 #ydgs.set('10') 485 dyydh. place(x = 155, y = 180) 486 487 ''' 488 ydzte = StringVar() #The waybill status of the waybill number 489 ydzt = Entry(root, width = 8, textvariable = ydzte, fg='green') 490 ydzt. pack() 491 #ydgs.set('10') 492 ydzt. place(x = 410, y = 490) 493 ''' 494 495 button = Button(root, text = u"Click to query", fg = 'blue', bg = '#00ffff', width = 8, height = 1, command = idchayundan) 496 button. pack(side = RIGHT) 497 button. place(x = 273, y = 175) 498 499 500 501 #################################################### #############Ship################################### ########### 502 lb=Label(root, text = u'delivery', fg = 'purple', bg = 'green', width=77) 503 lb.pack(side = LEFT, padx = 0, pady = 0) 504 lb.place(x=20,y=230) 505 506 lb=Label(root, text = u'shipping number', fg = 'red') 507 lb. pack() 508 lb.place(x=20,y=260) 509 510 e = StringVar() #The waybill number of the shipment 511 fhydh = Entry(root, width = 16, textvariable = e) 512 fhydh. pack() 513 #ydgs.set('10') 514 fhydh. place(x = 110, y = 260) 515 516 lb=Label(root, text = u'shipping mobile phone's imei', fg = 'red') 517 lb. pack() 518 lb.place(x=250,y=260) 519 520 e = StringVar() #shipped mobile phone imei 521 imei = Entry(root, width = 19, textvariable = e, bg='#FFD700') 522 imei. pack() 523 e.set('imei861483035137583') 524 imei.place(x = 350, y = 260) 525 526 button = Button(root,text = u"Confirm Shipment",fg = 'blue',bg ='#00bfff',width = 8,height = 1,command = fahuo) 527 button. pack(side = RIGHT) 528 button. place(x = 500, y = 255) 529 530 ################################################### ###Send SMS################################################ ###### 531 lb=Label(root, text = u'send text message', fg = 'purple', bg = 'green', width=77) 532 lb.pack(side = LEFT, padx = 0, pady = 0) 533 lb.place(x=20,y=310) 534 535 lb=Label(root, text = u'to', fg = 'red') 536 lb. pack() 537 lb.place(x=20,y=340) 538 539 e = StringVar() #Send the waybill number of the text message 540 fdxydh = Entry(root, width = 16, textvariable = e) 541 fdxydh. pack() 542 #ydgs.set('10') 543 fdxydh. place(x = 50, y = 340) 544 545 lb=Label(root, text = u'this waybill send SMS', fg = 'red') 546 lb. pack() 547 lb.place(x=170,y=340) 548 549 button = Button(root,text = u"Confirm text message",fg = 'blue',bg ='#00bfff',width = 8,height = 1,command = faduanxin) 550 button. pack(side = RIGHT) 551 button. place(x = 500, y = 340) 552 553 ################################################### Receipt################################################### ################ 554 lb=Label(root, text = u'receipt', fg = 'purple', bg = 'green', width=77) 555 lb.pack(side = LEFT, padx = 0, pady = 0) 556 lb.place(x=20,y=390) 557 558 lb=Label(root, text = u'received waybill number:', fg = 'red') 559 lb. pack() 560 lb.place(x=20,y=420) 561 562 e = StringVar() #Received waybill number 563 shydh = Entry(root, width = 16, textvariable = e) 564 shydh. pack() 565 #ydgs.set('10') 566 shydh. place(x = 110, y = 420) 567 568 button = Button(root, text = u"confirm receipt", fg = 'blue', bg = '#00bfff', width = 8, height = 1, command = shouhuo) 569 button. pack(side = RIGHT) 570 button. place(x = 500, y = 420) 571 572 ##########'''*********************************Query Status of waybill *******************************''' 573 lb=Label(root, text = u'query waybill status', fg = 'purple', bg = 'green', width=77) 574 lb.pack(side = LEFT, padx = 0, pady = 0) 575 lb.place(x=20,y=460) 576 577 lb=Label(root, text = u'Please enter the waybill number:', fg = 'purple') 578 lb. pack() 579 lb.place(x=20,y=490) 580 581 e = StringVar() #queried waybill number 582 cxydh = Entry(root, width = 16, textvariable = e) 583 cxydh. pack() 584 #ydgs.set('10') 585 cxydh. place(x = 110, y = 490) 586 587 button = Button(root, text = u"click to query", fg = 'blue', bg = '#00ffff', width = 8, height = 1, command = chaxunyundanzt) 588 button. pack(side = RIGHT) 589 button. place(x = 273, y = 485) 590 591 lb=Label(root, text = u'The status of the waybill is:', fg = 'purple') 592 lb. pack() 593 lb.place(x=340,y=490) 594 595 ydzte = StringVar() #The waybill status of the waybill number 596 ydzt = Entry(root, width = 8, textvariable = ydzte, fg='#006400', bg='tan') 597 ydzt. pack() 598 #ydgs.set('10') 599 ydzt. place(x = 410, y = 490) 600 601 lb=Label(root, text = u'id is:', fg = 'purple') 602 lb. pack() 603 lb.place(x=470,y=490) 604 605 yddid = StringVar() #waybill number id 606 et = Entry(root, width = 8, textvariable = yddid, fg='#006400', bg='tan') 607 et. pack() 608 #ydgs.set('10') 609 et. place(x = 505, y = 490) 610 611 612 613 '''********************Bottom Image******************** **''' 614 img = ImageTk.PhotoImage(file='yuanzhao.png') 615 lb=Label(root, text="abc", image=img) 616 lb.pack(side="top") 617 lb.place(x=0,y=540) 618 619 620 621 root. mainloop()<br><br><br><br><br>
Finally, just upload two screenshots of runtime.
<br><br>
The interface of this tool uses the packet capture interface of the project or refer to the protocol document. The purpose of making this tool is to put all the main process functions of the system on one interface, because the system is divided into the web erp management end and the app scanning code delivery and receiving end, each end has more than a dozen pages, back and forth Switching page tests, especially web-side waybills and dispatches require filling in a large number of page forms , which is a waste of time and frenzied.<br><br>From the code, we can see that the code of tkinter is not difficult. After the background script is written, it will take about half a day to build the tool interface. The function is triggered by binding the button to the function, and the function is executed when the button is clicked. When the traditional script operation wants to execute a function, you need to comment out the code that calls another function. This is also an advantage of the interface tool. , what to do.
<br><br>The above interface tool is popped up by running the code directly. The file name of the script is yuanzhao.py. If you want to make an exe client, you need to write another file. We named it setup.py, and the code is as follows.<br><br>
1 from distutils.core import setup 2 import py2exe 3 4 #setup(windows=['yuanzhao.py']) 5 6 7 setup( 8 # targets to build 9 windows = [{<!-- -->"script":"yuanzhao.py", "icon_resources": [(0, "yuanzhao.ico")]} ] 10)
Run python setup.py py2exe, and the package will be successful. At this time, two folders will be generated under the path,
Let’s take a look at the dist folder. This file is the usage path of the tool,
In this way, the dist folder can be placed in any third-party package in the py script or the computer without python installed to run the test tool.
<br><br><br><br>