import PySimpleGUI as sg layout = [ [sg.Text('Enter a Number')], [sg.Input()], [sg.OK()] ] event,(number,) = sg.Window('Enter a number example').Layout(layout).Read() sg.Popup(event,number) ##############下拉選項框######################## layout = [ [sg.Text('請選擇你的性別',auto_size_text=True)], [sg.InputCombo(['男','女','保密'],auto_size_text=True)], [sg.OK('確認',auto_size_button=True)] ] with sg.FlexForm('信息錄入',auto_size_text=True) as form: button_name ,(gender,) = form.Layout(layout).Read() sg.Popup(button_name,gender) ##############滑動條############################# layout = [ [sg.Text('選擇你一個你喜歡的程度',auto_size_text=True)], [sg.Slider(range=(1,500),default_value = 200,orientation ='h')], [sg.OK('確認',auto_size_button=True)] ] with sg.FlexForm('請滑動',auto_size_text=True) as form: button_name,(likelevel,) = form.Layout(layout).Read() sg.Popup(button_name,likelevel)
############################按鈕################ layout = [ [sg.Text('你的學歷是',auto_size_text=True)], [sg.Radio('高中',group_id=1)], #h 或者 v 表示水平或者垂直 [sg.Radio('本科',group_id=1)], [sg.Radio('碩士',group_id=1)], [sg.Radio('博士',group_id=1)], [sg.OK('確認',auto_size_button=True)] ] with sg.FlexForm('按鈕',auto_size_text=True) as form: button_name,level = form.Layout(layout).Read() sg.Popup(button_name,level) ############################複選框#################### layout = [ [sg.Text('你的學歷是',auto_size_text=True)], [sg.Checkbox('游泳',default=True)], #h 或者 v 表示水平或者垂直 [sg.Checkbox('籃球')], [sg.Checkbox('足球')], [sg.Checkbox('羽毛球')], [sg.OK('確認',auto_size_button=True)] ] with sg.FlexForm('複選框',auto_size_text=True) as form: button_name,choices = form.Layout(layout).Read() sg.Popup(button_name,choices)