I have been trying to use a wxPython textctrl to display a list of files, but it did not fit my purposes. The wx.StaticText seemed useful, and a ll works except for one major kink; I don't know how to scroll it.

Moved post to its own thread, since the sticky is not for questions.

You can use multiple labels on a scrolled panel. Here is an example ...

# the wx.lib.scrolledpanel.ScrolledPanel() widget scrolls
# multiple labels in the panel

import wx
import wx.lib.scrolledpanel as sp

class MyScrolledPanel(sp.ScrolledPanel):
    def __init__(self, parent):
        # make the scrolled panel larger than its parent
        sp.ScrolledPanel.__init__(self, parent,
            wx.ID_ANY, size=(300, 600), style=wx.TAB_TRAVERSAL)
        # scroll bars won't appear until required
        # default is SetupScrolling(scroll_x=True, scroll_y=True)

        # this will take up plenty of space for the test
        # change the text in the third label from the top
        # index is zero based so the index is 2
        self.labels[2].SetLabel("changed the third label!!!")

    def createMultiLabels(self):
        # things to put on the labels
        label_str = """
        This is just a long text to check on scrolling ----- 
        """ * 3

        # wx.GridSizer(rows, cols, vgap, hgap)
        gsizer = wx.GridSizer(25, 1, 0, 0)

        # create a list of labels
        # acccess with self.labels[0], self.labels[1] etc.
        self.labels = []
        for word in label_str.split():
            self.labels.append(wx.StaticText(self, wx.ID_ANY,

        # iterate through the list of labels and set layout
        for x in self.labels:
            gsizer.Add(x, 0, flag=wx.ALL, border=0)

        # set the sizer

app = wx.App(0)
# create a frame, no parent, use default ID, set title, size
caption = "Multilabels in a scrolled panel"
frame = wx.Frame(None, wx.ID_ANY, caption, size=(300, 200))

Thank you vegaseat. The code above will definitely help me in the future, but I have discovered that the wx.ListBox fits my program better(I need to be able to select files and remove them from a list).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.