Python Forum

Full Version: wxpython
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've been playing around with wxpython and although I've tried various ways of clearing text in leftp I can't seem to get it.
I've tried
lb.Show(False) lb.Hide and setting the label text to ""
Any help would be great

import wx
import string


app = wx.App()

mainframe = wx.Frame(None, title = "Simple App", size =(900, 600))
mainframe.SetBackgroundColour((22,0,22))

def onClose(self):
    exit()

def page(evt,letter):
    lb = wx.StaticText(leftp, -1, label = letter, style = wx.ALIGN_LEFT)
    lb.SetForegroundColour((255,255,0))
    pagep = wx.Panel(leftp, 1, (0,0),(279,490))


letters = string.ascii_uppercase

buttons = []

i = 0
j=0
for letter in letters:
    buttons.append(wx.Button(mainframe, i, letter, (j, 0),(33,20)).Bind(wx.EVT_BUTTON, lambda evt, letter=letter: page(evt, letter)))
    i += 1
    j += 34

leftp = wx.Panel(mainframe,1,(0,24), (279,490))
leftp.SetBackgroundColour((110,90,190))

rightp = wx.Panel(mainframe,1,(281,24), (800,490))
rightp.SetBackgroundColour((110,90,190))

bottomp = wx.Panel(mainframe, 1, (0,515),(900,50))
bottomp.SetBackgroundColour((110,90,190))

exitb = wx.Button(bottomp, -1, "Exit",(785,10))
exitb.Bind(wx.EVT_BUTTON, onClose)

mainframe.Show()
app.MainLoop()
You use StaticText which is read only (once set)
I don't believe there is a clear method, since it's static.
There are many other text widgets that you can use, see: https://wxpython.org/Phoenix/docs/html/s...ea=default