[wxPython-users] Ampersands and static text
Guilherme Polo
ggpolo at gmail.com
Tue Apr 24 12:38:53 PDT 2007
Uhm.. not here.
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
>
>
>
>
>
--
-- Guilherme H. Polo Goncalves
More information about the wxpython-users
mailing list