I would like some help.
I'm training on this code:
import PySimpleGUI as sg
category = ['Smartphone', 'Battery', 'Charger']
brand = ['Iphone', 'Motorola', 'LG']
color = ['White', 'Green', 'Black']
size_font = 20
layout = [[sg.Text('Code', font=size_font), sg.Input(key='-COD-', font=size_font, size=(20, 1))],
[sg.Text('Un', font=size_font), sg.InputText(key='-UN-', font=size_font, size=(10, 1))],
[sg.Text('Name', font=size_font), sg.Input(key='-NAME-', size=(30, 1))],
[sg.Text('Category', font=size_font), sg.Combo(category, font=size_font, key='-CATEG-', size=(30, 1))],
[sg.Text('Brand', font=size_font), sg.Combo(marca, font=size_font, key='-BRAND-')],
[sg.Text('Color', font=size_font), sg.Combo(color, font=size_font, key='-COL-')],
[sg.Text('')],
[sg.Button('Insert', font=size_font), sg.Button('Cancel', font=size_font)]]
window = sg.Window('Product Registration', layout, size=(700, 300))
while True:
event, values = window.read()
if event in (sg.WIN_CLOSED, 'Cancel'):
break
if event == 'Insert':
window['-NAME-'].update(window['-CATEG-'])
window.close()
I would like the value chosen in the Combo list, whose key is ='-CATEG-' ,?was filled in key = '-NAME-'. But the object is returning and not the chosen value, example: <PySimpleGUI.PySimpleGUI.Combo object at 0x7fd8bf982a60>.
And another thing: Can you concatenate the keys: '-CATEG-' + '-BRAND-' + '-COLOR-' with this junction being placed in key = '- NAME-' ?. Example: In the 'Category' Combo, the Smartphone option was chosen; in 'Brand, Motorola and 'Color ', Black. Thus, the 'Name' field should be: Smartphone Motorola Black.
In addition, it is a good practice to create variables to define some parameters, as done for the variable 'size_font'??I thought so because I believe that maintenance will be easier.