wxNotebook tab captions

Hi,

I noticed that:

wxNotebook.SetPageText(pageIndex,"H&ello")

doesn't have the expected result. I wanted the "e" to be
underlined and an automatic accelerator for Alt+E, similar to
other controls such as menu items.

I am a newbie, and am going to look into accelerator tables
tomorrow, but was wondering if anyone has anything to say about
this in the meanwhile.

Thanks.

···

--
Paul

Paul McNett wrote:

Hi,

I noticed that:

wxNotebook.SetPageText(pageIndex,"H&ello")

doesn't have the expected result. I wanted the "e" to be underlined and an automatic accelerator for Alt+E, similar to other controls such as menu items.

I don't think this is supported.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Popup menu question. I created a Menu with all
the items in place, etc.

Just before popping the menu up, I want to change
the title to some value, depending on the context.

To do that, I call m.SetTitle(t) where m is the
instance of the menu and t is the new title text.

This does not work. The title shown is the same
one defined at the time the menu was first created.

What's wrong?

/Jean Brouwers

PS) This is wxPython2.4.1.2/Python2.3.1 on RH8/GTK2.

Robin Dunn writes:

> wxNotebook.SetPageText(pageIndex,"H&ello")
>
> doesn't have the expected result. I wanted the "e" to be
> underlined and an automatic accelerator for Alt+E, similar
> to other controls such as menu items.

I don't think this is supported.

It doesn't appear to be, which is a shame. Anyone have any ideas
on how to at least "fake it"? I'm converting my app framework
from Visual FoxPro to wxPython and one thing my clients are
used to is navigating the pages in my frames using the alt-keys
instead of having to reach for the mouse. Each frame has
between 3-n pages:

  Page 1: Select: user can manipulate the where clause of the
select statement

  Page 2: Browse: user can incrementally browse the result set in
a grid.

  Page 3: Edit: user can edit the fields in the record that they
selected on page 2.

  Additional pages for child tables, etc.

Is there at least a way to provide for the user tabbing to the
page tabs so they can use the arrow keys to select a page?

Thanks!

···

--
Paul

Paul McNett wrote:

Robin Dunn writes:

wxNotebook.SetPageText(pageIndex,"H&ello")

doesn't have the expected result. I wanted the "e" to be
underlined and an automatic accelerator for Alt+E, similar
to other controls such as menu items

This is how I fake it:

1) Create menu items with method for each tab

     menu = wxMenu() menu.Append(self.ID_SELECT_1ST_PAGE, "1st page\tCTRL-A")
     menu.Append(self.ID_SELECT_2ND_PAGE, "2nd page\tCTRL-B")
     EVT_MENU(self, self.ID_SELECT_1ST_PAGE, self.OnSelect1stPage)
     EVT_MENU(self, self.ID_SELECT_2ND_PAGE, self.OnSelect2ndPage)

2) Create bitmap images for each notebook tab's text with the underline character to indicate the accelerator key and assign it to wxImageList:

    self.notebook_imagelist = wxImageList(136, 17)
    self.notebook_imagelist.Add(images.getadd_app_selectBitmap())
    self.notebook_imagelist.Add(images.getedit_app_selectBitmap())
    self.notebook.AssignImageList(self.notebook_imagelist)
   2) Set each notebook page to use the correct image:

    self.notebook.SetPageImage(0, 0) ##set image for 1st notebook page
    self.notebook.SetPageImage(1, 1) ## set image for 2nd notebook page
4) Set each method to cals the correct tab:

    def OnSelect1stPage(self, event)
           self.notebook.SetSelection(0) def OnSelect2ndPage(self, event):
          self.notebook.SetSelection(1)
With the appropriate acclerator key (Ctrl + a), the user will trigger the menu's event for the appropriate method to set the page.

I don't think this is supported.
   
It doesn't appear to be, which is a shame. Anyone have any ideas on how to at least "fake it"? I'm converting my app framework from Visual FoxPro to wxPython and one thing my clients are used to is navigating the pages in my frames using the alt-keys instead of having to reach for the mouse. Each frame has between 3-n pages:

Page 1: Select: user can manipulate the where clause of the select statement

Page 2: Browse: user can incrementally browse the result set in a grid.

Page 3: Edit: user can edit the fields in the record that they selected on page 2.

Additional pages for child tables, etc.

Is there at least a way to provide for the user tabbing to the page tabs so they can use the arrow keys to select a page?

I set the style for all windows to use wxWANTS_CHARS and send all key event to the parent's window. So now I can define whatever key event in the parent's windows to trigger the correct respond. It is really really ugly but it works.

Hope this help.

Derrick Lim

···

Thanks!

Derrick wrote:

This is how I fake it:

1) Create menu items with method for each tab

     menu = wxMenu()
     menu.Append(self.ID_SELECT_1ST_PAGE, "1st page\tCTRL-A")
     menu.Append(self.ID_SELECT_2ND_PAGE, "2nd page\tCTRL-B")
     EVT_MENU(self, self.ID_SELECT_1ST_PAGE, self.OnSelect1stPage)
     EVT_MENU(self, self.ID_SELECT_2ND_PAGE, self.OnSelect2ndPage)

This all looks like a great approach, but just ot add: If you don't want
the menu items, you don't need them. You can create accelerators
directly with a wxAcceleratorTable. I couldn't find an example of this
in teh Demo, but there are a few in the Wiki, including:

http://wiki.wxpython.org/index.cgi/OrganizingYourCode

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                        
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Jean Brouwers wrote:

Popup menu question. I created a Menu with all
the items in place, etc.

Just before popping the menu up, I want to change
the title to some value, depending on the context.

To do that, I call m.SetTitle(t) where m is the
instance of the menu and t is the new title text.

This does not work. The title shown is the same
one defined at the time the menu was first created.

What's wrong?

/Jean Brouwers

PS) This is wxPython2.4.1.2/Python2.3.1 on RH8/GTK2.

I think wxGTK only supports setting the menu title when the wxMenu is created. You'll need to recreate the menu each time you need to change the title. Don't forget to Destroy() the old one.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Paul McNett wrote:

Is there at least a way to provide for the user tabbing to the page tabs so they can use the arrow keys to select a page?

That has been added in 2.5.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Chris Barker wrote:

Derrick wrote:

This is how I fake it:

1) Create menu items with method for each tab

    menu = wxMenu()
    menu.Append(self.ID_SELECT_1ST_PAGE, "1st page\tCTRL-A")
    menu.Append(self.ID_SELECT_2ND_PAGE, "2nd page\tCTRL-B")
    EVT_MENU(self, self.ID_SELECT_1ST_PAGE, self.OnSelect1stPage)
    EVT_MENU(self, self.ID_SELECT_2ND_PAGE, self.OnSelect2ndPage)
   
This all looks like a great approach, but just ot add: If you don't want
the menu items, you don't need them. You can create accelerators
directly with a wxAcceleratorTable. I couldn't find an example of this
in teh Demo, but there are a few in the Wiki, including:

http://wiki.wxpython.org/index.cgi/OrganizingYourCode

-Chris

Thanks. That is helpful.

BTW, I left this out. I use a text image with an underline character for the tab to indicate the accelerator key.

Derrick