WxPython, set the value of StaticText ()

advertisements

I am making a little GUI frontend for a app at the moment using wxPython.

I am using wx.StaticText() to create a place to hold some text, code below:

content = wx.StaticText(panel, -1, "Text Here", style=wx.ALIGN_CENTRE)

I have a button when clicked retrieves data from MySQL, I am wanting to change the value of the StaticText() to the MySQL data or what else could I use the hold the data.

I have tried using the below method:

contents = wx.TextCtrl(bkg, style=wx.TE_MULTILINE | wx.HSCROLL)
content.SetValue("New Text")

This displays the data fine but after the data is loaded you can edit the data and I do not want this.

Hope you guys understand what I am trying to do, I am new to Python :)

Cheers


wx.TextCtrl has a style called wx.TE_READONLY . Use that to make it read-only.

As a sidenode, you can use the C++ wxWidgets Manual for wxPython aswell. Where special handling for wxPython or other ports is required, the manual often points out the difference.