Ampersands in display text

use && to get it to display properly.

& is use to signify a hotkey

···

On 4/24/07, Bob Klahn <bobklahn@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?

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

···

At 12:30 PM 4/24/2007, Dj Gilcrease wrote:

On 4/24/07, Bob Klahn > bobklahn@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

Uhm.. not here.

···

2007/4/24, Bob Klahn <bobstones@comcast.net>:

At 12:30 PM 4/24/2007, Dj Gilcrease wrote:

On 4/24/07, Bob Klahn <bobklahn@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

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

···

At 03:38 PM 4/24/2007, "Guilherme Polo" <ggpolo@gmail.com> wrote:

2007/4/24, Bob Klahn <bobstones@comcast.net>:

At 12:30 PM 4/24/2007, Dj Gilcrease wrote:

On 4/24/07, Bob Klahn <bobklahn@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 Polo <mailto:ggpolo@gmail.com> scribbled on Tuesday, April 24,
2007 3:39 PM:

When I press Alt-S, I get "Button1 was clicked"! What's going on
here??

Bob

Uhm.. not here.

It may just be a windows thing, but what normally happens under windows is
if you key in the keyboard shortcut for a static text control, the next
control in the tab order of the window takes focus. This allows you to put
labels in front of text entry boxes and have the window act as you expect it
to. I think in this case because the static text control is the last
control added to the window, the processing is wrapping around and
activating the first button on the window.

You can see this if you alter the order that the objects are added to the
window - unless the static text control is last, keying in it's shortcut
will cause the next button added to click.

I'm not sure why the button would be registering a click event, as it should
only be taking focus in the window.

Hopefully Robin can comment on why the button would be registering a
click...

-jdc

···

2007/4/24, Bob Klahn <bobstones@comcast.net>:

Bob Klahn wrote:

···

At 03:38 PM 4/24/2007, "Guilherme Polo" <ggpolo@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?

Just FYI, I am on WinXP SP2 / wxPython 2.8.3 and I also get this behavior.

- Mike