0
import PySimpleGUI as sg

layout = [

    [sg.Text('Medico Refertatore', size=(15, 1)), sg.InputText()],
    [sg.Text('Nome Paziente', size=(15, 1)), sg.InputText()],
    [sg.Text('Cognome Paziente', size=(15, 1)), sg.InputText()],
    [sg.Text('TC', size=(15, 1)), sg.Button('0%', focus = True ), sg.Button('1-24%', focus = True), sg.Button('25-49%', focus = True), sg.Button('50-69%', focus = True), sg.Button('70-99%', focus = True), sg.Button('100%', focus = True), ],
    [sg.Text('IVA PROX', size=(15, 1)), sg.Button('0%', focus = True ), sg.Button('1-24%', focus = True), sg.Button('25-49%', focus = True), sg.Button('50-69%', focus = True), sg.Button('70-99%', focus = True), sg.Button('100%', focus = True), ],
    [sg.Text('IVA MEDIA', size=(15, 1)), sg.Button('0%', focus = True ), sg.Button('1-24%', focus = True), sg.Button('25-49%', focus = True), sg.Button('50-69%', focus = True), sg.Button('70-99%', focus = True), sg.Button('100%', focus = True), ],
    [sg.Text('IVA DISTALE', size=(15, 1)), sg.Button('0%', focus = True ), sg.Button('1-24%', focus = True), sg.Button('25-49%', focus = True), sg.Button('50-69%', focus = True), sg.Button('70-99%', focus = True), sg.Button('100%', focus = True), ],
    [sg.Text('I SETTALE', size=(15, 1)), sg.Button('0%', focus = True ), sg.Button('1-24%', focus = True), sg.Button('25-49%', focus = True), sg.Button('50-69%', focus = True), sg.Button('70-99%', focus = True), sg.Button('100%', focus = True), ],
    [sg.Text('I DIAGONALE', size=(15, 1)), sg.Button('0%', focus = True ), sg.Button('1-24%', focus = True), sg.Button('25-49%', focus = True), sg.Button('50-69%', focus = True), sg.Button('70-99%', focus = True), sg.Button('100%', focus = True), ],
    [sg.Text('RAMO INTERMEDIO', size=(15, 1)), sg.Button('0%', focus = True ), sg.Button('1-24%', focus = True), sg.Button('25-49%', focus = True), sg.Button('50-69%', focus = True), sg.Button('70-99%', focus = True), sg.Button('100%', focus = True), ],
    [sg.Text('CFX PROX', size=(15, 1)), sg.Button('0%', focus = True ), sg.Button('1-24%', focus = True), sg.Button('25-49%', focus = True), sg.Button('50-69%', focus = True), sg.Button('70-99%', focus = True), sg.Button('100%', focus = True), ],
    [sg.Text('CFX MEDIA', size=(15, 1)), sg.Button('0%', focus = True ), sg.Button('1-24%', focus = True), sg.Button('25-49%', focus = True), sg.Button('50-69%', focus = True), sg.Button('70-99%', focus = True), sg.Button('100%', focus = True), ],
    [sg.Text('CFX DISTALE', size=(15, 1)), sg.Button('0%', focus = True ), sg.Button('1-24%', focus = True), sg.Button('25-49%', focus = True), sg.Button('50-69%', focus = True), sg.Button('70-99%', focus = True), sg.Button('100%', focus = True), ],
    [sg.Text('I MARGINALE', size=(15, 1)), sg.Button('0%', focus = True ), sg.Button('1-24%', focus = True), sg.Button('25-49%', focus = True), sg.Button('50-69%', focus = True), sg.Button('70-99%', focus = True), sg.Button('100%', focus = True), ],
    [sg.Text('II MARGINALE', size=(15, 1)), sg.Button('0%', focus = True ), sg.Button('1-24%', focus = True), sg.Button('25-49%', focus = True), sg.Button('50-69%', focus = True), sg.Button('70-99%', focus = True), sg.Button('100%', focus = True), ],
    [sg.Text('IVP(CFX)', size=(15, 1)), sg.Button('0%', focus = True ), sg.Button('1-24%', focus = True), sg.Button('25-49%', focus = True), sg.Button('50-69%', focus = True), sg.Button('70-99%', focus = True), sg.Button('100%', focus = True), ],
    [sg.Text('CDX PROSSIMALE', size=(15, 1)), sg.Button('0%', focus = True ), sg.Button('1-24%', focus = True), sg.Button('25-49%', focus = True), sg.Button('50-69%', focus = True), sg.Button('70-99%', focus = True), sg.Button('100%', focus = True), ],
    [sg.Text('CDX MEDIO', size=(15, 1)), sg.Button('0%', focus = True ), sg.Button('1-24%', focus = True), sg.Button('25-49%', focus = True), sg.Button('50-69%', focus = True), sg.Button('70-99%', focus = True), sg.Button('100%', focus = True), ],
    [sg.Text('CDX DISTALE', size=(15, 1)), sg.Button('0%', focus = True ), sg.Button('1-24%', focus = True), sg.Button('25-49%', focus = True), sg.Button('50-69%', focus = True), sg.Button('70-99%', focus = True), sg.Button('100%', focus = True), ],
    [sg.Text('IVP(CDX)', size=(15, 1)), sg.Button('0%', focus = True ), sg.Button('1-24%', focus = True), sg.Button('25-49%', focus = True), sg.Button('50-69%', focus = True), sg.Button('70-99%', focus = True), sg.Button('100%', focus = True), ],
    [sg.Text('POST LAT(CDX)', size=(15, 1)), sg.Button('0%', focus = True ), sg.Button('1-24%', focus = True), sg.Button('25-49%', focus = True), sg.Button('50-69%', focus = True), sg.Button('70-99%', focus = True), sg.Button('100%', focus = True), ],
    [sg.Text('AMIS', size=(15, 1)), sg.Button('0%', focus = True ), sg.Button('1-24%', focus = True), sg.Button('25-49%', focus = True), sg.Button('50-69%', focus = True), sg.Button('70-99%', focus = True), sg.Button('100%', focus = True), ],
    [sg.Text('AMID', size=(15, 1)), sg.Button('0%', focus = True ), sg.Button('1-24%', focus = True), sg.Button('25-49%', focus = True), sg.Button('50-69%', focus = True), sg.Button('70-99%', focus = True), sg.Button('100%', focus = True), ],
    [sg.Text('FREE GRAFT ARTERIOSO', size=(15, 1)), sg.Button('0%', focus = True ), sg.Button('1-24%', focus = True), sg.Button('25-49%', focus = True), sg.Button('50-69%', focus = True), sg.Button('70-99%', focus = True), sg.Button('100%', focus = True), ],
    [sg.Text('GRAFT VENOSO', size=(15, 1)), sg.Button('0%', focus = True ), sg.Button('1-24%', focus = True), sg.Button('25-49%', focus = True), sg.Button('50-69%', focus = True), sg.Button('70-99%', focus = True), sg.Button('100%', focus = True), ],
    [sg.Submit(), sg.Cancel()]

]

window = sg.Window('APP RICERCA', layout, return_keyboard_events= True)

while True:
    event, values = window.read()

    if event in (None, 'Cancel'):
        break;

 ####################################TC

    elif event == '0%':   
     print('1')

    elif event == '1-24%':
     print('2')  

    elif event =='25-49%':
     print('3')

    elif event == '50-69%':
     print('4') 

    elif event == '70-99%':
     print('5')   

    elif event == '100%':
        print('6')




window.close()

How do I get to print what is pressed with each button in a CSV file?

I am able to print the result of pressing differnt buttons in the visual studio terminal but I can't to seem able to classify the buttons according to their type and print the results in a csv file.

VegaOmega
  • 19
  • 1
  • 7
  • I don't see any code where you've learned to use the CSV package. Learn how to write to CSV files separately and then combine the 2 capabilities. – Mike from PSG Jun 09 '20 at 07:44
  • You aren't defining the key's of any of the elements. Do that first and then you could use .startswith or .endswith for the if statement logic – Elijah Jul 10 '20 at 02:33

0 Answers0