'CB_DROPDOWN'에 해당되는 글 1건

  1. 2007.12.05 [wxPython] ComboBox 스타일 변경하기
Python2007.12.05 06:25
ComboBox는 일반적으로 CB_DROPDOWN 스타일을 적용하여 드롭 리스트 방식으로 사용한다. 스타일을 CB_SIMPLE로 변경하면 리스트 박스처럼 사용할 수도 있다.

Styles

wx.CB_SIMPLE Creates a combobox with a permanently displayed list. Windows only.
wx.CB_DROPDOWN Creates a combobox with a drop-down list.
wx.CB_READONLY Same as wxCB_DROPDOWN but only the strings specified as the combobox choices can be selected, it is impossible to select (even from a program) a string which is not in the choices list.
wx.CB_SORT Sorts the entries in the list alphabetically.

사용자 삽입 이미지
#!/usr/bin/env python
# -*- coding: cp949 -*-
"""11-5 Combo box: pull-down choice """

# http://withrobot.tistory.com
# 2007.12.05

import wx

class Frame(wx.Frame):
    def __init__(self, parent=None, id=-1, title='Combo Box'):
        wx.Frame.__init__(self, parent, id, title, size=(300,300), pos=(100,100) )
        panel = wx.Panel(self)

        sampleList = ['zero', 'one', 'two', 'three', 'four', 'five',
                      'six', 'seven', 'eight']

        self.st = wx.StaticText(panel,-1,"Select one:",(15,20))
        wx.ComboBox(panel,-1,"선택하세요",(15,40),(100,50),sampleList,wx.CB_DROPDOWN)
        wx.ComboBox(panel,-1,"선택하세요",(150,40),(100,50),sampleList,wx.CB_SIMPLE)
       
class App(wx.App):
    def OnInit(self):
        self.frame = Frame()
        self.frame.Show()
        return True

def main():
    app = App()
    app.MainLoop()

if __name__ == '__main__':
    main()


Posted by getcome