How to accommodate large fonts in a listctrl

Many or most will recognise these lines from the listctrl demo code, with a little modification.

I can change the font for a line in a listctrl using the lines shown at the end of this fragment. However, the lines in the listctrl do not increase in height to accommodate the larger font, and I am at a loss as to how to request a larger size.

Can someone please advise me?

    items = musicdata.items()
    for key, data in items:
        index = self.list.InsertItem(self.list.GetItemCount(), data[0])
        self.list.SetItem(index, 1, data[1])
        self.list.SetItem(index, 2, data[2])
        self.list.SetItemData(index, key)

        font = wx.Font(self.GetClassDefaultAttributes().font)
        font.SetPixelSize((0,25))
        self.list.SetItemFont(index, font)

``

Hi,

···

On 12 November 2017 at 16:34, Bill Bell bell.w.d@gmail.com wrote:

Many or most will recognise these lines from the listctrl demo code, with a little modification.

I can change the font for a line in a listctrl using the lines shown at the end of this fragment. However, the lines in the listctrl do not increase in height to accommodate the larger font, and I am at a loss as to how to request a larger size.

Can someone please advise me?

    items = musicdata.items()
    for key, data in items:
        index = self.list.InsertItem(self.list.GetItemCount(), data[0])
        self.list.SetItem(index, 1, data[1])
        self.list.SetItem(index, 2, data[2])
        self.list.SetItemData(index, key)


        font = wx.Font(self.GetClassDefaultAttributes().font)
        font.SetPixelSize((0,25))
        self.list.SetItemFont(index, font)

``

It seems to be working slightly better if you add this line:

self.list.SetFont(font)

At the end of the for loop. Not pretty to look at, but better than before…

Andrea.

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Thank you! Definitely good enough for my purposes.

Bill

···

On Sunday, 12 November 2017 13:03:39 UTC-5, Infinity77 wrote:

Hi,

On 12 November 2017 at 16:34, Bill Bell bell...@gmail.com wrote:

Many or most will recognise these lines from the listctrl demo code, with a little modification.

I can change the font for a line in a listctrl using the lines shown at the end of this fragment. However, the lines in the listctrl do not increase in height to accommodate the larger font, and I am at a loss as to how to request a larger size.

Can someone please advise me?

    items = musicdata.items()
    for key, data in items:
        index = self.list.InsertItem(self.list.GetItemCount(), data[0])
        self.list.SetItem(index, 1, data[1])
        self.list.SetItem(index, 2, data[2])
        self.list.SetItemData(index, key)


        font = wx.Font(self.GetClassDefaultAttributes().font)
        font.SetPixelSize((0,25))
        self.list.SetItemFont(index, font)

``

It seems to be working slightly better if you add this line:

self.list.SetFont(font)

At the end of the for loop. Not pretty to look at, but better than before…

Andrea.

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-user...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.