This repository has been archived by the owner on Mar 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathReport_Editor.py
1086 lines (1049 loc) · 60.9 KB
/
Report_Editor.py
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import decimal
import webbrowser
from multiprocessing import Process
from multiprocessing import freeze_support
import PySimpleGUI as sg
TEXT = {
'00': '△:n:同一批次产品应采集的样品件数,c:最大可允许超出m值的样品件数,m:微生物指标可接受水平的限量值,M:微生物指标的最高安全限值。',
'01': '酒精度实测值与标签标示值允许差为±1.0%vol(标签标示值:XX%vol)',
'02': 'α-666:0.0001\nβ-666:0.0004\nγ-666:0.0002\nδ-666:0.0001',
'03': 'p,p’-DDE:0.0001\no,p’-DDE:0.0002\no,p’-DDD:0.0004\np,p’-DDT:0.0009',
'04': 'α-六六六:\n0.000097\nβ-六六六:\n0.000634\nγ-六六六:\n0.000226\nδ-六六六:\n0.000179',
'05': 'P,P’-滴滴伊:\n0.000345\nO,P’-滴滴涕:\n0.000412\nP,P’-滴滴滴:\n0.000465\nP,P’-滴滴涕:\n0.000481',
'06': '标签审核内容不包括标示内容真实性和规范性的核实。',
'07': '标签审核内容不包括标示内容真实性和规范性的核实。\n该样品为散装称重食品,参照GB 7718-2011、GB 28050-2011的要求进行审核,审核内容不包括净含量和规格。',
'08': '标签审核内容不包括标示内容真实性的核实。',
'09': '样品为电子标签,标签审核内容不包括强制标示内容的字符高度以及生产日期格式,以实物印刷为准。\n标签审核内容不包括标示内容真实性的核实。',
'10': '样品为电子标签,标签审核内容不包括强制标示内容的字符高度以及生产日期格式,以实物印刷为准。\n标签审核内容不包括标示内容真实性的核实。\n本报告用于发证检验,食品生产许可证编号不在本次标签审核范围内。',
'11': '样品为电子标签,标签审核内容不包括强制标示内容的字符高度以及生产日期格式,以实物印刷为准。\n标签审核内容不包括标示内容真实性的核实。\n该样品为散装称重食品,参照GB 7718-2011、'
'GB 28050-2011的要求进行审核,审核内容不包括净含量和规格。',
'12': '标签审核内容不包括标示内容真实性的核实。\n该样品为散装称重食品,参照GB 7718-2011、GB 28050-2011的要求进行审核,审核内容不包括净含量和规格。',
'13': '样品为样版标签,标签审核内容不包括生产日期字符高度及格式,以实物印刷为准。\n标签审核内容不包括标示内容真实性的核实。',
'14': '经抽样检验,所检项目序号“XXX”无限量要求,不作判定,所检其余项目',
'15': '本报告代替编号为XXX的检测报告,原报告作废。',
'16': '该阳性样品验证结果:不一致。',
'17': '多氯联苯以 PCB28、PCB52、PCB101、PCB118、PCB138、PCB153 和 PCB180 总和计。',
'18': '实测值为总汞。',
'19': '定量限:\nα-六六六:\n0.01\nβ-六六六:\n0.01\nγ-六六六:\n0.05\nδ-六六六:\n0.01',
'20': '标签审核结果详见第3页。',
}
LIMIT = {
'香菇': ('91.7', '', '1', '0.5', '0.5', '0.1', '0'),
'鲜枣': ('67.4', '', '0.1', '0', '0.05', '0', '0'),
'葡萄': ('88.5', '', '0.2', '0', '0.05', '0', '0'),
'木耳': ('91.8', '', '1', '0.5', '0.2', '0.1', '0'),
'大白菜': ('94.4', '', '0.3', '0.5', '0.2', '0.01', '0'),
'黄花菜': ('40.3', '', '0.1', '0.5', '0.2', '0.01', '0'),
'芥菜': ('91.5', '', '0.3', '0.5', '0.2', '0.01', '0'),
'豆角': ('90.0', '', '0.2', '0.5', '0.1', '0.01', '0'),
'鲢鱼': ('77.4', '', '0.5', '0', '0.1', '0', '0'),
'青鳞鱼': ('73.9', '', '0.5', '0', '0.1', '0', '0'),
'鱿鱼': ('80.4', '', '1.0', '0', '0.1', '0', '0'),
'柠檬': ('91.0', '', '0.1', '0', '0', '0', '0'),
'柚': ('89.0', '', '0.1', '0', '0', '0', '0'),
'西柚': ('90.9', '', '0.1', '0', '0', '0', '0'),
'猪肉': ('71.0', '', '0.2', '0', '0.1', '0', '1'),
'食用菌': ('', '', '1', '0.5', '0.2', '0.1', '0'),
}
SOLID = {
'饮料': ('0', '0.5', '0.05', '0.1', '0'),
'果蔬汁': ('1.0', '0.5', '0.05', '0.1', '0.05'),
'含乳': ('0', '0.5', '0', '0.1', '0.05'),
'植物蛋白': ('1.0', '0.5', '0', '0.1', '0.025'),
'碳酸': ('0.2', '0.5', '0.05', '0.1', '0.05'),
'风味': ('1.0', '0.5', '0', '0.1', '0'),
'果味': ('1.0', '0.5', '0.05', '0.1', '0.05'),
}
SOLID_ITEMS = (
None,
None,
'苯甲酸及其钠盐(以苯甲酸计)',
'山梨酸及其钾盐(以山梨酸计)',
'苋菜红',
'柠檬黄',
'胭脂红')
DEHYDRATION_ITEMS = (
None,
None,
'铅(以Pb计)',
'总砷(以As计)',
'镉(以Cd计)',
'总汞(以Hg计)',
'铬(以Cr计)')
VERSION = 'V0.1.1'
ICO = b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\xc8\x00\x00\x00\xc8\x08\x06\x00\x00\x00\xadX\xae\x9e\x00\x00' \
b'\x00\x01sRGB\x00\xae\xce\x1c\xe9\x00\x00\x10"IDATx^\xed\x9d}\x90\x1bu\x19\xc7\x9fgs\xef}\xbdrPy)/\xe5\xad\xe2' \
b'\x88\x02\xd5)U\xa0\xd0&P\xda\xcbUG\x8bJ\x13Zu\x1c_yq\x04\xabu,' \
b'\x0c\x8c\x0e\x8cH\xf1e\x14\x07\x84&=\x10\x19\x85\xe4\x8a\xa5\xc9U\x0f\x95\x17\x19^+\x96B\xb5\x15\n\x85R\xda' \
b'\xeb\xcb\xf5z\x97K\xf6q6\xa5X\x94\xdb\xddl6\xf7\xfbu\xf7\x9b?{' \
b'\xbf\xdf\xf3\xf2y\xf6\xd3l\xb2\x9b\x84\t\x0f\x10\x00\x81a\t0\xd8\x80\x00\x08\x0cO\x00\x82\xe0\xe8\x00\x01\x1b' \
b'\x02\x10\x04\x87\x07\x08@\x10\x1c\x03 \xe0\x8d\x00\x9eA\xbcq\xc3\xae\x90\x10\x80 ' \
b'!\x194\xda\xf4F\x00\x82x\xe3\x86]!!\x00AB2h\xb4\xe9\x8d\x00\x04\xf1\xc6\r\xbbBB\x00\x82\x84d\xd0h\xd3\x1b\x01' \
b'\x08\xe2\x8d\x1bv\x85\x84\x00\x04\t\xc9\xa0\xd1\xa67\x02\x10\xc4\x1b7\xec\n\t\x01\x08\x12\x92A\xa3Mo\x04 ' \
b'\x887n\xd8\x15\x12\x02\x10$$\x83F\x9b\xde\x08@\x10o\xdc\xb0+$\x04 HH\x06\x8d6\xbd\x11\x80 ' \
b'\xde\xb8aWH\x08@\x90\x90\x0c\x1amz#\x00A\xbcq\xc3\xae\x90\x10\x80 ' \
b'!\x194\xda\xf4F\x00\x82x\xe3\x86]!!P3A\xe2\xd1{\x8e*\xf1\xd0\x84\xba\x12\xb72S$$<\xd1\xe6\x08\x12(' \
b'\x11\x0f\xd4IiG\xb1T\xbf\xa3\xab\xe7so\xd5"\xb5o\x82|z\xc6oG\x17\xea\x07?CL\x8b\x88hz-\x8aEL\x10\x18\x96\x80' \
b'\xd0>!\xfa\x1d\x19\xc6\xaf\xb3\xab?\xd7C\xc4\xe2\x07\xad\xaa\x05\x99{' \
b'\xc1\xf2\xa3\x8d:c\t\x0b-$\xa6f?\x8aB\x0c\x10\xa8\x86\x80\x88lb\xa2\x9b3\xf9\xe4\xcf\xab\x89c\xed\xf5,' \
b'H\xfb\x8c\xbb\xdb\xb8\xbex=3\x7f\xb9\xda"\xb0\x1f\x04jA@D^a\xe2\xeb3\xf9\xc4\xed^\xe3{' \
b'\x12dn\xb4\xf3d\x83J\xdd\xcc|\xac\xd7\xc4\xd8\x07\x02#E@\x88:w\x17\x8eY\xd8\xd3s~\xb1\xd2\x9c\x15\x0b\x12\x8f' \
b'\xae\xf8\x18\x93<HL\xe3*M\x86\xf5 \xa0\x8a\x80\x88<\xdc8\xd44\xf7\xbe\x9e\xf9}\x95\xd4P\x91 ' \
b'\xf3b\x9dg\x99Tz\x84\x89\x1b+I\x82\xb5 ' \
b'\xa0\x07\x01ylWa\xd2\xb9\x95<\x93\xb8\x16\xe4\xe2\x0b:\x8f\xab\x8b\x98O2S\x9b\x1e\xcd\xa2\n\x10\xf0B@\xee\xce' \
b'\xe4\x92\x97\xba\xdd\xe9Z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v\xabmZ&c\xea\x03\xb9K\x9f\xf2$H<\x9a^\xc9Ls\xec2\xfc' \
b'&\xf3\x19jj\xaa\x1b\xe9\xde\x91\x0f\x04\x1c\t\xdcw\xcf\xf3\xd4y\xd7\xb3\xb6\xebL\xd3\x9c\xd7\xd5}Y\xc6\xab ' \
b'O0\xd3G\x86\xdb\xdc\xd2ROw\xdf\x7f\x89c\xa1X\x00\x02*\x08<\xfa\x97W\xe8\xa6\x1b\xfel\xff:\xc4\xa4od\xbb\x13' \
b'?\xf3$HG4\xf5"1\x9f2\xdcf\xeb\xad\xdd\xdbW|RE\xef\xc8\t\x02\x8e\x04\xd6\xaf\xdbF\x8b\xafZm/\x88\xd0\xf5\xd9' \
b'|\xe2\xfb\x9e\x04\x89\xc7\xd2\x1b\x98\xe8\xa4\xe16\x1f\xd6\xd6BwtB\x10\xc7Ia\x81\x12\x02/\xbe\xf0\x16}\xfb' \
b'\xca\x87\xecs\x0b\xfd \x93O,\x81 JF\x84\xa4*\t@\x10\x95\xf4\x91[{\x02\x10D\xfb\x11\xa1@\x95\x04 ' \
b'\x88J\xfa\xc8\xad=\x01\x08\xa2\xfd\x88P\xa0J\x02\x10D%}\xe4\xd6\x9e\x00\x04\xd1~D(' \
b'P%\x01\x08\xa2\x92>rkO\x00\x82h?"\x14\xa8\x92\x00\x04QI\x1f\xb9\xb5\'\x00A\xb4\x1f\x11\nTI\x00\x82\xa8\xa4' \
b'\x8f\xdc\xda\x13\x80 \xda\x8f\x08\x05\xaa$\x00AT\xd2Gn\xed\t@\x10\xedG\x84\x02U\x12\x80 *\xe9#\xb7\xf6\x04 ' \
b'\x88\xf6#B\x81*\t@\x10\x95\xf4\x91[{\x02\x10D\xfb\x11\xa1@\x95\x04 ' \
b'\x88J\xfa\xc8\xad=\x01\x08\xa2\xfd\x88P\xa0J\x02\x10D%}\xe4\xd6\x9e\x00\x04\xd1~D(' \
b'P%\x01\x08\xa2\x92>rkO\x00\x82h?"\x14\xa8\x92\x00\x04QI\x1f\xb9\xb5\'\x00A\xb4\x1f\x11\nTI\x00\x82\xa8\xa4' \
b'\x8f\xdc\xda\x13\x80 \xda\x8f\x08\x05\xaa$\x00AT\xd2Gn\xed\t@\x10\xedG\x84\x02U\x12\x80 *\xe9#\xb7\xf6\x04 ' \
b'\x88\xf6#B\x81*\t@\x10\x95\xf4\x91[{\x02\x10D\xfb\x11\xa1@\x95\x04 ' \
b'\x88J\xfa\xc8\xad=\x01\x08\xa2\xfd\x88P\xa0J\x02\x10D%}\xe4\xd6\x9e\x00\x04\xd1~D(' \
b'P%\x01\x08\xa2\x92>rkO\x00\x82h?"\x14\xa8\x92\x00\x04QI\x1f\xb9\xb5\'\x00A\xb4\x1f\x11\nTI\x00\x82\xa8\xa4' \
b'\x8f\xdc\xda\x13\x80 \xda\x8f\x08\x05\xaa$\x00AT\xd2Gn\xed\t@\x10\xedG\x84\x02U\x12\x80 *\xe9#\xb7\xf6\x04 ' \
b'\x88\xf6#B\x81*\t@\x10\x95\xf4\x91[{\x02\x10D\xfb\x11\xa1@\x95\x04 ' \
b'\x88J\xfa\xc8\xad=\x01\x08\xa2\xfd\x88P\xa0J\x02\x10D%}\xe4\xd6\x9e\x00\x04\xd1~D(' \
b'P%\x01\x08\xa2\x92>rkO\x00\x82h?"\x14\xa8\x92\x00\x04QI\x1f\xb9\xb5\'\x00A\xb4\x1f\x11\nTI\x00\x82\xa8\xa4' \
b'\x8f\xdc\xda\x13\x80 \xda\x8f\x08\x05\xaa$\x00AT\xd2Gn\xed\t@\x10\xedG\x84\x02U\x12\x80 *\xe9#\xb7\xf6\x04 ' \
b'\x88\xf6#B\x81*\t@\x10\x95\xf4\x91[{\x02\x10D\xfb\x11\xa1@\x95\x04 ' \
b'\x88J\xfa\xc8\xad=\x01\x08\xa2\xfd\x88P\xa0J\x02\x10D%}\xe4\xd6\x9e\x00\x04\xd1~D(P%\x01\x08\xa2\x92>rkO@\xb9 ' \
b'\xe3\xc65\xd1\xd5K\xce\xd1\x1e\x14\n\x0c\'\x81\xcd\xaf\xec\xa2\xdb~\xf6\xc4{' \
b'4\xcfD$\xfb\xff]\xe8\x07\x99|b\xc9p\x84\xac\x95\xc3>\xe2\xb1\xf4\x06&:)\x9cx\xd1up\t\x08\x910\xd1~O\xaa\x11$' \
b'\xf5O&>1\xb8\xa0\xd0Y\x98\t\x88\x081\xb1wA:b\xa9\xedD<!\xcc\x10\xd1{' \
b'\xc0\t\x88\xfc2\x93O~\xc5\xdb)V4\xdd\xcfL\xcd\x01G\x84\xf6BL@\x84Ve\xf3\x89\x8b=\t\xd2\x1eM\xed3\x98\x9bB\xcc' \
b'\x0f\xad\x07\x9c\x80)\x94\xeb\xca\'.\xf4$HG4\xd5K\xcc\xe3\x03\xce\x08\xed\x85\x98\x80\x08-\xcf\xe6\x13\x0b=\t' \
b'\x12\x8f\xa572\xd1\t!\xe6\x87\xd6\x83N\xa0\xbaw\xb1\xd2\x1b\x88\xe8$.\xbfgl\xfb\x8ep\xd01\xa2\xbf\x80\x11' \
b'\x10y\xe7\x88\xf6\xfe.\xd6\xbb\xae\x83\xbc\xed\xc8\xdb\x97W\xca\xb8"\x11\xa6\xa3\'\x8d\r\x18:\xb4\x13\x14\x02' \
b'\x83\x83E\xda\xfa\xfa\xdew\xb5\xc3\xd6\x7f\xf4\x07\xd9Q\xe5u\x10\xfb\x0b\x85\r\x8d\x11\xfa\xe8\xf4\xa3\x83' \
b'\xc2\x13}\x04\x8c\xc0\xee]\x83\xb4\xf6\xe9\xad\xf6]U{\x8aew%\x1d\x82\x04\xec\x88\nX;\x10$`\x03E;\xfe\x12\x80 ' \
b'\xfe\xf2D\xb4\x80\x11\x80 \x01\x1b(\xda\xf1\x97@\xed\x05\x89\xa6\x9ef\xe63\x86+\xbb.\xc24\xed\xdcI\xfev\x85h ' \
b'\xe0\x13\x81\xde\x1d\xfb\xe8\x1f\xcfmsz\x91\xbe8\x93O\xdc8\xdc"\x87\xdb\xddS]L<\xd7.\xc3\xf4\xf3&\x91a\xe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\x03\x99\x83J\x00\x82' \
b'\x04u\xb2\xe8\xcb\x17\x02\x10\xc4\x17\x8c\x08\x12T\x02\x10$\xa8\x93E_\xbe\x10\x80 \xbe`D\x90\xa0\x12\x80 ' \
b'A\x9d,\xfa\xf2\x85\x00\x04\xf1\x05#\x82\x04\x95\x00\x04\t\xead\xd1\x97/\x04 \x88/\x18\x11$\xa8\x04 ' \
b'HP\'\x8b\xbe|!\x00A|\xc1\x88 A%\x00A\x82:Y\xf4\xe5\x0b\x01\x08\xe2\x0bF\x04\t*\x01\x08\x12\xd4\xc9\xa2/_\x08' \
b'@\x10_0"HP\t@\x90\xa0N\x16}\xf9B\x00\x82\xf8\x82\x11A\x82J\x00\x82\x04u\xb2\xe8\xcb\x17\x02\x10\xc4\x17\x8c' \
b'\x08\x12T\x02\x10$\xa8\x93E_\xbe\x10\x80 \xbe`D\x90\xa0\x12\x80 A\x9d,' \
b'\xfa\xf2\x85\x00\x04\xf1\x05#\x82\x04\x95\x00\x04\t\xead\xd1\x97/\x04\xfe\x03\x13\xd8q2\x1e\x92rk\x00\x00\x00' \
b'\x00IEND\xaeB`\x82 '
def valid_numbers(text, min_=False):
if text.endswith('.0'):
return '.0'
elif text.endswith('.00'):
return '.00'
elif text.endswith('.000'):
return '.000'
text = text.lstrip('0')
text = text.rstrip('0')
if '.' not in text:
return {True: '.0', False: '1.'}[min_]
length = len(text[text.index('.') + 1:])
length = min(length, 4)
return '.' + '0' * length
def home():
layout = [
[sg.Button('营养成分表(基础)', size=(16, 2), font=('微软雅黑', 12)),
sg.Button('营养成分表(详细)', size=(16, 2), font=('微软雅黑', 12))],
[sg.Button('脱水率及限值计算', size=(16, 2), font=('微软雅黑', 12)),
sg.Button('固体饮料限值计算', size=(16, 2), font=('微软雅黑', 12))],
[sg.Button('常用文本剪贴板', size=(16, 2), font=('微软雅黑', 12)),
sg.Button('查看工具详细说明', size=(16, 2), font=('微软雅黑', 12))],
]
return sg.Window(
f'报告编辑部小工具 {VERSION}',
layout,
size=(
405,
195),
text_justification='center',
element_justification='center',
icon=ICO,
finalize=True, )
def nutrition_win():
rc_11 = [
[sg.Text('能量', font=('微软雅黑', 12))],
[sg.Text('蛋白质', font=('微软雅黑', 12))],
[sg.Text('脂肪', font=('微软雅黑', 12))],
[sg.Text('碳水化合物', font=('微软雅黑', 12))],
[sg.Text('钠', font=('微软雅黑', 12))],
]
rc_12 = [
[sg.Input(key='00', size=(10, 1), font=('微软雅黑', 12))],
[sg.Input(key='01', size=(10, 1), font=('微软雅黑', 12))],
[sg.Input(key='02', size=(10, 1), font=('微软雅黑', 12))],
[sg.Input(key='03', size=(10, 1), font=('微软雅黑', 12))],
[sg.Input(key='04', size=(10, 1), font=('微软雅黑', 12))],
]
rc_13 = [
[sg.Text(key='10', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='11', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='12', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='13', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='14', size=(5, 1), font=('微软雅黑', 12))],
]
rc_14 = [
[sg.Text(key='20', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='21', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='22', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='23', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='24', size=(10, 1), font=('微软雅黑', 12))],
]
rc_15 = [
[sg.Text(key='30', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='31', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='32', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='33', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='34', size=(5, 1), font=('微软雅黑', 12))],
]
rc_16 = [
[sg.Text('千焦(KJ)', font=('微软雅黑', 12))],
[sg.Text('克(g)', font=('微软雅黑', 12))],
[sg.Text('克(g)', font=('微软雅黑', 12))],
[sg.Text('克(g)', font=('微软雅黑', 12))],
[sg.Text('毫克(mg)', font=('微软雅黑', 12))],
]
layout = [
[sg.Frame(layout=rc_11, title='项目', font=('微软雅黑', 12)),
sg.Frame(layout=rc_12, title='原始数值', font=('微软雅黑', 12)),
sg.Frame(layout=rc_13, title='修约数值', font=('微软雅黑', 12)),
sg.Frame(layout=rc_14, title='NRV%(原始)', font=('微软雅黑', 12)),
sg.Frame(layout=rc_15, title='NRV%(修约)', font=('微软雅黑', 12)),
sg.Frame(layout=rc_16, title='单位', font=('微软雅黑', 12))],
[sg.Button('从剪贴板导入', key='导入', font=('微软雅黑', 12)),
sg.Button('计算', key='计算', font=('微软雅黑', 12)),
sg.Button('清空', key='清空', font=('微软雅黑', 12))],
[sg.StatusBar('准备就绪', text_color="black", justification='center', key='status', font=('微软雅黑', 12),
size=(10, 1))],
]
return sg.Window(
'营养成分表修约(基础)',
layout,
enable_close_attempted_event=True,
element_justification='center',
icon=ICO,
finalize=True,
return_keyboard_events=True)
def nutrition():
set_theme()
window_item = nutrition_win()
while True:
event_n, values_n = window_item.read(timeout=100)
if event_n == '-WINDOW CLOSE ATTEMPTED-':
break
elif event_n in ['计算', '\r']:
try:
del values_n['status']
numbers = [decimal.Decimal(i) for i in values_n.values()]
except decimal.InvalidOperation:
window_item.find_element('status').update(
'输入数值无效!', text_color="black")
continue
limit = [decimal.Decimal(i)
for i in ('17', '0.5', '0.5', '0.5', '5')]
standard = [
decimal.Decimal(i) for i in (
'8400', '60', '60', '300', '2000')]
energy = []
for i, j in zip((0, 1, 2, 3, 4), ('1.', '.0', '.0', '.0', '1.')):
if numbers[i] > limit[i]:
num = numbers[i].quantize(
decimal.Decimal(j), rounding=decimal.ROUND_HALF_EVEN)
if 1 <= i <= 3:
energy.append(num)
window_item.find_element('1' + str(i)).update(num)
nrv = (
(num /
standard[i]) *
decimal.Decimal('100')).quantize(
decimal.Decimal('.0000'),
rounding=decimal.ROUND_HALF_EVEN)
window_item.find_element(
'2' +
str(i)).update(
'%.2f%%' %
nrv)
if decimal.Decimal('0.5') <= nrv <= decimal.Decimal('1'):
window_item.find_element('3' + str(i)).update('1%')
else:
window_item.find_element(
'3' +
str(i)).update(
'%.0f%%' %
((num /
standard[i]) *
decimal.Decimal('100')).quantize(
decimal.Decimal('.00'),
rounding=decimal.ROUND_HALF_EVEN))
else:
if 1 <= i <= 3:
energy.append(decimal.Decimal('0'))
window_item.find_element('1' + str(i)).update('0')
window_item.find_element('2' + str(i)).update('0%')
window_item.find_element('3' + str(i)).update('0%')
energy = (energy[0] * decimal.Decimal('17')) + (energy[1] *
decimal.Decimal('37')) + (energy[2] * decimal.Decimal('17'))
energy_round = energy.quantize(
decimal.Decimal('1.'),
rounding=decimal.ROUND_HALF_EVEN)
energy_nrv = (
energy_round *
decimal.Decimal('100') /
decimal.Decimal('8400')).quantize(
decimal.Decimal('.0000'),
rounding=decimal.ROUND_HALF_EVEN)
correct = bool(abs(energy - numbers[0]) <= decimal.Decimal('20.0'))
window_item.find_element('status').update(
'能量计算结果分别为:%s,%s,%.2f%%,%.0f%%' %
(energy, energy_round, energy_nrv, energy_nrv.quantize(
decimal.Decimal('.00'), rounding=decimal.ROUND_HALF_EVEN)),
text_color={True: "green", False: "red"}[correct])
elif event_n == '导入':
data = sg.clipboard_get()
data = data.split('\r\n') if '\r' in data else data.split('\n')
if len(data) == 6:
data = data[:-1]
if len(data) == 5:
for i, j, l in zip(
(0, 1, 2, 3, 4), data, (-6, -4, -4, -4, -6)):
window_item.find_element('0' + str(i)).update(j[:l])
window_item.find_element('status').update(
'导入成功!', text_color="black")
else:
window_item.find_element('status').update(
'导入失败,请检查复制内容!', text_color="black")
elif event_n == '清空':
for i in range(5):
window_item.find_element('0' + str(i)).update('')
window_item.find_element('status').update(
'准备就绪', text_color="black")
window_item.close()
def nutrition_plus_win():
rc_11 = [
[sg.Text('能量', font=('微软雅黑', 12))],
[sg.Text('蛋白质', font=('微软雅黑', 12))],
[sg.Text('脂肪', font=('微软雅黑', 12))],
[sg.Text('碳水化合物', font=('微软雅黑', 12))],
[sg.Text('钠', font=('微软雅黑', 12))],
[sg.Text('膳食纤维', font=('微软雅黑', 12))],
[sg.Text('维生素E', font=('微软雅黑', 12))],
[sg.Text('维生素B1', font=('微软雅黑', 12))],
[sg.Text('维生素B2', font=('微软雅黑', 12))],
[sg.Text('维生素C', font=('微软雅黑', 12))],
[sg.Text('叶酸', font=('微软雅黑', 12))],
[sg.Text('钾', font=('微软雅黑', 12))],
[sg.Text('钙', font=('微软雅黑', 12))],
[sg.Text('铁', font=('微软雅黑', 12))],
[sg.Text('锌', font=('微软雅黑', 12))],
[sg.Text('硒', font=('微软雅黑', 12))],
]
rc_12 = [
[sg.Input(key='000', size=(10, 1), font=('微软雅黑', 12))],
[sg.Input(key='001', size=(10, 1), font=('微软雅黑', 12))],
[sg.Input(key='002', size=(10, 1), font=('微软雅黑', 12))],
[sg.Input(key='003', size=(10, 1), font=('微软雅黑', 12))],
[sg.Input(key='004', size=(10, 1), font=('微软雅黑', 12))],
[sg.Input(key='005', size=(10, 1), font=('微软雅黑', 12), default_text='0')],
[sg.Input(key='006', size=(10, 1), font=('微软雅黑', 12), default_text='0')],
[sg.Input(key='007', size=(10, 1), font=('微软雅黑', 12), default_text='0')],
[sg.Input(key='008', size=(10, 1), font=('微软雅黑', 12), default_text='0')],
[sg.Input(key='009', size=(10, 1), font=('微软雅黑', 12), default_text='0')],
[sg.Input(key='010', size=(10, 1), font=('微软雅黑', 12), default_text='0')],
[sg.Input(key='011', size=(10, 1), font=('微软雅黑', 12), default_text='0')],
[sg.Input(key='012', size=(10, 1), font=('微软雅黑', 12), default_text='0')],
[sg.Input(key='013', size=(10, 1), font=('微软雅黑', 12), default_text='0')],
[sg.Input(key='014', size=(10, 1), font=('微软雅黑', 12), default_text='0')],
[sg.Input(key='015', size=(10, 1), font=('微软雅黑', 12), default_text='0')],
]
rc_13 = [
[sg.Text(key='100', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='101', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='102', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='103', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='104', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='105', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='106', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='107', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='108', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='109', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='110', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='111', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='112', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='113', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='114', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='115', size=(5, 1), font=('微软雅黑', 12))],
]
rc_14 = [
[sg.Text(key='200', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='201', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='202', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='203', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='204', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='205', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='206', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='207', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='208', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='209', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='210', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='211', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='212', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='213', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='214', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='215', size=(10, 1), font=('微软雅黑', 12))],
]
rc_15 = [
[sg.Text(key='300', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='301', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='302', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='303', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='304', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='305', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='306', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='307', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='308', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='309', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='310', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='311', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='312', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='313', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='314', size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='315', size=(5, 1), font=('微软雅黑', 12))],
]
rc_16 = [
[sg.Text('千焦(KJ)', font=('微软雅黑', 12))],
[sg.Text('克(g)', font=('微软雅黑', 12))],
[sg.Text('克(g)', font=('微软雅黑', 12))],
[sg.Text('克(g)', font=('微软雅黑', 12))],
[sg.Text('毫克(mg)', font=('微软雅黑', 12))],
[sg.Text('克(g)', font=('微软雅黑', 12))],
[sg.Text('mg α-TE', font=('微软雅黑', 12))],
[sg.Text('毫克(mg)', font=('微软雅黑', 12))],
[sg.Text('毫克(mg)', font=('微软雅黑', 12))],
[sg.Text('毫克(mg)', font=('微软雅黑', 12))],
[sg.Text('ugDFE', font=('微软雅黑', 12))],
[sg.Text('毫克(mg)', font=('微软雅黑', 12))],
[sg.Text('毫克(mg)', font=('微软雅黑', 12))],
[sg.Text('毫克(mg)', font=('微软雅黑', 12))],
[sg.Text('毫克(mg)', font=('微软雅黑', 12))],
[sg.Text('微克(μg)', font=('微软雅黑', 12))],
]
layout = [
[sg.Frame(layout=rc_11, title='项目', font=('微软雅黑', 12)),
sg.Frame(layout=rc_12, title='原始数值', font=('微软雅黑', 12)),
sg.Frame(layout=rc_13, title='修约数值', font=('微软雅黑', 12)),
sg.Frame(layout=rc_14, title='NRV%(原始)', font=('微软雅黑', 12)),
sg.Frame(layout=rc_15, title='NRV%(修约)', font=('微软雅黑', 12)),
sg.Frame(layout=rc_16, title='单位', font=('微软雅黑', 12))],
[sg.Button('从剪贴板导入', key='导入', font=('微软雅黑', 12)),
sg.Button('计算', key='计算', font=('微软雅黑', 12)), sg.Button('清空', key='清空', font=('微软雅黑', 12))],
[sg.StatusBar('准备就绪', text_color="black", justification='center', key='status', font=('微软雅黑', 12),
size=(10, 1))],
]
return sg.Window(
'营养成分表修约(详细)',
layout,
enable_close_attempted_event=True,
element_justification='center',
icon=ICO,
finalize=True,
return_keyboard_events=True)
def nutrition_plus():
set_theme()
window_item = nutrition_plus_win()
while True:
event_np, values_np = window_item.read(timeout=100)
if event_np == '-WINDOW CLOSE ATTEMPTED-':
break
elif event_np in ['计算', '\r']:
try:
del values_np['status']
numbers = [decimal.Decimal(i) for i in values_np.values()]
except decimal.InvalidOperation:
window_item.find_element('status').update(
'输入数值无效!', text_color="black")
continue
limit = [
decimal.Decimal(i) for i in (
'17',
'0.5',
'0.5',
'0.5',
'5',
'0.5',
'0.28',
'0.03',
'0.03',
'2.0',
'8',
'20',
'8',
'0.3',
'0.30',
'1.0')]
standard = [
decimal.Decimal(i) for i in (
'8400',
'60',
'60',
'300',
'2000',
'25',
'14',
'1.4',
'1.4',
'100',
'400',
'2000',
'800',
'15',
'15',
'50')]
energy = []
for i, j in zip((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15), ('1.', '.0', '.0',
'.0', '1.', '.0', '.00', '.00',
'.00', '.0', '1.', '1.', '1.',
'.0', '.00', '.0')):
if numbers[i] > limit[i]:
num = numbers[i].quantize(
decimal.Decimal(j), rounding=decimal.ROUND_HALF_EVEN)
if i in (1, 2, 3, 5):
energy.append(num)
window_item.find_element('1' + str(i).zfill(2)).update(num)
nrv = ((num / standard[i]) *
decimal.Decimal('100')).quantize(
decimal.Decimal('.0000'),
rounding=decimal.ROUND_HALF_EVEN)
window_item.find_element(
'2' +
str(i).zfill(2)).update(
'%.2f%%' %
nrv)
if decimal.Decimal('0.5') <= nrv <= decimal.Decimal('1'):
window_item.find_element(
'3' + str(i).zfill(2)).update('1%')
else:
window_item.find_element(
'3' +
str(i).zfill(2)).update(
'%.0f%%' %
((num /
standard[i]) *
decimal.Decimal('100')).quantize(
decimal.Decimal('.00'),
rounding=decimal.ROUND_HALF_EVEN))
else:
if i in (1, 2, 3, 5):
energy.append(decimal.Decimal('0'))
window_item.find_element('1' + str(i).zfill(2)).update('0')
window_item.find_element(
'2' + str(i).zfill(2)).update('0%')
window_item.find_element(
'3' + str(i).zfill(2)).update('0%')
energy = (energy[0] * decimal.Decimal('17')) + (energy[1] *
decimal.Decimal('37')) + (energy[2] * decimal.Decimal('17'))
energy_round = energy.quantize(
decimal.Decimal('1.'),
rounding=decimal.ROUND_HALF_EVEN)
energy_nrv = (
energy_round *
decimal.Decimal('100') /
decimal.Decimal('8400')).quantize(
decimal.Decimal('.0000'),
rounding=decimal.ROUND_HALF_EVEN)
correct = bool(abs(energy - numbers[0]) <= decimal.Decimal('20.0'))
window_item.find_element('status').update(
'能量计算结果分别为:%s,%s,%.2f%%,%.0f%%' %
(energy, energy_round, energy_nrv, energy_nrv.quantize(
decimal.Decimal('.00'), rounding=decimal.ROUND_HALF_EVEN)),
text_color={True: "green", False: "red"}[correct])
elif event_np == '导入':
data = sg.clipboard_get()
data = data.split('\r\n') if '\r' in data else data.split('\n')
if len(data) == 6:
data = data[:-1]
if len(data) == 5:
for i, j, l in zip(
(0, 1, 2, 3, 4), data, (-6, -4, -4, -4, -6)):
window_item.find_element('00' + str(i)).update(j[:l])
window_item.find_element('status').update(
'导入成功!', text_color="black")
else:
window_item.find_element('status').update(
'导入失败,请检查复制内容!', text_color="black")
elif event_np == '清空':
for i in range(5):
window_item.find_element('0' + str(i).zfill(2)).update('')
for i in range(5, 16):
window_item.find_element('0' + str(i).zfill(2)).update('0')
window_item.find_element('status').update(
'准备就绪', text_color="black")
window_item.close()
def dehydration_win():
rc_11 = [
[sg.Text('鲜品水分', font=('微软雅黑', 12))],
[sg.Text('本品水分', font=('微软雅黑', 12))],
[sg.Text('铅(mg/kg)', font=('微软雅黑', 12))],
[sg.Text('总砷(mg/kg)', font=('微软雅黑', 12))],
[sg.Text('镉(mg/kg)', font=('微软雅黑', 12))],
[sg.Text('总汞(mg/kg)', font=('微软雅黑', 12))],
[sg.Text('铬(mg/kg)', font=('微软雅黑', 12))],
[sg.Text('其他限值一', font=('微软雅黑', 12))],
[sg.Text('其他限值二', font=('微软雅黑', 12))],
[sg.Text('其他限值三', font=('微软雅黑', 12))],
]
rc_12 = [
[sg.Input(key='00', size=(10, 1), font=('微软雅黑', 12))],
[sg.Input(key='01', size=(10, 1), font=('微软雅黑', 12))],
[sg.Input(key='02', size=(10, 1), default_text='0', font=('微软雅黑', 12))],
[sg.Input(key='03', size=(10, 1), default_text='0', font=('微软雅黑', 12))],
[sg.Input(key='04', size=(10, 1), default_text='0', font=('微软雅黑', 12))],
[sg.Input(key='05', size=(10, 1), default_text='0', font=('微软雅黑', 12))],
[sg.Input(key='06', size=(10, 1), default_text='0', font=('微软雅黑', 12))],
[sg.Input(key='07', size=(10, 1), default_text='0', font=('微软雅黑', 12))],
[sg.Input(key='08', size=(10, 1), default_text='0', font=('微软雅黑', 12))],
[sg.Input(key='09', size=(10, 1), default_text='0', font=('微软雅黑', 12))],
]
rc_13 = [
[sg.Text(key='10', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='11', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='12', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='13', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='14', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='15', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='16', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='17', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='18', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='19', size=(10, 1), font=('微软雅黑', 12))],
]
rc_14 = [
[sg.Text(size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='22', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='23', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='24', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='25', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='26', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='27', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='28', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='29', size=(10, 1), font=('微软雅黑', 12))],
]
rc_21 = [
[sg.Button('香菇', key='香菇', font=('微软雅黑', 10)), sg.Button('鲜枣', key='鲜枣', font=('微软雅黑', 10)),
sg.Button('葡萄', key='葡萄', font=('微软雅黑', 10)), sg.Button('木耳/银耳', key='木耳', font=('微软雅黑', 10)),
sg.Button('大白菜', key='大白菜', font=('微软雅黑', 10)), sg.Button('黄花菜', key='黄花菜', font=('微软雅黑', 10)),
sg.Button('芥菜', key='芥菜', font=('微软雅黑', 10)), sg.Button('青鳞鱼', key='青鳞鱼', font=('微软雅黑', 10))],
[sg.Button('鲢鱼', key='鲢鱼', font=('微软雅黑', 10)), sg.Button('豆角', key='豆角', font=('微软雅黑', 10)),
sg.Button('鱿鱼', key='鱿鱼', font=('微软雅黑', 10)), sg.Button('柠檬', key='柠檬', font=('微软雅黑', 10)),
sg.Button('柚', key='柚', font=('微软雅黑', 10)), sg.Button('西柚', key='西柚', font=('微软雅黑', 10)),
sg.Button('猪肉', key='猪肉', font=('微软雅黑', 10)), sg.Button('食用菌(除香菇外)', key='食用菌', font=('微软雅黑', 10))],
]
layout = [
[sg.Frame(layout=rc_11, title='项目', font=('微软雅黑', 12)),
sg.Frame(layout=rc_12, title='数值', font=('微软雅黑', 12)),
sg.Frame(layout=rc_13, title='结果(原始)', font=('微软雅黑', 12)),
sg.Frame(layout=rc_14, title='结果(修约)', font=('微软雅黑', 12))],
[sg.StatusBar('准备就绪', justification='center', key='status', font=('微软雅黑', 12), size=(10, 1))],
[sg.Button('计算', key='计算', font=('微软雅黑', 12)), sg.Button('清空', key='清空', font=('微软雅黑', 12)),
sg.Button('复制备注', key='备注', font=('微软雅黑', 12))],
[sg.Frame(layout=rc_21, title='常见样品', font=('微软雅黑', 12))]
]
return sg.Window(
'脱水率及限值计算',
layout,
enable_close_attempted_event=True,
element_justification='center',
icon=ICO,
finalize=True,
return_keyboard_events=True)
def dehydration():
set_theme()
window_item = dehydration_win()
remark = None
while True:
event_d, values_d = window_item.read(timeout=100)
if event_d == '-WINDOW CLOSE ATTEMPTED-':
break
elif event_d in ['计算', '\r']:
try:
del values_d['status']
numbers = [decimal.Decimal(i) for i in values_d.values()]
except decimal.InvalidOperation:
window_item.find_element('status').update('输入数值无效!')
continue
fresh = decimal.Decimal(numbers[0])
real = decimal.Decimal(numbers[1])
if fresh < real or real == decimal.Decimal('100'):
window_item.find_element('status').update('输入数值无效!')
continue
if fresh == decimal.Decimal('100'):
result = real / decimal.Decimal('100')
else:
result = ((fresh - real) / (decimal.Decimal('100') - real))
window_item.find_element('status').update(
'脱水率:%.1f%%' %
(result *
decimal.Decimal('100')).quantize(
decimal.Decimal('.000'),
rounding=decimal.ROUND_HALF_EVEN))
window_item.find_element('10').update(
'%.1f%%' %
fresh.quantize(
decimal.Decimal('.0'),
rounding=decimal.ROUND_HALF_EVEN))
window_item.find_element('11').update(
'%.1f%%' %
real.quantize(
decimal.Decimal('.000'),
rounding=decimal.ROUND_HALF_EVEN))
remark = []
for i, j in zip((2, 3, 4, 5, 6, 7, 8, 9), numbers[2:]):
if numbers[i] > decimal.Decimal('0'):
length = valid_numbers(str(numbers[i])) + '0'
window_item.find_element(
'1' + str(i)).update((numbers[i] / (1 - result)).quantize(decimal.Decimal('.000000'),
rounding=decimal.ROUND_HALF_EVEN))
cache = (
numbers[i] /
(
1 -
result)).quantize(
decimal.Decimal(length),
rounding=decimal.ROUND_HALF_EVEN)
window_item.find_element('2' + str(i)).update(cache)
if 2 <= i <= 6:
remark.append((DEHYDRATION_ITEMS[i], cache))
else:
window_item.find_element('1' + str(i)).update('0')
window_item.find_element('2' + str(i)).update('0')
elif event_d == '清空':
for i in range(10):
window_item.find_element('0' + str(i)).update('0')
window_item.find_element('status').update('准备就绪')
remark = None
elif event_d == '备注':
if not remark:
window_item.find_element('status').update('复制备注失败!')
continue
del values_d['status']
numbers = [decimal.Decimal(i) for i in values_d.values()]
fresh = decimal.Decimal(numbers[0])
real = decimal.Decimal(numbers[1])
items = ','.join('%s限量为%smg/kg' % i for i in remark)
if fresh == decimal.Decimal('100'):
result = real / decimal.Decimal('100')
text = '根据委托单位提供该产品的脱水率为%.1f%%。以此为依据,折算该样品%s。' % ((result * decimal.Decimal(
'100')).quantize(decimal.Decimal('.000'), rounding=decimal.ROUND_HALF_EVEN), items)
else:
result = (fresh - real) / (decimal.Decimal('100') - real)
text = '根据《中国食物成分表》中XXX水分含量%.1f%%,本品水分含量为%.1f%%,经过计算得出该产品的脱水率为%.1f%%。' \
'以此为依据,折算该样品%s。' % \
(fresh, real, (result * 100).quantize(decimal.Decimal('.000'), rounding=decimal.ROUND_HALF_EVEN),
items)
sg.clipboard_set(text)
window_item.find_element('status').update(
'脱水率:%.1f%%,复制备注成功!' %
(result *
decimal.Decimal('100')).quantize(
decimal.Decimal('.000'),
rounding=decimal.ROUND_HALF_EVEN))
elif event_d in LIMIT.keys():
for i in range(7):
window_item.find_element(
'0' +
str(i)).update(
LIMIT[event_d][i])
window_item.find_element('status').update('准备就绪')
remark = None
window_item.close()
def clipboard_win():
rc_11 = [
[sg.Button('微生物备注', key='00', font=('微软雅黑', 10))],
[sg.Button('监督抽检不判定结论', key='14', font=('微软雅黑', 10))],
[sg.Button('作废报告备注', key='15', font=('微软雅黑', 10))],
[sg.Button('标签审核结论', key='20', font=('微软雅黑', 10))],
[sg.Button('酒精度限值', key='01', font=('微软雅黑', 10))],
[sg.Button('阳性验证结论', key='16', font=('微软雅黑', 10))],
[sg.Button('甲基汞备注', key='18', font=('微软雅黑', 10))],
[sg.Button('多氯联苯备注', key='17', font=('微软雅黑', 10))],
]
rc_12 = [
[sg.Button('761 666检测限', key='02', font=('微软雅黑', 10))],
[sg.Button('761 DDT检测限', key='03', font=('微软雅黑', 10))],
[sg.Button('5009.19 666植物油检测限', key='04', font=('微软雅黑', 10))],
[sg.Button('5009.19 DDT植物油检测限', key='05', font=('微软雅黑', 10))],
[sg.Button('23200.13 666茶叶定量限', key='19', font=('微软雅黑', 10))],
]
rc_13 = [
[sg.Button('格式标签-预包装', key='06', font=('微软雅黑', 10))],
[sg.Button('格式标签-非预包装', key='07', font=('微软雅黑', 10))],
[sg.Button('详细标签-实物', key='08', font=('微软雅黑', 10))],
[sg.Button('详细标签-电子版', key='09', font=('微软雅黑', 10))],
[sg.Button('详细标签-无许可证电子版', key='10', font=('微软雅黑', 10))],
[sg.Button('详细标签-非预包装电子版', key='11', font=('微软雅黑', 10))],
[sg.Button('详细标签-非预包装实物版', key='12', font=('微软雅黑', 10))],
[sg.Button('详细标签-样版标签', key='13', font=('微软雅黑', 10))],
]
layout = [
[sg.Frame(layout=rc_11, title='未分类', font=('微软雅黑', 12)),
sg.Frame(layout=rc_12, title='检测限', font=('微软雅黑', 12)),
sg.Frame(layout=rc_13, title='标签备注', font=('微软雅黑', 12))],
]
return sg.Window(
'常用文本剪贴板(点击按钮复制相应文本)',
layout,
enable_close_attempted_event=True,
element_justification='center',
icon=ICO,
finalize=True)
def clipboard():
set_theme()
window_item = clipboard_win()
while True:
event_d, values_d = window_item.read(timeout=100)
if event_d == '-WINDOW CLOSE ATTEMPTED-':
break
elif event_d in [str(i).zfill(2) for i in range(21)]:
sg.clipboard_set(TEXT[event_d])
window_item.close()
def solid_drink_win():
rc_11 = [
[sg.Text('样品量(g)', font=('微软雅黑', 12))],
[sg.Text('水(ml)', font=('微软雅黑', 12))],
[sg.Text('苯甲酸', font=('微软雅黑', 12))],
[sg.Text('山梨酸', font=('微软雅黑', 12))],
[sg.Text('苋菜红', font=('微软雅黑', 12))],
[sg.Text('柠檬黄', font=('微软雅黑', 12))],
[sg.Text('胭脂红', font=('微软雅黑', 12))],
[sg.Text('其他限值一', font=('微软雅黑', 12))],
[sg.Text('其他限值二', font=('微软雅黑', 12))],
[sg.Text('其他限值三', font=('微软雅黑', 12))],
]
rc_12 = [
[sg.Input(key='00', size=(10, 1), font=('微软雅黑', 12))],
[sg.Input(key='01', size=(10, 1), font=('微软雅黑', 12))],
[sg.Input('0', key='02', size=(10, 1), font=('微软雅黑', 12))],
[sg.Input('0', key='03', size=(10, 1), font=('微软雅黑', 12))],
[sg.Input('0', key='04', size=(10, 1), font=('微软雅黑', 12))],
[sg.Input('0', key='05', size=(10, 1), font=('微软雅黑', 12))],
[sg.Input('0', key='06', size=(10, 1), font=('微软雅黑', 12))],
[sg.Input('0', key='07', size=(10, 1), font=('微软雅黑', 12))],
[sg.Input('0', key='08', size=(10, 1), font=('微软雅黑', 12))],
[sg.Input('0', key='09', size=(10, 1), font=('微软雅黑', 12))],
]
rc_13 = [
[sg.Text(size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(size=(5, 1), font=('微软雅黑', 12))],
[sg.Text(key='12', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='13', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='14', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='15', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='16', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='17', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='18', size=(10, 1), font=('微软雅黑', 12))],
[sg.Text(key='19', size=(10, 1), font=('微软雅黑', 12))],
]
rc_21 = [
[sg.Button('饮料大类', key='饮料', font=('微软雅黑', 10)),
sg.Button('果蔬汁类饮料', key='果蔬汁', font=('微软雅黑', 10)),
sg.Button('植物蛋白饮料', key='植物蛋白', font=('微软雅黑', 10))],
[sg.Button('含乳饮料', key='含乳', font=('微软雅黑', 10)),
sg.Button('碳酸饮料', key='碳酸', font=('微软雅黑', 10)),
sg.Button('风味饮料', key='风味', font=('微软雅黑', 10)),
sg.Button('果味饮料', key='果味', font=('微软雅黑', 10))],
]
layout = [
[sg.Frame(layout=rc_11, title='项目', font=('微软雅黑', 12)),
sg.Frame(layout=rc_12, title='原始数值', font=('微软雅黑', 12)),
sg.Frame(layout=rc_13, title='结果数值', font=('微软雅黑', 12))],
[sg.Button('计算', key='计算', font=('微软雅黑', 12)),
sg.Button('清空', key='清空', font=('微软雅黑', 12)),
sg.Button('复制备注', key='备注', font=('微软雅黑', 12))],
[sg.StatusBar('准备就绪', justification='center',
key='status', font=('微软雅黑', 12), size=(10, 1))],
[sg.Frame(layout=rc_21, title='常见固体饮料', font=('微软雅黑', 12))],
]
return sg.Window(
'固体饮料限值计算',
layout,
enable_close_attempted_event=True,
element_justification='center',
icon=ICO,
finalize=True,
return_keyboard_events=True)
def solid_drink():
set_theme()
window_item = solid_drink_win()
remark = None
while True:
event_s, values_s = window_item.read(timeout=100)
if event_s == '-WINDOW CLOSE ATTEMPTED-':
break
elif event_s in ['计算', '\r']:
try:
del values_s['status']
numbers = [decimal.Decimal(i) for i in values_s.values()]
window_item.find_element('status').update('准备就绪')
except decimal.InvalidOperation:
window_item.find_element('status').update('输入数值无效!')
continue
if decimal.Decimal('0') in numbers[:2]:
window_item.find_element('status').update('输入数值无效!')
continue
multiple = (numbers[0] + numbers[1]) / numbers[0]
length_m = valid_numbers(str(multiple), min_=True)
window_item.find_element('status').update(
'倍数:%s' %
multiple.quantize(
decimal.Decimal(length_m),
rounding=decimal.ROUND_HALF_EVEN))