我想创建一个网格,用户可以在其中通过 wxchoice(或 wxcombo)控件更改列名。我想象它是这样的:例如让用户有数据的树列
John,Smith,190
Maria,Kowalsky,180
我想让用户将每一列与三个选项之一(名字、姓氏、身高)相匹配,我刚开始:
#!/usr/bin/python
# coding: utf-8
import wx
from wx.grid import Grid
class DocsVarValGrid(Grid):
"""
"""
def __init__(self, parent, init_data=None, *args, **kwargs):
super(DocsVarValGrid, self).__init__(parent, *args, **kwargs)
self.CreateGrid(1, 1)
self.cols_names = init_data
class MyFrame(wx.Frame):
""""""
def __init__(self, *args, **kwargs):
super(MyFrame, self).__init__(*args, **kwargs)
#self.panel = PickAFile(parent=self)
self.grid = DocsVarValGrid(self, init_data=['a', 'b', 'c'])
self.Layout()
def main():
app = wx.App() # creation of the wx.App object (initialisation of the wxpython toolkit)
frame = MyFrame(None, title="Hello World") # creation of a Frame with "Hello World" as title
frame.Show() # frames are invisible by default so we use Show() to make them visible
app.MainLoop() # here the app enters a loop waiting for user input
if __name__ == '__main__':
main()