atom feed4 messages in com.googlegroups.wxpython-usersAGW AUI Notebook Right Close Button N...
FromSent OnAttachments
Mike DriscollDec 8, 2009 1:54 pm.py
Andrea GavanaDec 8, 2009 2:23 pm 
Mike DriscollDec 8, 2009 4:35 pm 
Mike DriscollDec 9, 2009 6:46 am 
Subject:AGW AUI Notebook Right Close Button Not Working
From:Mike Driscoll ("m.@pythonlibrary.org)
Date:Dec 8, 2009 1:54:23 pm
List:com.googlegroups.wxpython-users
Attachments:

Hi,

I am working on a tutorial for Andrea Gavana's AUI Notebook and discovered that if I set the "Close Button at Right" option, the close button does not work. This doesn't work in my demo application and it also does not work in the official wxPython demo. I tried downloading the latest SVN version of these files and they didn't work either. I've included my demo app for you all to look over.

I'm on Windows Vista SP2, wxPython 2.8.10.1 (unicode), Python 2.5.2

----------------- Mike Driscoll

Blog: http://blog.pythonlibrary.org

#---------------------------------------------------------------------- # agwAUINBookFeaturesDemo.py # # Created: December 2009 # # Author: Mike Driscoll - mi@pythonlibrary.org # # Note: Some code comes from the wxPython demo # #----------------------------------------------------------------------

import panelOne, panelTwo, panelThree import wx import wx.lib.agw.aui as aui

ID_NotebookArtGloss = 0 ID_NotebookArtSimple = 1 ID_NotebookArtVC71 = 2 ID_NotebookArtFF2 = 3 ID_NotebookArtVC8 = 4 ID_NotebookArtChrome = 5

######################################################################## class AUIManager(aui.AuiManager): """ AUI Manager class """

#---------------------------------------------------------------------- def __init__(self, managed_window): """Constructor""" aui.AuiManager.__init__(self) self.SetManagedWindow(managed_window)

######################################################################## class AUINotebook(aui.AuiNotebook): """ AUI Notebook class """

#---------------------------------------------------------------------- def __init__(self, parent): """Constructor""" aui.AuiNotebook.__init__(self, parent=parent) self.default_style = aui.AUI_NB_DEFAULT_STYLE |
aui.AUI_NB_TAB_EXTERNAL_MOVE | wx.NO_BORDER self.SetWindowStyleFlag(self.default_style)

# add some pages to the notebook pages = [panelOne, panelTwo, panelThree]

x = 1 for page in pages: label = "Tab #%i" % x tab = page.TabPanel(self) self.AddPage(tab, label, False) x += 1

######################################################################## class DemoFrame(wx.Frame): """ wx.Frame class """

""" notebook_menu.AppendRadioItem(ID_NotebookArtGloss, "Glossy Theme (Default)") notebook_menu.AppendRadioItem(ID_NotebookArtSimple, "Simple Theme") notebook_menu.AppendRadioItem(ID_NotebookArtVC71, "VC71 Theme") notebook_menu.AppendRadioItem(ID_NotebookArtFF2, "Firefox 2 Theme") notebook_menu.AppendRadioItem(ID_NotebookArtVC8, "VC8 Theme") notebook_menu.AppendRadioItem(ID_NotebookArtChrome, "Chrome Theme") """

#---------------------------------------------------------------------- def __init__(self): """Constructor""" title = "AGW AUI Notebook Feature Tutorial" wx.Frame.__init__(self, None, wx.ID_ANY, title=title, size=(600,400)) self.themeDict = {"Glossy Theme (Default)":0, "Simple Theme":1, "VC71 Theme":2, "Firefox 2 Theme":3, "VC8 Theme":4, "Chrome Theme":5, }

# create the AUI manager self.aui_mgr = AUIManager(self)

# create the AUI Notebook self.notebook = AUINotebook(self)

self._notebook_style = self.notebook.default_style

# add notebook to AUI manager self.aui_mgr.AddPane(self.notebook, aui.AuiPaneInfo().Name("notebook_content"). CenterPane().PaneBorder(False)) self.aui_mgr.Update()

# create menu and tool bars self.createMenu() self.createTB()

#---------------------------------------------------------------------- def createMenu(self): """ Create the menu """ def doBind(item, handler): """ Create menu events. """ self.Bind(wx.EVT_MENU, handler, item)

menubar = wx.MenuBar()

fileMenu = wx.Menu()

doBind( fileMenu.Append(wx.ID_ANY, "&Exit\tAlt+F4", "Exit Program"),self.onExit)

optionsMenu = wx.Menu()

doBind( optionsMenu.Append(wx.ID_ANY, "Disable Current Tab"), self.onDisableTab)

# add the menus to the menubar menubar.Append(fileMenu, "File") menubar.Append(optionsMenu, "Options")

self.SetMenuBar(menubar)

#---------------------------------------------------------------------- def createTB(self): """ notebook_menu.AppendRadioItem(ID_NotebookNoCloseButton, "No Close
Button") notebook_menu.AppendRadioItem(ID_NotebookCloseButton, "Close Button At
Right") notebook_menu.AppendRadioItem(ID_NotebookCloseButtonAll, "Close Button
On All Tabs") notebook_menu.AppendRadioItem(ID_NotebookCloseButtonActive, "Close
Button On Active Tab") notebook_menu.AppendSeparator() notebook_menu.AppendCheckItem(ID_NotebookCloseOnLeft, "Close Button On
The Left Of Tabs") notebook_menu.AppendSeparator() notebook_menu.AppendRadioItem(ID_NotebookAlignTop, "Tab Top Alignment") notebook_menu.AppendRadioItem(ID_NotebookAlignBottom, "Tab Bottom
Alignment") notebook_menu.AppendSeparator() notebook_menu.AppendCheckItem(ID_NotebookAllowTabMove, "Allow Tab Move") notebook_menu.AppendCheckItem(ID_NotebookAllowTabExternalMove, "Allow
External Tab Move") notebook_menu.AppendCheckItem(ID_NotebookAllowTabSplit, "Allow Notebook
Split") notebook_menu.AppendCheckItem(ID_NotebookTabFloat, "Allow Single Tab
Floating") notebook_menu.AppendSeparator() notebook_menu.AppendCheckItem(ID_NotebookDclickUnsplit, "Unsplit On Sash
Double-Click") notebook_menu.AppendCheckItem(ID_NotebookTabDrawDnd, "Draw Tab Image On
Drag 'n' Drop") notebook_menu.AppendSeparator() notebook_menu.AppendCheckItem(ID_NotebookScrollButtons, "Scroll Buttons
Visible") notebook_menu.AppendCheckItem(ID_NotebookWindowList, "Window List Button
Visible") notebook_menu.AppendCheckItem(ID_NotebookTabFixedWidth, "Fixed-Width
Tabs") notebook_menu.AppendSeparator() notebook_menu.AppendCheckItem(ID_NotebookHideSingle, "Hide On Single
Tab") notebook_menu.AppendCheckItem(ID_NotebookSmartTab, "Use Smart Tabbing") notebook_menu.AppendCheckItem(ID_NotebookUseImagesDropDown, "Use Tab
Images In Dropdown Menu") notebook_menu.AppendCheckItem(ID_NotebookCustomButtons, "Show Custom
Buttons In Tab Area") """ TBFLAGS = ( wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_FLAT ) tb = self.CreateToolBar(TBFLAGS) keys = self.themeDict.keys() keys.sort() choices = keys cb = wx.ComboBox(tb, wx.ID_ANY, "Glossy Theme (Default)", choices=choices, size=wx.DefaultSize, style=wx.CB_DROPDOWN) cb.Bind(wx.EVT_COMBOBOX, self.onChangeTheme) tb.AddControl(cb) tb.AddSeparator()

self.closeChoices = ["No Close Button", "Close Button At Right", "Close Button On All Tabs", "Close Button On Active Tab"] cb = wx.ComboBox(tb, wx.ID_ANY, self.closeChoices[3], choices=self.closeChoices, size=wx.DefaultSize, style=wx.CB_DROPDOWN) cb.Bind(wx.EVT_COMBOBOX, self.onChangeTabClose) tb.AddControl(cb)

tb.Realize()

#---------------------------------------------------------------------- def onChangeTabClose(self, event): """ Change how the close button behaves on a tab

Note: Based partially on the agw AUI demo """ choice = event.GetString() self._notebook_style &= ~(aui.AUI_NB_CLOSE_BUTTON | aui.AUI_NB_CLOSE_ON_ACTIVE_TAB | aui.AUI_NB_CLOSE_ON_ALL_TABS)

# note that this close button doesn't work for some reason if choice == "Close Button At Right": self._notebook_style ^= aui.AUI_NB_CLOSE_BUTTON elif choice == "Close Button On All Tabs": self._notebook_style ^= aui.AUI_NB_CLOSE_ON_ALL_TABS elif choice == "Close Button On Active Tab": self._notebook_style ^= aui.AUI_NB_CLOSE_ON_ACTIVE_TAB

self.notebook.SetWindowStyleFlag(self._notebook_style) self.notebook.Refresh() self.notebook.Update()

#---------------------------------------------------------------------- def onChangeTheme(self, event): """ Changes the notebook's theme

Note: Based partially on the agw AUI demo """

print event.GetString() evId = self.themeDict[event.GetString()] print evId

all_panes = self.aui_mgr.GetAllPanes()

for pane in all_panes:

if isinstance(pane.window, aui.AuiNotebook): nb = pane.window

if evId == ID_NotebookArtGloss:

nb.SetArtProvider(aui.AuiDefaultTabArt()) self._notebook_theme = 0

elif evId == ID_NotebookArtSimple: nb.SetArtProvider(aui.AuiSimpleTabArt()) self._notebook_theme = 1

elif evId == ID_NotebookArtVC71: nb.SetArtProvider(aui.VC71TabArt()) self._notebook_theme = 2

elif evId == ID_NotebookArtFF2: nb.SetArtProvider(aui.FF2TabArt()) self._notebook_theme = 3

elif evId == ID_NotebookArtVC8: nb.SetArtProvider(aui.VC8TabArt()) self._notebook_theme = 4

elif evId == ID_NotebookArtChrome: nb.SetArtProvider(aui.ChromeTabArt()) self._notebook_theme = 5

#nb.SetWindowStyleFlag(self._notebook_style) nb.Refresh() nb.Update()

#---------------------------------------------------------------------- def onDisableTab(self, event): """ """ page = self.notebook.GetCurrentPage() page_idx = self.notebook.GetPageIndex(page)

self.notebook.EnableTab(page_idx, False) self.notebook.AdvanceSelection()

#---------------------------------------------------------------------- def onExit(self, event): """ """ self.Close()

#---------------------------------------------------------------------- if __name__ == "__main__": app = wx.PySimpleApp() frame = DemoFrame() frame.Show() app.MainLoop()