Adding widgets (buttons) to the right of the tab selector in a notebook

Hello wxPython users,

I have a notebook that only has two tabs. The UI inside either tab as well as outside the notebook is very rich, so I am pressed for screen real estate.

I am wondering if there is a way of placing buttons (or other widgets of similar height) in the space at to top of the notebook widget, in the blank space just to the right of the two tabs selectors. The buttons’ functionality is common to both tabs and affect their appearance so this location is actually very intuitive from a UX point of view.

Evidently it is straightforward to have the buttons outside the notebook, for example just above it, but it would be material in my case to gain a little bit of screen real estate by moving the buttons to the right of the tab selection area, which is currently empty.

Thank you.

well, if you get anything in there but another page it would be real magic :rofl:

but what about a PopupMenu :wink:

You might try adding two pseudo-pages which veto their activation but have the
side effect of the button inside the veto method :smiley:

Karsten

Thank you @Karsten_Hilbert and @da-dada! Both of the suggestions were good ones. The pseudo tab worked well from a functionality point of view point but the appearance of the button (just like a tab) was confusing from a UX point of view. The popup menu was also functional, but the user experience was less convenient because these buttons are clicked frequently and in a popup they need an extra click and additional mouse motion. I ended up just accepting the small loss of screen real estate.

instead of the PopupMenu a modeless Dialog on top saves the click (and can be moved around) :smirk:

Assuming you are using a standard wx.Notebook, then all suggestions given are pretty much exhausting the possibilities.

Just in case you are able to use AuiNotebook from wx.lib.agw.aui though, you can add your own custom buttons to the left or right of the tab area:

https://docs.wxpython.org/wx.lib.agw.aui.auibook.AuiNotebook.html#wx.lib.agw.aui.auibook.AuiNotebook.AddTabAreaButton

The wxPython demo for AUI (under AGW) has also an example on how to do that, under the menu “Notebook” => “Show Custom Buttons in Tab Area”.

Andrea.

Thank you @Andrea_Gavana It is good to be reminded about this feature AuiNotebook even if I am not using it in this project.