반응형
wx.ComboBox -- item 추가하기
참고 : http://stackoverflow.com/questions/682923/dynamically-change-the-choices-in-a-wx-combobox
http://xoomer.virgilio.it/infinity77/wxPython/Widgets/wx.ItemContainer.html#SetItems
SetItems() 사용하면됨. -- Clear and set the strings in the control from a list.
myitems 에는 항목이 없지만, instance 생성후에 SetItems() 이용하여 , wx.ComboBox 의 항목 추가함.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import wx | |
class MyFrame(wx.Frame): | |
def __init__(self, parent): | |
wx.Frame.__init__(self, parent) | |
panel = wx.Panel(self) | |
myitems = [ ] | |
self.cb = wx.ComboBox(panel, choices = myitems, style=wx.CB_DROPDOWN) | |
if __name__ == '__main__': | |
app = wx.App() | |
fr = MyFrame(None) | |
fr.cb.SetItems([u'숫자형',u'열거형',u'텍스트']) # item 추가 | |
fr.cb.SetSelection(0) | |
fr.Show() | |
app.MainLoop() |
반응형
'wxpython' 카테고리의 다른 글
wxpython -- 화면캡쳐후 저장하기 (0) | 2015.09.09 |
---|