개발자 모드/파이썬(python)

파이썬 yml / SingleChoiceDialog / 조건문

인생은직구 2021. 5. 20. 17:54
728x90

test2.yaml
0.00MB
yml_sample7.pyw
0.00MB

#-*- coding: utf-8 -*-

import yaml
import wx
import os
import sys

#sys.setdefaultencoding('utf-8')


 
doc = yaml.load(open('test2.yaml', 'r',encoding='utf-8'))
strs = doc['strs']
 
for s in strs:
    print(s)  # 철수, 영희, 명수

if __name__ == '__main__':
    app = wx.PySimpleApp()
    dlg = wx.SingleChoiceDialog(None,
        'What version of Python are you using?',
        'Single Choice',
        strs,
        wx.CHOICEDLG_STYLE)
        
    if dlg.ShowModal() == wx.ID_OK:
        response = dlg.GetStringSelection()
 
    print(response)

    if response == "철수" :
        print(1)
    elif response == "영희" :
        print(2)
    else :
        print(3)

    
    dlg.Destroy()
    app.MainLoop()

 

결과

 

 

 

728x90