Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
wxpython
#1
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()
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply
#2
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
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020