Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
wxPython-如何在UltimateListCtrl单元格/窗口内对齐小部件?_Python_Python 3.x_User Interface_Widget_Wxpython - Fatal编程技术网

wxPython-如何在UltimateListCtrl单元格/窗口内对齐小部件?

wxPython-如何在UltimateListCtrl单元格/窗口内对齐小部件?,python,python-3.x,user-interface,widget,wxpython,Python,Python 3.x,User Interface,Widget,Wxpython,我在UI中使用UltimateListCtrl,我需要在其中放置小部件。一切都很好,我只是不知道如何在窗口/单元格中对齐小部件 在我的例子中,我想对齐列中心的复选框。 下面是我尝试将复选框居中的示例代码: import wx from wx.lib.agw import ultimatelistctrl as ULC class TestPanel(wx.Panel): def __init__(self, parent): """Cons

我在UI中使用UltimateListCtrl,我需要在其中放置小部件。一切都很好,我只是不知道如何在窗口/单元格中对齐小部件

在我的例子中,我想对齐列中心的复选框。

下面是我尝试将复选框居中的示例代码:

import wx
from wx.lib.agw import ultimatelistctrl as ULC

class TestPanel(wx.Panel):
    def __init__(self, parent):
        """Constructor"""
        wx.Panel.__init__(self, parent)
        
        self.ultimateList = ULC.UltimateListCtrl(self, wx.ID_ANY, size=(-1,435), agwStyle=ULC.ULC_REPORT | ULC.ULC_SINGLE_SEL | ULC.ULC_HAS_VARIABLE_ROW_HEIGHT)
        self.ultimateList.InsertColumn(0, 'Column 1', width=70)
        self.ultimateList.InsertColumn(1, 'Column 2', width=240, format=ULC.ULC_FORMAT_CENTER)

        index = self.ultimateList.InsertStringItem(0, "Test")

        self.checkboxCtrl = wx.CheckBox(self.ultimateList, wx.ID_ANY, size=(70,20), name="")
        self.ultimateList.SetItemWindow(index, 0, self.checkboxCtrl, expand=True)  

        self.checkboxCtrl1 = wx.CheckBox(self.ultimateList, wx.ID_ANY, size=(240,20), name="")
        self.ultimateList.SetItemWindow(index, 1, self.checkboxCtrl1, expand=False)  
        
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.ultimateList, 1, wx.EXPAND)
        self.SetSizer(sizer)
        

class TestFrame(wx.Frame):
    def __init__(self):
        """Constructor"""
        wx.Frame.__init__(self, None, title="MvP UltimateListCtrl Demo")
        panel = TestPanel(self)
        self.Show()
    
#----------------------------------------------------------------------
if __name__ == "__main__":
    app = wx.App(False)
    frame = TestFrame()
    app.MainLoop():