![]() I just chose a value which worked in most cases for the context of that app.Who’s It For: Apple users who love the cohesive experience between their computer, iPhone, iPad, and other Apple-made products. Instead, I simply set the column width to a hard value once at app launch. While I could have made a call to redraw the ListBook, that would make the contents of the pages move left/right each time. However, if the column shrinks, then the right column border is pulled in to the end of the longest item. If the column grows to be bigger than the ListCtrl, then a scrollbar appears allowing the user to scroll to view the cutoff ends of the items. In that case, the ListCtrl is not resized after a page is added and SetColumnWidth is called, only the column is resized. However, in the real application I encountered this issue with, the ListBook is initially drawn/rendered to the screen empty and then pages are added/removed through normal use of the application. ![]() In the example application above, the ListBook is not drawn until after the last page is added and the column width is recalculated. Note that autocalculating may not work as desired in every application. MyListCtrl = ()Īnd here is what that looks like on Windows: # Access listCtr and calculate column width Self.myListBook = wx.Listbook(panel, size=(500, 500), style=wx.LIST_FORMAT_LEFT) Therefore, the call needs to be made after the last page is added. We could set the column width to a hard value, but by using -1 we tell it to calculate the width by using the width of the longest item in the list. This will cause the column width and by extension the total width of the ListCtrl to be recalculated. You must SetColumnWidth on the ListCtrl after all pages have been added. Page_stuff = wx.StaticText(page, wx.ID_ANY, ("Item in the page 1")) _sizer.Add(page2_stuff, 0, wx.EXPAND, 5)Įven resorting to dropping the sizers and fixing the Listbook size continues to arrange the items proportionally. _stuff = wx.StaticText(page2, wx.ID_ANY, ("Items in the page 2")) _sizer.Add(page1_stuff, 0, wx.EXPAND, 5) _stuff = wx.StaticText(page1, wx.ID_ANY, ("Items in the page 1")) ![]() Self.myListBook = wx.Listbook(panel, -1, style=wx.LIST_FORMAT_LEFT) You need to set a sizer for each page added. I'm running Windows 10, Python 3.8.1, and wxPython 4.1.1 msw (phoenix) wxWidgets 3.1.5. Sizer.Add(self.myListBook, 1, wx.EXPAND | wx.ALL, 5) # sizeritem = lcSizer.GetItem(self.myListCtr) # lcSizer.SetItemMinSize(myListCtr, 500, -1) ![]() ![]() # lcSizer = myListCtr.GetContainingSizer() Self.myListBook = wx.Listbook(panel, style=wx.LB_LEFT) Wx.Frame._init_(self, None, title="Example") How can I increase the width of the ListCtrl within a wx.Listbook? import wx I also tried to access the sizer of the ListCtrl (via myListCtr.GetContainingSizer()) but that returns None. However, changing the size has no effect. Of course, I can access the ListCtrl using Listbook.GetListView(). I would like to increase the width so that the page names are not truncated, but can't seem to. However, the width of the ListCtrl is less than the shortest page name. I'm using a wx.Listbook, which uses a ListCtrl to select pages within the Listbook. ![]()
0 Comments
Leave a Reply. |