Hello,
I want to do the Math when I click in the first button,but the value is not updating after the second time.
I need to close the window and start again.
See the code below:
I want to do the Math when I click in the first button,but the value is not updating after the second time.
I need to close the window and start again.
See the code below:
import PySimpleGUI as sg import sys def conv_elet(Xmax,Xmin,Ymax,Ymin,Valor): Y=(((Valor-Xmin)*(Ymax-Ymin))/(Xmax-Xmin))+Ymin return Y layout1 = [ [sg.Txt('Enter com Speed Ref:'),sg.In(size=(8,1), key='speedref')], [sg.Txt('Enter Speed Conv:'),sg.In(size=(8,1), key='valor')], [sg.Txt('', size=(8,1), key='output') ], [sg.Button('Calcular', bind_return_key=True)]] window1 = sg.Window('Math', layout1) tab1_layout = [[sg.Button('1- Converter Speed(rpm) para 4-20mA')], [sg.Button('2- Converter 4-20mA para Speed(rpm)')], [sg.Button('3- Converter Decimal(0-27648) para 4-20mA)')], [sg.Button('4- Converter 4-20mA para Decimal(0-27648)')] ] tab2_layout = [[sg.T('This is inside tab 2')], [sg.In(key='in')]] layout = [[sg.TabGroup([[sg.Tab('Conversoes Base', tab1_layout, tooltip='tip'), sg.Tab('Conversoes Motores', tab2_layout)]], tooltip='TIP2')]] window = sg.Window('Tabelas de Conversões', layout, default_element_size=(10,1)) while True: event, values = window.read() event, values = window1.read() if event is not None: SpeedMax = float(values['speedref']) SpeedMin= SpeedMax * -1 Ymax=20 Ymin=4 Valor1= float(values['valor']) resultado=conv_elet(SpeedMax,SpeedMin,Ymax,Ymin,Valor1) window1['output'].update(resultado) else: break window.close()