[wxPython-users] Ampersands and static text
Bob Klahn
bobstones at comcast.net
Tue Apr 24 13:11:34 PDT 2007
At 03:38 PM 4/24/2007, "Guilherme Polo" <ggpolo at gmail.com> wrote:
>Uhm.. not here.
By which you mean, Alt-S does nothing? This mysterious-to-me
behavior is fully repeatable here. I'm using wxPython 2.8.3 on
Windows XP Service Pack 2.
So I'm guessing that's not your software/hardware combination, correct?
This same behavior must be happening on the machine of someone on
this list. Who's seeing what I'm seeing? Who can explain it?
Bob
>2007/4/24, Bob Klahn <bobstones at comcast.net>:
>>
>> At 12:30 PM 4/24/2007, Dj Gilcrease wrote:
>>
>>On 4/24/07, Bob Klahn <bobklahn at comcast.net> wrote:
>>
>> What'a happening with the ampersand here? When ampersands occur in display
>> text, I need them to display as ampersands.
>>
>> What do I need to do to get ampersands to display properly?
>> use && to get it to display properly.
>>
>> & is use to signify a hotkey
>> Yikes! I do know that. I shouldn't have used a button in the sample code
>>I posted. My actual example uses a StaticText control rather than a button;
>>I didn't expect to have the ampersand problem there. Why does the problem
>>occur with static text?
>>
>> Example:
>>
>> import wx
>>
>> class MyFrame(wx.Frame):
>> def __init__(self):
>> wx.Frame.__init__(self, None)
>> panel = wx.Panel(self)
>>
>> button1 = wx.Button(panel, -1, "Fun & Games" , pos=(30, 20),
>>size=(100,25) )
>> button2 = wx.Button(panel, -1, "Fun && Games", pos=(30, 50),
>>size=(100,25) )
>> button3 = wx.Button(panel, -1, "Fun &Games" , pos=(30, 80),
>>size=(100,25) )
>>
>> st = wx.StaticText(panel, -1, "Fun &Sun" , pos=(30,110),
>>size=(45,45))
>>
>> self.Bind(wx.EVT_BUTTON, self.OnButton1Click, button1)
>> self.Bind(wx.EVT_BUTTON, self.OnButton2Click, button2)
>> self.Bind(wx.EVT_BUTTON, self.OnButton3Click, button3)
>>
>> def OnButton1Click(self, event):
>> print "Button1 was clicked"
>> def OnButton2Click(self, event):
>> print "Button2 was clicked"
>> def OnButton3Click(self, event):
>> print "Button3 was clicked"
>>
>> app = wx.PySimpleApp()
>> frame = MyFrame()
>> frame.Show()
>> app.MainLoop()
>>
>>
>> When I press Alt-S, I get "Button1 was clicked"! What's going on here??
>>
>> Bob
More information about the wxpython-users
mailing list