NotebookCtrl usage questions

Hi,

I'm a real newby at using wxPython, so if I'm asking anything that should be obvious, please forgive me. In the code at the bottom, I'm creating a frame with a NotebookCtrl and three pages. The colored tabs and tab text are larger and bolder than normal (in the eventual application, the tabs will be changing color up to 3 times/second), and there will be additional notebooks on each page). I started with code generated by wxGlade, rearranged the code a bit so I could see what was it was doing, then substituted the NotebookCtrl object for the Notebook and added some of its functionality. It's not doing all that I'd like. I've looked through the NotebookCtrl demo but still have the following questions/problems:

1) As the tab text gets larger than the default, it is not vertically centered. Is there a way to do this?
2) My tool tip string does not show, making me think I've not implemented it correctly.
3) I would like the focus and currently selected tab to be clearer (like the brown line above the tabs that appear in demo program). The SetHighlightSelection and SetSelectionColour methods aren't having any effect.
4) Is there a way to make the tab shapes different, such as having rounded corners?

I would very much appreciate any assistance.

Chris

···

-----------------------------------------

import wx
import NotebookCtrl as NC

class MyFrame(wx.Frame):
    def __init__(self, *args, **kwds):
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.SetTitle("MyFrame")

        # Instantiate Station Notebook and tabs.
        # Make its parent the top frame.
        # Assign pages to the notebook.
                self.station_nb = NC.NotebookCtrl(self, -1)
        self.station_nb_tab_S1 = wx.Panel(self.station_nb, -1)
        self.station_nb_tab_S2 = wx.Panel(self.station_nb, -1)
        self.station_nb_tab_S3 = wx.Panel(self.station_nb, -1)

                # Set Station Notebook properties
        self.station_nb.SetMinSize((512,256))
        self.station_nb.SetToolTipString("View FRONT Station results")
        self.station_nb.SetHighlightSelection(True)
        self.station_nb.SetSelectionColour(wx.NamedColor("Brown"))
        self.station_nb.SetUseFocusIndicator(True)

        # Add pages to Station Notebook
        self.station_nb.AddPage(self.station_nb_tab_S1, " S1: Color ")
        self.station_nb.AddPage(self.station_nb_tab_S2, " S2: UV ")
        self.station_nb.AddPage(self.station_nb_tab_S3, " S3: Color ")
                # Color the tabs
        self.station_nb.SetPageColour(0, wx.RED)
        self.station_nb.SetPageColour(1, wx.NamedColor("Yellow"))
        self.station_nb.SetPageColour(2, wx.GREEN)
                # Set the tab fonts
        self.station_nb.SetPageTextFont(0, wx.Font(11, wx.SWISS, wx.NORMAL, wx.NORMAL, 0, "Arial Black"))
        self.station_nb.SetPageTextFont(1, wx.Font(11, wx.SWISS, wx.NORMAL, wx.NORMAL, 0, "Arial Black"))
        self.station_nb.SetPageTextFont(2, wx.Font(11, wx.SWISS, wx.NORMAL, wx.NORMAL, 0, "Arial Black"))
              # Make a sizer and add to the frame
        sizer_1 = wx.BoxSizer(wx.VERTICAL)
        sizer_1.Add(self.station_nb)
        self.SetAutoLayout(True)
        self.SetSizer(sizer_1)
        sizer_1.Fit(self)
        sizer_1.SetSizeHints(self)
        self.Layout()

# end of class MyFrame

if __name__ == "__main__":
    app = wx.PySimpleApp(0)
    wx.InitAllImageHandlers()
    frame_1 = MyFrame(None, -1, "")
    app.SetTopWindow(frame_1)
    frame_1.Show()
# frame_1.ShowFullScreen(True)
    app.MainLoop()

I didn't answer this the other day because I was expecting Andrea to answer it. He may not have seen it, so I'll give him a little nudge with this message. :wink:

Robin

Chris Botos wrote:

···

Hi,

