Python Forum
[WxPython] how to reopen a closed tab of wx.aui.Notebook?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[WxPython] how to reopen a closed tab of wx.aui.Notebook?
#1
Hello Group, I have a design that I had created in wxformbuilder but I have a difficulty when I close a tab and by a menubar return it open

import wx
import wx.xrc
import wx.aui

###########################################################################
## Class MyFrame2
###########################################################################

class MyFrame2 ( wx.Frame ):

	def __init__( self, parent ):
		wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.Size( 500,300 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )

		self.SetSizeHints( wx.DefaultSize, wx.DefaultSize )
		self.m_mgr = wx.aui.AuiManager()
		self.m_mgr.SetManagedWindow( self )
		self.m_mgr.SetFlags(wx.aui.AUI_MGR_DEFAULT)

		self.m_menubar2 = wx.MenuBar( 0 )
		self.m_menu4 = wx.Menu()
		self.m_menuItem8 = wx.MenuItem( self.m_menu4, wx.ID_ANY, u"Close", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu4.Append( self.m_menuItem8 )

		self.m_menu4.AppendSeparator()

		self.m_menuItem9 = wx.MenuItem( self.m_menu4, wx.ID_ANY, u"Open tab", wx.EmptyString, wx.ITEM_NORMAL )
		self.m_menu4.Append( self.m_menuItem9 )

		self.m_menubar2.Append( self.m_menu4, u"Inicio" )

		self.SetMenuBar( self.m_menubar2 )

		self.m_statusBar2 = self.CreateStatusBar( 1, wx.STB_SIZEGRIP, wx.ID_ANY )
		self.m_auinotebook3 = wx.aui.AuiNotebook( self, wx.ID_ANY, wx.DefaultPosition, wx.Size( 240,-1 ), wx.aui.AUI_NB_DEFAULT_STYLE )
		self.m_mgr.AddPane( self.m_auinotebook3, wx.aui.AuiPaneInfo() .Left() .PinButton( True ).Dock().Resizable().FloatingSize( wx.DefaultSize ) )

		self.m_panel4 = wx.Panel( self.m_auinotebook3, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
		self.m_auinotebook3.AddPage( self.m_panel4, u"a page", False, wx.NullBitmap )


		self.m_mgr.Update()
		self.Centre( wx.BOTH )

		# Connect Events
		self.Bind( wx.EVT_MENU, self.CloseUi, id = self.m_menuItem8.GetId() )
		self.Bind( wx.EVT_MENU, self.Open_Tab, id = self.m_menuItem9.GetId() )

	def __del__( self ):
		self.m_mgr.UnInit()



	# Virtual event handlers, overide them in your derived class
	def CloseUi( self, event ):
		event.Skip()

	def Open_Tab( self, event ):
		event.Skip()

if __name__ == "__main__":
		app = wx.App(False)
		frame = MyFrame2(None)
		frame.Show()
		app.MainLoop()
this event is responsible for opening the tab that had closed
def Open_Tab( self, event ):
		event.Skip()
Could you please help me? I would appreciate it for your time Pray
Reply
#2
When you close a tab it is destroyed, you cant re-open it, in the open_tab event, code will have to be added to create a new tab.
Reply
#3
(Feb-17-2019, 05:04 PM)Yoriz Wrote: When you close a tab it is destroyed, you cant re-open it, in the open_tab event, code will have to be added to create a new tab.
But how could I do it?, since I only have this information
Documentation
of this more I have been struck by the following
EVT_AUINOTEBOOK_PAGE_CLOSE: --> A page is about to be closed. Processes a wxEVT_AUINOTEBOOK_PAGE_CLOSE event.
EVT_AUINOTEBOOK_PAGE_CLOSED(winid, fn): --> A page has been closed. Processes a wxEVT_AUINOTEBOOK_PAGE_CLOSED event.
I plan to use the following
RemovePage
but this only closes the tab but not its content and then I use the following to open the tab
AddPage
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [closed] "checked" variable (attribute?) origin? paul18fr 4 366 Mar-05-2024, 04:20 PM
Last Post: deanhystad
  [Tkinter] Extrakt a Variable from a closed tkinter window hWp 5 3,705 Aug-23-2019, 09:01 PM
Last Post: woooee
  [Tkinter] Displaying an image that can't be closed nicochulo 4 3,560 Feb-15-2018, 10:27 AM
Last Post: nicochulo
  [PyQt] Whole application is closed by subwindows Alfalfa 1 7,323 Oct-03-2017, 03:22 PM
Last Post: Alfalfa

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020