Hello everybody,
I'm new to Python wx and I'm trying to make an application which requires the use of database content.
I've already made the input data frame.
I need to make a frame where to list the database content.
I need to create a label for each row like

self.user1=wx.StaticText(....)
self.user2=wx.StaticText(...)
(...)
self.usern=wx.StaticText(...)

It should be even better to use a notebook for the paging (Page 1, Page 2, ..., Page n).
I have no idea how to do it so please help me with it.
Thanx a lot for your time and answers.

Recommended Answers

All 3 Replies

You could try something like this example:

# create a series of wx.StaticText() labels with a for loop

import wx

class MyFrame(wx.Frame):
    def __init__(self, parent, mytitle, pinto_beans):
        wx.Frame.__init__(self, parent, wx.ID_ANY, mytitle)
        self.SetBackgroundColour("blue")

        # use wx.GridSizer(rows, cols, vgap, hgap) for layout
        gsizer = wx.GridSizer(6, 1, 0, 0)

        # create a list of labels
        # acccess with self.labels[0], self.labels[1] etc.
        self.labels = []
        for bean in pinto_beans.split('\n'):
            self.labels.append(wx.StaticText(self, wx.ID_ANY,
                label=bean, style=wx.ALIGN_CENTRE))

        # iterate through the list of labels and set layout
        # font and colour
        font = wx.Font(24, wx.MODERN, wx.NORMAL, wx.BOLD)
        for label in self.labels:
            label.SetFont(font)
            label.SetBackgroundColour("yellow")
            gsizer.Add(label, 0, flag=wx.ALL|wx.EXPAND, border=5)

        # set the sizer and fit the frame around it
        self.SetSizerAndFit(gsizer)


pinto_beans = """\
Burke
Othello
Maverick
Sierra
Zotoma"""

app = wx.App(0)
frame = MyFrame(None, 'beans', pinto_beans)
frame.Center()
frame.Show()
app.MainLoop()

where is the problem?
You can pass here and brush yourself on wxthings and where you hit a wall, come back and post specific problem Check wxPython tutorial

commented: Nice tutorials, very useful! +0

Thanx a lot for your answers, now I know how to do it.

Be a part of the DaniWeb community

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