468,268 Members | 1,695 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,268 developers. It's quick & easy.

Make wxListCtrl fit around contents and parent frame fit around listctrl

Hello,
I am working on a graphical MySQL Frontend written in python/wxPython.
The results from a table query are displayed either in a wxGrid or in
a wxListCtrl. I would prefer the latter because it underlines the
read-only character of the data, but I am not happy with the way the
results are displayed.
The wxGrid with the results is laid out by the following code:
resultsFrame = wxFrame(parent,-1,title)
resultsTable = wxGrid(resultsFrame,-1)
#populate grid with results...
resultsTable.Fit()
sizer = wxBoxSizer(wxVERTICAL)
sizer.Add(resultsTable,1,wxEXPAND)
resultsFrame.SetSizer(sizer)
resultsFrame.SetAutoLayout(True)
sizer.Fit(resultsFrame)
resultsFrame.Show(True)
This ensures that each column of the grid is adjusted to fit the
longest cell and that the wxFrame fits around the grid. However, I
have not found a way to achieve the same results for a wxListCtrl
despite trying several combinations of .Fit()-functions. For example,
the following code
resultsFrame = wxFrame(parent,-1,title)
resultsList = wxListCtrl(resultsFrame,-1,style =
wxLC_REPORT|wxLC_VRULES|wxLC_HRULES)
#populate wxListCtrl
resultsList.Fit()
resultsList.EnsureVisible(True)
resultsList.SetColumnWidth(-1,-1)
sizer = wxBoxSizer(wxVERTICAL)
sizer.Add(resultsList,1,wxEXPAND)
resultsFrame.SetSizer(sizer)
resultsFrame.SetAutoLayout(True)
sizer.Fit(resultsFrame)
resultsFrame.Fit()
resultsFrame.Show(True)
always generates a Frame of the same size, regardless of the length
and width of the listctrl. I have checked the wxListCtrl
documentation, but I couldn't find the information I was looking for.
Does anyboy know how to format a wxListCtrl that displays all of its
information without scrolling and/or resizing columns?
THanks in advance
Piet
Jul 18 '05 #1
0 1375

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.