I'm a real newby at using wxPython, so if I'm asking anything that should be obvious, please forgive me. In the code at the bottom, I'm creating a frame with a NotebookCtrl and three pages. The colored tabs and tab text are larger and bolder than normal (in the eventual application, the tabs will be changing color up to 3 times/second), and there will be additional notebooks on each page). I started with code generated by wxGlade, rearranged the code a bit so I could see what was it was doing, then substituted the NotebookCtrl object for the Notebook and added some of its functionality. It's not doing all that I'd like. I've looked through the NotebookCtrl demo but still have the following questions/problems:

1) As the tab text gets larger than the default, it is not vertically centered. Is there a way to do this?
2) My tool tip string does not show, making me think I've not implemented it correctly.
3) I would like the focus and currently selected tab to be clearer (like the brown line above the tabs that appear in demo program). The SetHighlightSelection and SetSelectionColour methods aren't having any effect.
4) Is there a way to make the tab shapes different, such as having rounded corners?

I would very much appreciate any assistance.

Chris

-----------------------------------------

import wx
import NotebookCtrl as NC

class MyFrame(wx.Frame):
   def __init__(self, *args, **kwds):
       kwds["style"] = wx.DEFAULT_FRAME_STYLE
       wx.Frame.__init__(self, *args, **kwds)
       self.SetTitle("MyFrame")

       # Instantiate Station Notebook and tabs.
       # Make its parent the top frame.
       # Assign pages to the notebook.
              self.station_nb = NC.NotebookCtrl(self, -1)
       self.station_nb_tab_S1 = wx.Panel(self.station_nb, -1)
       self.station_nb_tab_S2 = wx.Panel(self.station_nb, -1)
       self.station_nb_tab_S3 = wx.Panel(self.station_nb, -1)

              # Set Station Notebook properties
       self.station_nb.SetMinSize((512,256))
       self.station_nb.SetToolTipString("View FRONT Station results")
       self.station_nb.SetHighlightSelection(True)
       self.station_nb.SetSelectionColour(wx.NamedColor("Brown"))
       self.station_nb.SetUseFocusIndicator(True)

       # Add pages to Station Notebook
       self.station_nb.AddPage(self.station_nb_tab_S1, " S1: Color ")
       self.station_nb.AddPage(self.station_nb_tab_S2, " S2: UV ")
       self.station_nb.AddPage(self.station_nb_tab_S3, " S3: Color ")
              # Color the tabs
       self.station_nb.SetPageColour(0, wx.RED)
       self.station_nb.SetPageColour(1, wx.NamedColor("Yellow"))
       self.station_nb.SetPageColour(2, wx.GREEN)
              # Set the tab fonts
       self.station_nb.SetPageTextFont(0, wx.Font(11, wx.SWISS, wx.NORMAL, wx.NORMAL, 0, "Arial Black"))
       self.station_nb.SetPageTextFont(1, wx.Font(11, wx.SWISS, wx.NORMAL, wx.NORMAL, 0, "Arial Black"))
       self.station_nb.SetPageTextFont(2, wx.Font(11, wx.SWISS, wx.NORMAL, wx.NORMAL, 0, "Arial Black"))
            # Make a sizer and add to the frame
       sizer_1 = wx.BoxSizer(wx.VERTICAL)
       sizer_1.Add(self.station_nb)
       self.SetAutoLayout(True)
       self.SetSizer(sizer_1)
       sizer_1.Fit(self)
       sizer_1.SetSizeHints(self)
       self.Layout()

# end of class MyFrame

if __name__ == "__main__":
   app = wx.PySimpleApp(0)
   wx.InitAllImageHandlers()
   frame_1 = MyFrame(None, -1, "")
   app.SetTopWindow(frame_1)
   frame_1.Show()
# frame_1.ShowFullScreen(True)
   app.MainLoop()

Thanks, Robin! I've actually figured out two of the problems. Please see below for the discussion. Plus, I was just now going to post another question regarding event handling with the notebook. I'll go ahead and send that in another message to keep the messages less messy.

Chris

Robin Dunn wrote:

I didn't answer this the other day because I was expecting Andrea to answer it. He may not have seen it, so I'll give him a little nudge with this message. :wink:

Robin

Chris Botos wrote:

Hi,

