Make wxListCtrl fit around contents and parent frame fit around listctrl

P

Piet

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top