wxPython控件学习之UltimateListCtrl空间中使用ComboBox时,该控件一直在重绘的问题
2012-12-16 21:07
1126 查看
例子:
解决方法如代码中,SetItemWindow(),添加control到列中的时候,可以先用wx.Panel做位其父控件。这样control不会被一直重绘。我在项目中用到ComboBox时候,遇到了这个情况。其他控件暂时没有遇到过。wxPython 还是有许多问题的。
#-*- coding: UTF-8 -*- #------------------------------------------------------------------------------- # Name: 模块mainFrame # Purpose: 应用程序的主界面 # # Author: ankier # # Created: 16-12-2012 # Copyright: (c) ankier 2012 # Licence: <your licence> #------------------------------------------------------------------------------- try: from agw import floatspin as FS except ImportError: # if it's not there locally, try the wxPython lib. import wx.lib.agw.floatspin as FS try: from agw import ultimatelistctrl as ULC except ImportError: # if it's not there locally, try the wxPython lib. from wx.lib.agw import ultimatelistctrl as ULC import wx import sys ## @detail MainFrame主界面窗口类 class MainFrame(wx.Frame): def __init__(self): #重新定向wxpython的输出输入和错误输出到系统标准输入输出 sys.stdin = sys.__stdin__ sys.stdout = sys.__stdout__ sys.stderr = sys.__stderr__ wx.Frame.__init__(self, None, wx.ID_ANY, 'Ultimate list ctrl demo', pos=wx.DefaultPosition, size=(800, 600), style=wx.DEFAULT_FRAME_STYLE) self.CreateStatusBar() panel = wx.Panel(self, -1) box = wx.FlexGridSizer(10, 2, 5, 5) button = wx.Button(panel, -1, 'Add') box.Add(button, 0, wx.ALIGN_CENTRE) button.Bind(wx.EVT_BUTTON, self.__OnAddClicked) self.listCtrls = ULC.UltimateListCtrl(panel, -1, size =(200, 100), style = ULC.ULC_MASK_TYPE, agwStyle = ULC.ULC_REPORT|ULC.ULC_HAS_VARIABLE_ROW_HEIGHT|ULC.ULC_NO_FULL_ROW_SELECT) self.listCtrls.InsertColumn(0, 'Name', ULC.ULC_FORMAT_CENTRE) self.listCtrls.InsertColumn(1, 'Selection', ULC.ULC_FORMAT_CENTRE) box.Add(self.listCtrls, 0, wx.ALIGN_CENTRE) panel.SetSizerAndFit(box) def __OnAddClicked(self, event): index = self.listCtrls.InsertStringItem(sys.maxint, 'name 1') panel = wx.Panel(self.listCtrls, -1) sizer = wx.BoxSizer(wx.VERTICAL) cbb = wx.ComboBox(panel, -1, value = '1', choices = ['1', '2', '3', '4', '5'], style = wx.CB_DROPDOWN|wx.TE_PROCESS_ENTER) sizer.Add(cbb, 1, wx.EXPAND) panel.SetSizer(sizer) #cbb = wx.Button(self.listCtrls, -1, 'Add') cbb.Bind(wx.EVT_PAINT, self.__OnPaint) self.listCtrls.SetItemWindow(index, 1, panel, expand = True) self.listCtrls.Update() def __OnPaint(self, event): event.Skip()
解决方法如代码中,SetItemWindow(),添加control到列中的时候,可以先用wx.Panel做位其父控件。这样control不会被一直重绘。我在项目中用到ComboBox时候,遇到了这个情况。其他控件暂时没有遇到过。wxPython 还是有许多问题的。
相关文章推荐
- (记录学习android遇到的问题)使用被weight分配空间后的控件高度值画新控件出现的问题
- 使用ComboBox控件时遇到的小问题。。。
- Tab控件跟ListCtrl控件联合使用,ListCtrl控件有可能被遮挡问题
- wxPython控件学习之wx.ComboBox
- MFC学习笔记之:ListCtrl控件使用详解
- Ext ComboBox控件使用常见问题
- easyUI下拉框控件easyui-combobox使用后台json文件填充数据失败的问题
- MFC学习笔记之:ListCtrl控件使用详解
- ListCtrl使用详解——我的表格控件学习历程
- EasyUI的combobox控件使用onchange 问题
- Atlas学习笔记:使用UpdatePanel控件需注意的问题
- vc6.0 Combobox控件的使用问题
- 关于wince 使用占用空间大的内存变量问题(编译无错误但是无法运行的问题)
- 【转】wxPython控件学习之TextCtrl(三)响应文本控件事件
- QSplitter 控件使用时要注意的问题
- vs2005中使用登陆和注册控件时出现的问题
- iOS学习之UIPickerView控件的简单使用
- Yii tinymce扩展控件的使用问题:tinymce is not defined
- Visual Studio 2010—— C#的ComboBox控件使用
- 【问题记录】Asp.net WebApplication和WebSite中用户控件的使用区别