I'm a real newby at using wxPython, so if I'm asking anything that should be obvious, please forgive me. In the code at the bottom, I'm creating a frame with a NotebookCtrl and three pages. The colored tabs and tab text are larger and bolder than normal (in the eventual application, the tabs will be changing color up to 3 times/second), and there will be additional notebooks on each page). I started with code generated by wxGlade, rearranged the code a bit so I could see what was it was doing, then substituted the NotebookCtrl object for the Notebook and added some of its functionality. It's not doing all that I'd like. I've looked through the NotebookCtrl demo but still have the following questions/problems:

1) As the tab text gets larger than the default, it is not vertically centered. Is there a way to do this?

I still haven't been able to center the text.

2) My tool tip string does not show, making me think I've not implemented it correctly.

I set the string but had not enabled it. It works now.

3) I would like the focus and currently selected tab to be clearer (like the brown line above the tabs that appear in demo program). The SetHighlightSelection and SetSelectionColour methods aren't having any effect.

I discovered that with a larger font I had to increase the vertical tab sizes. Once big enough, the highlight worked fine. However, if I made it too big, and the tab is colored, a horizontal white line appears across the middle of the tab. Is this a required workaround, or is there a more predictable way of doing it?

4) Is there a way to make the tab shapes different, such as having rounded corners?

I'd still like to know how to do this, if it is possible.

···

I would very much appreciate any assistance.

Chris

-----------------------------------------

import wx
import NotebookCtrl as NC

class MyFrame(wx.Frame):
   def __init__(self, *args, **kwds):
       kwds["style"] = wx.DEFAULT_FRAME_STYLE
       wx.Frame.__init__(self, *args, **kwds)
       self.SetTitle("MyFrame")

       # Instantiate Station Notebook and tabs.
       # Make its parent the top frame.
       # Assign pages to the notebook.
              self.station_nb = NC.NotebookCtrl(self, -1)
       self.station_nb_tab_S1 = wx.Panel(self.station_nb, -1)
       self.station_nb_tab_S2 = wx.Panel(self.station_nb, -1)
       self.station_nb_tab_S3 = wx.Panel(self.station_nb, -1)

              # Set Station Notebook properties
       self.station_nb.SetMinSize((512,256))
       self.station_nb.SetToolTipString("View FRONT Station results")
       self.station_nb.SetHighlightSelection(True)
       self.station_nb.SetSelectionColour(wx.NamedColor("Brown"))
       self.station_nb.SetUseFocusIndicator(True)

       # Add pages to Station Notebook
       self.station_nb.AddPage(self.station_nb_tab_S1, " S1: Color ")
       self.station_nb.AddPage(self.station_nb_tab_S2, " S2: UV ")
       self.station_nb.AddPage(self.station_nb_tab_S3, " S3: Color ")
              # Color the tabs
       self.station_nb.SetPageColour(0, wx.RED)
       self.station_nb.SetPageColour(1, wx.NamedColor("Yellow"))
       self.station_nb.SetPageColour(2, wx.GREEN)
              # Set the tab fonts
       self.station_nb.SetPageTextFont(0, wx.Font(11, wx.SWISS, wx.NORMAL, wx.NORMAL, 0, "Arial Black"))
       self.station_nb.SetPageTextFont(1, wx.Font(11, wx.SWISS, wx.NORMAL, wx.NORMAL, 0, "Arial Black"))
       self.station_nb.SetPageTextFont(2, wx.Font(11, wx.SWISS, wx.NORMAL, wx.NORMAL, 0, "Arial Black"))
            # Make a sizer and add to the frame
       sizer_1 = wx.BoxSizer(wx.VERTICAL)
       sizer_1.Add(self.station_nb)
       self.SetAutoLayout(True)
       self.SetSizer(sizer_1)
       sizer_1.Fit(self)
       sizer_1.SetSizeHints(self)
       self.Layout()

# end of class MyFrame

if __name__ == "__main__":
   app = wx.PySimpleApp(0)
   wx.InitAllImageHandlers()
   frame_1 = MyFrame(None, -1, "")
   app.SetTopWindow(frame_1)
   frame_1.Show()
# frame_1.ShowFullScreen(True)
   app.MainLoop()

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org