Python Forum
PysimpleGUI window update dynamically
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PysimpleGUI window update dynamically
#1
Hi all,
I made a tool checking IQR value in CSV, but I feel so stupid with my code, such as loading text control, and update value.
Can someone help me make a class for that as screenshots?
1)More parameter checking only copy a class.
2)when check file without goldensample how to handle this issue.


import PySimpleGUI as sg
import pandas as pd
import glob,os
from datetime import datetime
import numpy as np
import re
from decimal import Decimal


sg.theme('Topanga')


left_part= [
    [sg.Text('',size=(50,0),font=("Helvetica",10),text_color='red',justification="center",auto_size_text=True,key='Sens1K')],

    [sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site1-'),
    sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site2-'),
    sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site3-'),
    sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site4-'),
    sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site5-'),
    sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site6-'),
    sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site7-')],

    [sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site8-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site9-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site10-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site11-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site12-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site13-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site14-')],

    [sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site15-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site16-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site17-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site18-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site19-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site20-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site21-')],

    [sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site22-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site23-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site24-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site25-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site26-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site27-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site28-')],

    [sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site29-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site30-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site31-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site32-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site33-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site34-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-site35-')],



    [sg.Text('',size=(50,0),font=("Helvetica",10),text_color='red',justification="center",auto_size_text=True,key='Sens10K')],

    [sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite1-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite2-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite3-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite4-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite5-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite6-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite7-')],

    [sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite8-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite9-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite10-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite11-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite12-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite13-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite14-')],

    [sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite15-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite16-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite17-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite18-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite19-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite20-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite21-')],

    [sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite22-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite23-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite24-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite25-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite26-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite27-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite28-')],

    [sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite29-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite30-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite31-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite32-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite33-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite34-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-10ksite35-')],

]



right_part=[
    [sg.Text('',size=(50,0),font=("Helvetica",10),text_color='red',justification="center",auto_size_text=True,key='Sens8K')],

    [sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite1-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite2-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite3-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite4-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite5-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite6-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite7-')],

    [sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite8-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite9-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite10-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite11-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite12-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite13-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite14-')],

    [sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite15-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite16-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite17-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite18-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite19-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite20-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite21-')],

    [sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite22-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite23-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite24-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite25-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite26-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite27-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite28-')],

    [sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite29-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite30-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite31-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite32-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite33-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite34-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",key='-8ksite35-')],





    [sg.Text('',size=(45,0),font=("Helvetica",10),text_color='red',justification="center",auto_size_text=True,key='Sens0K')],

    [sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite1-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite2-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite3-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite4-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite5-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite6-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite7-')],

    [sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite8-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite9-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite10-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite11-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite12-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite13-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite14-')],

    [sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite15-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite16-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite17-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite18-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite19-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite20-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite21-')],

    [sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite22-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite23-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite24-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite25-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite26-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite27-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite28-')],

    [sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite29-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite30-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite31-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite32-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite33-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite34-'),
     sg.Text('',size=(12,1),font=("Helvetica",8),background_color='white',text_color='black',justification="center",visible = False,key='-0ksite35-')],

]




BNT = [
    [sg.Text("Tester"),sg.Combo(values=['CAMEMSNIOSAI11','CAMEMSNIOSAI21','CAMEMSNIOSAI31','CAMEMSNIOSAI41','CAMEMSNIOSAI51'],default_value='CAMEMSNIOSAI11',key='-Tester-'),
     sg.Text("Project"),sg.Combo(values=['P020','P027','P025','P033'],default_value='P020',key='-Model-')],

    [sg.Radio('FR Check',group_id="RadioDemo",default=True,size=(10,1),k='-R1-'),sg.Radio('Phase Check',group_id="RadioDemo",default=False,size=(15,1),k='-R2-')],

    [sg.Text(""),sg.Text('TestLot:'),sg.Text('',size=(20,0),font=("Helvetica",10),text_color='red',
        justification="left",key='-testlot-'),sg.Text('Testdate:'),
        sg.Text('',size=(20,0),font=("Helvetica",10),
        text_color='red',justification="left",key='-testdate-')],

    [sg.Text("",size=(1,0)),sg.OK('Check Master',key='OK'),sg.Exit(size=(5,0))]
]


layout = [
    [BNT,sg.Column(left_part, vertical_alignment='top'), sg.VSeparator(),sg.Column(right_part, vertical_alignment='top')],
]




window=sg.Window('Master Check',layout,font='Courier 12')


working_directory = os.getcwd()



IQR_path=r'C:\Users\Desktop\111'



Standard_median=-38.25
# CAMEMSNIOSAI11_P020=-38.25
# CAMEMSNIOSAI11_P027=-38.16
# CAMEMSNIOSAI21_P020=-38.25
# CAMEMSNIOSAI21_P027=-38.16
# CAMEMSNIOSAI31_P020=-38.25
# CAMEMSNIOSAI31_P027=-38.16
# CAMEMSNIOSAI41_P020=-38.25
# CAMEMSNIOSAI41_P027=-38.16
# CAMEMSNIOSAI51_P020=-38.35
# CAMEMSNIOSAI51_P027=-38.16
# CAMEMSNIOSAI61_P025=-34.0
# CAMEMSNIOSAI71_P025=-34.0
# CAMEMSNIOSAI71_P033=-34.0
# CAMEMSNIOSAI81_P025=-34.0
# CAMEMSNIOSAI81_P033=-34.0
# CAMEMSNIOSAI91_P025=-34.0
# CAMEMSNIOSAI91_P033=-34.0


# def standard_median(tester,project):
#     tester_model=tester+"_"+project
#     print(tester_model)





def read_csv(csv_add,tester,checkmodel,project):
    Sens1K=[]
    paint0=[]
    Sens8K=[]
    paint1=[]
    Sens10k=[]
    paint2=[]

    Noise=[]
    paint3=[]
    Phase1k=[]
    paint4=[]
    Phase3k=[]
    paint5=[]
    Phase10k=[]
    paint6=[]

    df=pd.read_csv(csv_add,header=2)
    df=df[df['Lot Code'].str.contains("golden")]
    df.columns = df.columns.str.split('.').str[0]
    lotnum=df['Lot Code'].tail(1).squeeze()
    testtime=df['Lot Finish Time'].tail(1).squeeze()
    try:
            Sens1k_raw=df['DUT_NM_Sens_Corr1000Hz_94SPL__Median'].tail(1).squeeze()
            Sens8K_raw=df['DUT_NM_relativeSens8000Hz_RFR_Median'].tail(1).squeeze()
            Sens10K_raw=df['DUT_NM_relativeSens10000Hz_RFR_Median'].tail(1).squeeze()

            NM_Noise_raw=df['DUT_NM_Noise_Median'].tail(1).squeeze()
            Phase1k_raw=df['DUT_Phase1kHz_RPR_Median'].tail(1).squeeze()
            Phase3k_raw=df['DUT_Phase3kHz_RPR_Median'].tail(1).squeeze()
            Phase10K_raw=df['DUT_Phase10kHz_RPR_Median'].tail(1).squeeze()

            for sens1k in Sens1k_raw:
                if sens1k!=0:
                    tt=sens1k-Standard_median
                    Sens1K.append(Decimal(tt).quantize(Decimal("0.00")))
                    paint0.append(compared_Sens(tt,0.3,0.2,0.1))
                else:
                    Sens1K.insert(len(Sens1K),np.nan)
                    paint0.insert(len(paint0),'white')
            for sens8k in Sens8K_raw:
                if sens8k!=0:
                    Sens8K.append(Decimal(sens8k).quantize(Decimal("0.00")))
                    paint1.append(compared_Sens(sens8k,1,0.6,0.3))
                else:
                    Sens8K.insert(len(Sens8K),np.nan)
                    paint1.insert(len(paint1),'white')
            for sens10k in Sens10K_raw:
                if sens10k != 0:
                    Sens10k.append(Decimal(sens10k).quantize(Decimal("0.00")))
                    paint2.append(compared_Sens(sens10k,1,0.6,0.3))
                else:
                    Sens10k.insert(len(Sens10k),np.nan)
                    paint2.insert(len(paint2),'white')



            for noise in NM_Noise_raw:
                if noise!=0:
                    Noise.append(Decimal(noise).quantize(Decimal("0.00")))
                    paint3.append(compared_Noise(noise,103.2,102.5,102))
                else:
                    Noise.insert(len(Noise),np.nan)
                    paint3.insert(len(paint3),'white')

            for phase1k in Phase1k_raw:
                if phase1k!=0:
                    Phase1k.append(Decimal(phase1k).quantize(Decimal("0.00")))
                    paint4.append(compared_Sens(phase1k,1,0.8,0.5))
                else:
                    Phase1k.insert(len(Phase1k),np.nan)
                    paint4.insert(len(paint4),'white')
            for phase3k in Phase3k_raw:
                if phase1k!=0:
                    Phase3k.append(Decimal(phase3k).quantize(Decimal("0.00")))
                    paint5.append(compared_Sens(phase3k,1.5,1,0.5))
                else:
                    Phase3k.insert(len(Phase3k),np.nan)
                    paint5.insert(len(paint5),'white')
            for phase10k in Phase10K_raw:
                if phase10k!=0:
                    Phase10k.append(Decimal(phase10k).quantize(Decimal("0.00")))
                    paint6.append(compared_Sens(phase10k,4,3,1.5))
                else:
                    Phase10k.insert(len(Phase10k),np.nan)
                    paint6.insert(len(paint6),'white')

            now = datetime.now()  # current date and time
            date_time = now.strftime("%m/%d/%Y-%H:%M:%S")
            ab=pd.Series([tester,date_time]).to_frame().T
            aa=pd.DataFrame(Sens1K).T
            bb=pd.DataFrame(Sens8K).T
            cc=pd.DataFrame(Sens10k).T


            dd=pd.DataFrame(Phase1k).T
            ee=pd.DataFrame(Phase3k).T
            ff=pd.DataFrame(Phase10k).T
            gg=pd.DataFrame(Noise).T

            if checkmodel=='Sens':
                result= np.concatenate([ab,aa,bb,cc],axis=1)
                result=pd.DataFrame(result)
                result.to_csv(r'sens_log.csv',mode='a',index=False,header=False)
            else:
                result1= np.concatenate([ab,dd,ee,ff,gg],axis=1)
                result1=pd.DataFrame(result1)
                result1.to_csv(r'phase_log.csv',mode='a',index=False,header=False)
    except Exception as e:
         print(e)

    return Sens1K,paint0,Sens8K,paint1,Sens10k,paint2,Noise,paint3,Phase1k,paint4,Phase3k,paint5,Phase10k,paint6,lotnum,testtime


def compared_Sens(val,limit1,limit2,limit3):   # 0.3,0.2,0.1
    if np.abs(val)>limit1:
        text_color='Dark Red'
    elif np.abs(val)>limit2:
        text_color='Red'
    elif np.abs(val)>limit3:
        text_color = 'orange'
    elif pd.isnull(val):
        text_color='White'
    else:
        text_color='Green'
    return text_color


def compared_Noise(val,limit1,limit2,limit3):    #  103.2,102.5,102
    if np.abs(val)>limit1:
        text_color='green'
    elif np.abs(val)>limit2:
        text_color='orange'
    elif np.abs(val)>limit3:
        text_color = 'red'
    elif pd.isnull(val):
        text_color='White'
    else:
        text_color='dark red'
    return text_color


while True:

    event,value = window.read()

    if event in (sg.WIN_CLOSED,'Exit'):
        break
    elif event == "OK":
        for j in range(0,35):
            window[f'-site{j+1}-'].update('',background_color='white')
            window[f'-8ksite{j+1}-'].update('',background_color='white')
            window[f'-10ksite{j+1}-'].update('',background_color='white')
            window[f'-0ksite{j+1}-'].update('',background_color='white')

        try:
             if value['-R1-']==True:
                    model='Sens'
                    for k in range(0,35):
                             window.Element(f'-0ksite{k+1}-').Update(visible=False)
                    window.Element('Sens0K').Update(visible=False)
                    window['Sens1K'].update('DUT_NM_Sens_Corr1000Hz_94SPL__Median')
                    window['Sens8K'].update('DUT_NM_relativeSens8000Hz_RFR_Median')
                    window['Sens10K'].update('DUT_NM_relativeSens10000Hz_RFR_Median')
                    Tester=value['-Tester-']
                    project=value['-Model-']
                    IQR_files=os.path.join(IQR_path,project,'ENG\IQR\*.csv')
                    IQR_all=glob.glob(IQR_files)
                    IQR_all.sort(key=lambda file_name:os.path.getmtime(file_name),reverse=True)
                    for file_IQR in IQR_all:
                        FP=re.findall(Tester,file_IQR)
                        FP="".join(FP)
                        if FP==Tester:
                            Sens1k,paint0,Sens8k,paint1,Sens10k,paint2,Noise,paint3,Phase1k,paint4,Phase3k,paint5,Phase10k,paint6,lotnum,testtime=read_csv(file_IQR,Tester,model,project)
                            break
                    window['-testlot-'].update(lotnum)
                    window['-testdate-'].update(testtime)
                    for j in range(0,35):
                        window[f'-site{j+1}-'].update(f'Site{j+1}:{Sens1k[j]}',background_color=paint0[j])
                        window[f'-8ksite{j+1}-'].update(f'Site{j+1}:{Sens8k[j]}',background_color=paint1[j])
                        window[f'-10ksite{j+1}-'].update(f'Site{j+1}:{Sens10k[j]}',background_color=paint2[j])
             else:

                 model = 'Phase'
                 for k in range(0,35):
                     window.Element(f'-0ksite{k+1}-').Update(visible=True)
                 window.Element('Sens0K').Update(visible=True)
                 window['Sens1K'].update('DUT_Phase1kHz_RPR_Median')
                 window['Sens8K'].update('DUT_Phase3kHz_RPR_Median')
                 window['Sens10K'].update('DUT_Phase10kHz_RPR_Median')
                 window['Sens0K'].update('DUT_NM_Noise_Median')
                 Tester = value['-Tester-']
                 project = value['-Model-']
                 IQR_files = os.path.join(IQR_path, project, 'ENG\IQR\*.csv')
                 IQR_all = glob.glob(IQR_files)
                 IQR_all.sort(key=lambda file_name: os.path.getmtime(file_name), reverse=True)
                 for file_IQR in IQR_all:
                     FP = re.findall(Tester,file_IQR)
                     FP = "".join(FP)
                     if FP == Tester:
                         Sens1k,paint0,Sens8k,paint1,Sens10k,paint2,Noise,paint3,Phase1k,paint4,Phase3k,paint5,Phase10k,paint6,lotnum,testtime=read_csv(file_IQR,Tester,model,project)
                         break
                 window['-testlot-'].update(lotnum)
                 window['-testdate-'].update(testtime)
                 for j in range(0,35):
                     window[f'-site{j+1}-'].update(f'Site{j+1}:{Phase1k[j]}',background_color=paint4[j])
                     window[f'-8ksite{j+1}-'].update(f'Site{j+1}:{Phase3k[j]}',background_color=paint5[j])
                     window[f'-10ksite{j+1}-'].update(f'Site{j+1}:{Phase10k[j]}',background_color=paint6[j])
                     window[f'-0ksite{j+1}-'].update(f'Site{j+1}:{Noise[j]}',background_color=paint3[j])

        except Exception as e:
            print(e)


window.close()
Reply
#2
]Can you describe what you mean by this:
Quote:Can someone help me make a class for that as screenshots?
1)More parameter checking only copy a class.
2)when check file without goldensample how to handle this issue.
I might understand what you mean with goldensample. You are wondering what to do if this is an empty dataframe.
 df = pd.read_csv(csv_add, header=2)
    df = df[df["Lot Code"].str.contains("golden")]
I would have the readcsv() function return None if is no golden data in the file.
import pandas as pd


def read_csv():
    df = pd.DataFrame(
        {"Lot Code": ["G", "B", "G"], "Numbers": [5, 6, 7], "Letters": ["A", "B", "C"]}
    )
    df = df[df["Lot Code"].str.contains("G")]
    if len(df) == 0:
        return None
    return df["Numbers"].values, df["Letters"].values


x = read_csv()
if x is None:
    sg.popup("Error", "There's no golden data!")
else:
    numbers, letters = x
    print(numbers, letters)
Reply
#3
Thank you for your replied. Sorry for my English is poor.
1)Define windows text control so complicated if have a good way to do that.
2)The windows need to check 3 parameters if possible make a class and then quoted this class to others parament show.
3)How to handle if miss Golden string in file.

Thanks in advance!!

Attached Files

Thumbnail(s)
   

.csv   CAMEMSNIOSAI11_Statistic.csv (Size: 49.82 KB / Downloads: 81)
.csv   CAMEMSNIOSAI51_Statistic.csv (Size: 40.07 KB / Downloads: 76)
Reply
#4
To answer your question.

1. There is a much easier way to make a matrix of controls. You should look at all the pysimplegui examples.

This shows how to make a minesweeper game: https://www.pysimplegui.org/en/latest/co...of-buttons

Replace the Button object with a Text object and you have a grid of text objects with very little code.

2. Can you describe the parameter checking in more detail?

3. I answered this question in my first post. Read the CSV file. Filter to only contain Golden rows. Inform the user if there were no golden rows in the data, otherwise update the values.
Reply
#5
Many thanks,I tried to change step1 define as below.

But all the control in one column,how to split to two columns or more.


import PySimpleGUI as sg

sg.theme('Topanga')


left_part= [
    [sg.Text('',size=(45,0),font=("Helvetica",10),text_color='red',justification="center",auto_size_text=True,key='Sens1K')],


    [[sg.InputText(size=(10,1),pad=(2,2),key=f'site{row}{col}')for col in range(7)]for row in range(5)],


    [sg.Text('',size=(45,0),font=("Helvetica",10),text_color='red',justification="center",auto_size_text=True,key='Sens10K')],

    [[sg.InputText(size=(10,1),pad=(2,2),key=f'3ksite{row}{col}')for col in range(7)]for row in range(5)],

]

right_part=[
    [sg.Text('',size=(45,0),font=("Helvetica",10),text_color='red',justification="center",auto_size_text=True,key='Sens8K')],

    [[sg.InputText(size=(10, 1), pad=(2, 2), key=f'8ksite{row}{col}') for col in range(7)] for row in range(5)],

    [sg.Text('',size=(40, 0), font=("Helvetica", 10), text_color='red', justification="center", auto_size_text=True,key='Sens0K')],

    [[sg.InputText(size=(10, 1), pad=(2, 2), key=f'10ksite{row}{col}') for col in range(7)] for row in range(5)],
]

BNT = [
    [sg.Text("Tester"),sg.Combo(values=['CAMEMSNIOSAI11','CAMEMSNIOSAI21','CAMEMSNIOSAI31','CAMEMSNIOSAI41','CAMEMSNIOSAI51'],default_value='CAMEMSNIOSAI11',key='-Tester-'),
     sg.Text("Project"),sg.Combo(values=['P020','P027','P025','P033'],default_value='P020',key='-Model-')],

    [sg.Radio('FR Check',group_id="RadioDemo",default=True,size=(10,1),k='-R1-'),sg.Radio('Phase Check',group_id="RadioDemo",default=False,size=(15,1),k='-R2-')],

    [sg.Text(""),sg.Text('TestLot:'),sg.Text('',size=(20,0),font=("Helvetica",10),text_color='red',
        justification="left",key='-testlot-'),sg.Text('Testdate:'),
        sg.Text('',size=(20,0),font=("Helvetica",10),
        text_color='red',justification="left",key='-testdate-')],

    [sg.Text("",size=(1,0)),sg.OK('Check Master',key='OK'),sg.Exit(size=(5,0))]
]

layout = [
    [BNT,left_part,right_part]
]


window=sg.Window('Master Check',layout,font='Courier 12',finalize=True)



while True:

    event,value = window.read()

    if event in (sg.WIN_CLOSED,'Exit'):
        break
    elif event == "OK":

        print("Hello World!")

window.close()

Attached Files

Thumbnail(s)
       
Reply
#6
Look at the cookbook. If you want two columns, use columns.

https://www.pysimplegui.org/en/latest/co...le-columns
Reply
#7
I appreciate your help. I changed it again, seems like the control definition is ok.
The last version is read "checkmaster_config.ini"(upload file need to change the suffix from .txt to .ini),selected different model dynamic updated columns name list and limit to each section, such P020&P025read out:
[P020]
item1=DUT_NM_Sens_Corr1000Hz_94SPL__Median,0.3,0.2,0.1
item2=DUT_NM_relativeSens8000Hz_RFR_Median,1,0.6,0.3
item3=DUT_NM_relativeSens10000Hz_RFR_Median,1,0.6,0.3
item4=DUT_NM_Noise_Median,102,102.5,103.2
item5=DUT_Phase1kHz_RPR_Median,1,0.8,0.5
item6=DUT_Phase3kHz_RPR_Median,1.5,1,0.5
item7=DUT_Phase10kHz_RPR_Median,4,3,1.5

[P025]
item1=Sensitivity 1000 Settled_Median,0.3,0.2,0.1
item2=DUT Phase 1kHz_Median,1,0.8,0.5
item3=Dut Sens 3kHz_Median,0.3,0.2,0.1
item4=Dut Phase 3kHz_Median,1.5,1,0.5
item5=DUT Sens 8kHz_Median,1,0.6,0.3
itme6=DUT Sens 10kHz_Median,1,0.6,0.3
item7=Dut Phase 10kHz_Median,4,3,1.5
itme8=DUT_NM_Noise_Median,Median,1,102,102.68,103

Please help to point out where have a chance to modify it,I feel this code is not concise.





import PySimpleGUI as sg
import pandas as pd
import glob,os
from datetime import datetime
import numpy as np
import re
from decimal import Decimal
from pathlib import Path
import configparser


sg.theme('Topanga')

left_part = [
    [sg.Text('', size=(45, 0),font=("Helvetica",10),text_color='red',justification='center',auto_size_text=True,
             key='Data1')],
    *[[sg.InputText(size=(12,1),font=("Helvetica",8),background_color='white',justification='center',text_color='black',
                   pad=(2,2),key=f'partA{row}{col}') for col in range(7)] for row in range(5)],
    [sg.Text('', size=(45, 0), font=("Helvetica", 10), text_color='red', justification='center', auto_size_text=True,
             key='Data2')],
    *[[sg.InputText(size=(12,1),font=("Helvetica",8),background_color='white',justification='center',text_color='black',
                    pad=(2,2),key=f'partB{row}{col}') for col in range(7)] for row in range(5)],

]

right_part = [
    [sg.Text('', size=(45, 0), font=("Helvetica", 10), text_color='red', justification='center',auto_size_text=True,
             key='Data3')],
    *[[sg.InputText(size=(12,1),font=("Helvetica",8),background_color='white',justification='center',text_color='black',
                   pad=(2,2),key=f'partC{row}{col}') for col in range(7)] for row in range(5)],
    [sg.Text('', size=(40, 0), font=("Helvetica",10), text_color='red', justification='center',auto_size_text=True,
             visible = False,key='Data4')],
    *[[sg.InputText(size=(12,1),font=("Helvetica",8),background_color='white',justification='center',text_color='black',
                    pad=(2,2),visible = False,key=f'partD{row}{col}') for col in range(7)] for row in range(5)],
]

BNT = [
    [sg.Text("Tester"),
     sg.Combo(values=['CAMEMSNIOSAI11', 'CAMEMSNIOSAI21', 'CAMEMSNIOSAI31', 'CAMEMSNIOSAI41', 'CAMEMSNIOSAI51',
                      'CAMEMSNIOSAI61', 'CAMEMSNIOSAI71', 'CAMEMSNIOSAI81', 'CAMEMSNIOSAI91', 'CAMEMSNIOSAI101'],
              default_value='CAMEMSNIOSAI11', key='-Tester-'),
     sg.Text("Project"), sg.Combo(values=['P020','P027','P025','P033'], default_value='P020', key='-Model-')],

    [sg.Radio('FR Check', group_id="RadioDemo", default=True, size=(10, 1), k='-R1-'),
     sg.Radio('Phase Check', group_id="RadioDemo", default=False, size=(15, 1), k='-R2-')],

    [sg.Text('TestLot:'), sg.Text('', size=(20, 0), font=("Helvetica", 10), text_color='red',
                                               justification="left", key='-testlot-'), sg.Text('Testdate:'),
     sg.Text('', size=(20, 0), font=("Helvetica", 10),
             text_color='red', justification="left", key='-testdate-')],

    [sg.OK('Check Master', key='OK'), sg.Exit(size=(5, 0))]
]

layout = [
    [BNT,sg.Column(left_part,vertical_alignment='top'),sg.VSeparator(),sg.Column(right_part,vertical_alignment='top')],
]

window=sg.Window('Master Check',layout,font='Courier 12')

working_directory = os.getcwd()
IQR_path=r'C:\Users\Desktop\111'




def read_csv(csv_add,tester,checkmodel,fullname,project):

    part1_data,paint1,part2_data,paint2,part3_data,paint3,part4_data,paint4,\
    part5_data,paint5,part6_data,paint6,part7_data,paint7=([] for i in range(14))

    SETTINGS_PATH = Path.cwd()
    # create the settings object and use ini format
    settings = sg.UserSettings(path=SETTINGS_PATH, filename="checkmaster_config.ini",
                               use_config_file=True, convert_bools_and_none=True)

    sens_val=float(settings['Sens'][f'{fullname}'])

    file_path=os.path.join(SETTINGS_PATH,'checkmaster_config.ini')

    config = configparser.ConfigParser()  # 类实例化

    config.read(file_path)

    val = dict(config.items(project))

    resources = {}
    for line in val.values():
        key, value = line.rstrip().split(',', 1)
        resources[key] = value
    item_all=list(resources.keys())
    limit_all = list(resources.values())

    df=pd.read_csv(csv_add,header=2)
    df=df[df['Lot Code'].str.contains("golden")]
    df.columns = df.columns.str.split('.').str[0]
    lotnum=df['Lot Code'].tail(1).squeeze()
    testtime=df['Lot Finish Time'].tail(1).squeeze()
    try:
            part1_raw=df[item_all[0]].tail(1).squeeze()
            part2_raw=df[item_all[1]].tail(1).squeeze()
            part3_raw=df[item_all[2]].tail(1).squeeze()
            part4_raw=df[item_all[3]].tail(1).squeeze()
            part5_raw=df[item_all[4]].tail(1).squeeze()
            part6_raw=df[item_all[5]].tail(1).squeeze()
            part7_raw=df[item_all[6]].tail(1).squeeze()

            for part1 in part1_raw:
                if part1!=0:
                    tt= part1-sens_val
                    part1_data.append(Decimal(tt).quantize(Decimal("0.00")))
                    a, b, c =limit_all[0].split(',')
                    a=float(a)
                    b=float(b)
                    c=float(c)
                    paint1.append(compared_Sens(tt,a,b,c))
                else:
                    part1_data.insert(len(part1_data), np.nan)
                    paint1.insert(len(paint1), 'white')

            part2_data,paint2=assign_data(part2_raw,limit_all[1])
            part3_data,paint3=assign_data(part3_raw,limit_all[2])

            for part4 in part4_raw:
                if part4!=0:
                    a, b, c =limit_all[0].split(',')
                    a=float(a)
                    b=float(b)
                    c=float(c)
                    part4_data.append(Decimal(part4).quantize(Decimal("0.00")))
                    paint4.append(compared_Noise(part4,a,b,c))
                else:
                    part4_data.insert(len(part4_data), np.nan)
                    paint4.insert(len(paint4), 'white')

            part5_data,paint5=assign_data(part5_raw,limit_all[4])
            part6_data,paint6=assign_data(part6_raw,limit_all[5])
            part7_data,paint7=assign_data(part7_raw,limit_all[6])

            now = datetime.now()  # current date and time
            date_time = now.strftime("%m/%d/%Y-%H:%M:%S")
            ab=pd.Series([tester,date_time]).to_frame().T
            aa=pd.DataFrame(part1_data).T
            bb=pd.DataFrame(part2_data).T
            cc=pd.DataFrame(part3_data).T


            dd=pd.DataFrame(part5_data).T
            ee=pd.DataFrame(part6_data).T
            ff=pd.DataFrame(part7_data).T
            gg=pd.DataFrame(part4_data).T

            if checkmodel=='Sens':
                result= np.concatenate([ab,aa,bb,cc],axis=1)
                result=pd.DataFrame(result)
                result.to_csv(r'sens_log.csv',mode='a',index=False,header=False)
            else:
                result1= np.concatenate([ab,dd,ee,ff,gg],axis=1)
                result1=pd.DataFrame(result1)
                result1.to_csv(r'phase_log.csv',mode='a',index=False,header=False)
    except Exception as e:
         print(e)
         return None

    return part1_data,paint1,part2_data,paint2,part3_data,paint3,part4_data,paint4,\
           part5_data,paint5,part6_data,paint6,part7_data,paint7,lotnum,testtime


def assign_data(raw_data,limit):
    arr,paintcolor=([] for i in range(2))

    a, b, c = limit.split(',')
    a = float(a)
    b = float(b)
    c = float(c)

    for noise in raw_data:
        if noise != 0:
            arr.append(Decimal(noise).quantize(Decimal("0.00")))
            paintcolor.append(compared_Sens(noise,a,b,c))
        else:
            arr.insert(len(arr),np.nan)
            paintcolor.insert(len(paintcolor),'white')

    return arr,paintcolor


def compared_Sens(val,limit1,limit2,limit3):   # 0.3,0.2,0.1
    if np.abs(val)>limit1:
        text_color='Dark Red'
    elif np.abs(val)>limit2:
        text_color='Red'
    elif np.abs(val)>limit3:
        text_color = 'orange'
    elif pd.isnull(val):
        text_color='White'
    else:
        text_color='Green'
    return text_color


def compared_Noise(val,limit1,limit2,limit3):    #  103.2,102.5,102
    if np.abs(val)>limit1:
        text_color='green'
    elif np.abs(val)>limit2:
        text_color='orange'
    elif np.abs(val)>limit3:
        text_color = 'red'
    elif pd.isnull(val):
        text_color='White'
    else:
        text_color='dark red'
    return text_color


while True:

    event, value = window.read()
    if event in (sg.WIN_CLOSED, 'Exit'):
        break
    elif event == "OK":

      for row in range(5):
          for col in range(7):
              window[f'partA{row}{col}'].update('',background_color='white')
              window[f'partB{row}{col}'].update('',background_color='white')
              window[f'partC{row}{col}'].update('',background_color='white')
              window[f'partD{row}{col}'].update('',background_color='white')
              window.Element(f'partD{row}{col}').Update(visible=False)
      window.Element('Data4').Update(visible=False)
      window['Data1'].update('')
      window['Data2'].update('')
      window['Data3'].update('')
      window['Data4'].update('')

      window['-testlot-'].update('')
      window['-testdate-'].update('')

      Tester=value['-Tester-']
      project=value['-Model-']

      fullname=Tester+'_'+project

      IQR_files=os.path.join(IQR_path,project,'ENG\IQR\*_Statistic.csv')
      IQR_all=glob.glob(IQR_files)
      IQR_all.sort(key=lambda file_name:os.path.getmtime(file_name),reverse=True)
      if len(IQR_all)!=0:
          for file_IQR in IQR_all:
              FP = re.findall(Tester, file_IQR)
              FP = "".join(FP)
              if len(FP)!=0:
                  if FP == Tester:
                          # sample_path = file_IQR
                          if value['-R1-'] == True:
                               check_item = 'Sens'
                               x=read_csv(file_IQR,Tester,check_item,fullname,project)
                               if x is None:
                                    sg.popup("No GoldenSample data in file,Please re-selected it!!")
                                    break
                               else:
                                    window['Data1'].update('DUT_NM_Sens_Corr1000Hz_94SPL__Median')
                                    window['Data2'].update('DUT_NM_relativeSens8000Hz_RFR_Median')
                                    window['Data3'].update('DUT_NM_relativeSens10000Hz_RFR_Median')

                                    Sens1k,paint0,Sens8k,paint1,Sens10k,paint2,Noise,paint3,Phase1k,paint4,Phase3k,\
                                    paint5,Phase10k,paint6,lotnum,testtime=read_csv(file_IQR,Tester,check_item,fullname,project)

                                    window['-testlot-'].update(lotnum)
                                    window['-testdate-'].update(testtime)
                                    j=-1
                                    for row in range(5):
                                       for col in range(7):
                                          j=j+1
                                          window[f'partA{row}{col}'].update(f'Site{j+1}:{Sens1k[j]}',background_color=paint0[j])
                                          window[f'partB{row}{col}'].update(f'Site{j+1}:{Sens8k[j]}',background_color=paint1[j])
                                          window[f'partC{row}{col}'].update(f'Site{j+1}:{Sens10k[j]}',background_color=paint2[j])
                                    break
                          else:
                                  check_item = 'Phase'
                                  x = read_csv(file_IQR, Tester, check_item,fullname,project)
                                  if x is None:
                                        sg.popup("No GoldenSample data in file,Please re-selected it!!")
                                        break
                                  else:
                                        window.Element('Data4').Update(visible=True)
                                        window['Data1'].update('DUT_Phase1kHz_RPR_Median')
                                        window['Data2'].update('DUT_Phase3kHz_RPR_Median')
                                        window['Data3'].update('DUT_Phase10kHz_RPR_Median')
                                        window['Data4'].update('DUT_NM_Noise_Median')

                                        Sens1k, paint0, Sens8k, paint1, Sens10k, paint2, Noise, paint3, Phase1k, paint4, Phase3k, \
                                        paint5, Phase10k, paint6, lotnum, testtime = read_csv(file_IQR, Tester, check_item,fullname,project)

                                        window['-testlot-'].update(lotnum)
                                        window['-testdate-'].update(testtime)
                                        j = -1
                                        for row in range(5):
                                          for col in range(7):
                                              j = j + 1
                                              window.Element(f'partD{row}{col}').Update(visible=True)
                                              window[f'partA{row}{col}'].update(f'Site{j + 1}:{Phase1k[j]}', background_color=paint4[j])
                                              window[f'partB{row}{col}'].update(f'Site{j + 1}:{Phase3k[j]}', background_color=paint5[j])
                                              window[f'partC{row}{col}'].update(f'Site{j + 1}:{Phase10k[j]}', background_color=paint6[j])
                                              window[f'partD{row}{col}'].update(f'Site{j + 1}:{Noise[j]}', background_color=paint3[j])
                                        break
          else:
              sg.popup("Tester or Project selected wrong,Please selected properly!!")
              # break
      else:
          sg.popup("No Data!")



window.close()

Attached Files

Thumbnail(s)
   

.csv   CAMEMSNIOSAI61_Statistic.csv (Size: 225.32 KB / Downloads: 63)
.txt   checkmaster_config.txt (Size: 1.14 KB / Downloads: 70)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Interaction between Matplotlib window, Python prompt and TKinter window NorbertMoussy 3 348 Mar-17-2024, 09:37 AM
Last Post: deanhystad
Photo PySimpleGUI FilesBrowse enable event to update value in combo SamLiu 2 4,467 Mar-15-2023, 12:49 PM
Last Post: SamLiu
  [Tkinter] Can't update label in new tk window, object has no attribute tompranks 3 3,468 Aug-30-2022, 08:44 AM
Last Post: tompranks
Question closing a "nested" window with a button in PySimpleGUI and repeating this process Robby_PY 9 13,419 Jan-18-2021, 10:21 PM
Last Post: Serafim
  how to add elements in the other window? (pysimplegui) syafiq14 0 2,312 Jul-20-2020, 10:35 PM
Last Post: syafiq14
  Want to dynamically update numbers using tkinter in pygame script k0gane 0 2,037 Feb-09-2020, 09:01 AM
Last Post: k0gane
  tkinter window and turtle window error 1885 3 6,638 Nov-02-2019, 12:18 PM
Last Post: 1885
  [PyQt] how to dynamically add label to pyqt window Joongi 3 10,541 Sep-10-2019, 01:38 PM
Last Post: Denni
  Need help setting up a PySimpleGUI progress bar that I can maually update in script Soundtechscott 1 10,044 Jun-10-2019, 06:14 AM
Last Post: Soundtechscott
  [PySimpleGUI] update listbox not working zappfinger 2 12,038 Nov-12-2018, 08:33 PM
Last Post: zappfinger

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020