Help with AuiNotebook - tab preset pos

Hello,
I’d like to use the AuiNotebook because I need to have a frame with tabs on top and bottom and I love how this lets you drag and drop them as well. I’m trying to implement this and I’m hung up on how to set the tab locations when the window frame is launched. For example, I’d like the window to open with the tabs preset to the positions shown in this example. Unfortunately the only way I can move tabs around is to drag with mouse. How do I get them “pre-loaded” in those positions when the window is launched? I’ve looked here:
https://wxpython.org/Phoenix/docs/html/wx.aui.AuiNotebook.html#wx.aui.AuiNotebook.Selection

But don’t see a way to do it with a method or the init constructor.

Here is an example of what I’d like to set the locations to on window launch.

Rob,

Your issue is clear, although…

It would help if you can also upload or link to a source code example instead of a JPG screenshot only. I might have a - customized - solution for you.

Further info in the wxPython docs. Take a look at the 2 possible AuiNotebook implementations. For the 2nd result see LoadPerspective and SavePerspective .

Thom

Hi Thom,

Sorry to bug you again :slight_smile: I will review those links tonight. I’ve also attached the example I was learning from.

Example.zip (4.4 KB)

Thanks Rob,

You’re not bugging at all. I will look into your example after you’ve decided which of both implementations you want to use.

Please note that the AGW implementation natively supports restoring tabs and other interface elements through the perspective concept.

On the other hand, the basic AUI notebook implementation from your example needs lots of customization code before it can even compare to the AGW one.

Choose wisely😏

Slaînte,
Thom

Oh, so AGW would probably be a better path forward for me then? Would this require custom code to preset tab locations? I am not tied to the AUI path.

  1. Yes, I think it would be a better path forward.
  2. No, it wouldn’t require custom code to preset tab locations. You can use Load/SavePerspective as linked earlier in this topic.

Check out the demo source code for AGW notebook on GitHub or in your local wx install.

Run <YourLocalPythonRootDir>/Lib/site-packages/wxPython-demo/demo.pyw and navigate here:

image

Enjoy the read and take your time while at it, there’s a lot to consume.

Hi Thom! Thanks so much! That example is large! :slight_smile: I will start studying up on that now this is so helpful! Thanks again!!

You’re welcome, Rob.

To make it a little easier for you, with credits to @Andrea_Gavana and @driscollis respectively, here goes:

  1. AuiNotebook (AGW) at wxPyWiki

  2. The “Book” Controls of wxPython (Part 2 of 2)

Enjoy,
Thom

1 Like

Another possibility is to look at the “Split” method of AuiNotebook:

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

You simply build your notebook as usually then you call Split twice to move one page to the left and one to the bottom. I’m not sure if it will work - I’ve never tried it myself - but it’s worth a shot :slight_smile: .

Andrea.

Let me know if any of that code in number 2 doesn’t work. I haven’t had a chance to do a thorough audit of my wxPython tutorials yet, although I know most of them work in wxPython 4.

@driscollis Here you go; some minor fixes were needed, see attachment, please review.

ForMike - ORG (2009) - Fixed - DIFF - Notebooks-agw_NEW.zip (26.4 KB)

My full 64-bit environment:

     Python [3.8.2]
   wxPython [4.0.7.post2 msw (phoenix) wxWidgets 3.0.5]
OS Platform [Windows 10 (build 18363), 64-bit edition]

Hi Guys,

When I try to run the python demo I get an error due to failed import of “versions”. Is there supposed to be a versions file I’m missing?

Screenshot attached
108

Seems you downloaded or cloned the demo from the GitHub repo.

Try this one:

wxPython-demo from https://extras.wxpython.org/wxPython4/extras/4.1.0

The demo/version.py file is generated when wxPython is built, and is not included in git any longer. So if you want to use the git version of the demo then it’s expected that you will also be doing a build of wxPython.

Otherwise, the link at extras that Thom shared is the right way to go.

Ok awesome! Thanks Guys! I got this demo up and running and WOW is this thing sweet and complex!!