[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r8530 - trunk/gnue-forms/src/uidrivers/wx26/widgets
From: |
johannes |
Subject: |
[gnue] r8530 - trunk/gnue-forms/src/uidrivers/wx26/widgets |
Date: |
Fri, 7 Jul 2006 04:49:38 -0500 (CDT) |
Author: johannes
Date: 2006-07-07 04:49:37 -0500 (Fri, 07 Jul 2006)
New Revision: 8530
Modified:
trunk/gnue-forms/src/uidrivers/wx26/widgets/form.py
trunk/gnue-forms/src/uidrivers/wx26/widgets/page.py
Log:
pep8 for pages. If tabbed is set to none, hide all pages except the
current one. This does not work with grid-controls smoothly now, as
there's a pb with the grid-panel's sizer.
issue87 in-progress
Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/form.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/form.py 2006-07-06 14:31:28 UTC
(rev 8529)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/form.py 2006-07-07 09:49:37 UTC
(rev 8530)
@@ -180,6 +180,7 @@
self._containerToolkitWidget.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED,
self.__on_page_changed, self._containerToolkitWidget)
+ self.show_page(0, True)
self.main_window.SetSizerAndFit(self.__master_sizer)
self.main_window.CenterOnScreen ()
@@ -230,7 +231,7 @@
# Show the requested page
# -------------------------------------------------------------------------
- def show_page(self, page_index):
+ def show_page(self, page_index, initial=False):
"""
Show a given <page> in the current container.
@@ -241,13 +242,22 @@
if isinstance (container, wx.Notebook):
container.SetSelection(page_index)
else:
- for (index, widget) in enumerate(self.pages):
- if index != page_index:
- widget.Hide()
- else:
- widget.Show()
+ self.main_window.Freeze()
+ try:
+ for (index, widget) in enumerate(self.pages):
+ if index != page_index:
+ widget.Hide()
+ else:
+ widget.Show()
+ if not initial:
+ self.main_window.Layout()
+ self.main_window.SetSizerAndFit(self.__master_sizer, True)
+ finally:
+ self.main_window.Thaw()
+
+
# -------------------------------------------------------------------------
# Event-handler
# -------------------------------------------------------------------------
@@ -339,7 +349,7 @@
@param page: UIPage instance of the page to be displayed
"""
- self.show_page(page._pageIndex)
+ self.show_page(page.page_index)
# =============================================================================
Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/page.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/page.py 2006-07-06 14:31:28 UTC
(rev 8529)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/page.py 2006-07-07 09:49:37 UTC
(rev 8530)
@@ -20,6 +20,9 @@
# - Suite 330, Boston, MA 02111-1307, USA.
#
# $Id$
+"""
+Implementation of a <page> tag in the UI layer.
+"""
import wx
@@ -34,28 +37,52 @@
class UIPage(_base.UIHelper):
"""
UI widget for the <page> tag.
+
+ @ivar page_index: zero-based index of the page within the form's
+ page-container (which is either a notebook or a panel).
+ @ivar container_sizer: all child widgets of the page will be added to this
+ wx.Sizer. For a positioned layout this is a wx.GridBagSizer and for
+ managed layouts it is a vertical wx.BoxSizer. This sizer is embedded
+ within the page panel using a border of 4 pixels.
+ @ivar _containerToolkitWidget: the page panel which gets the parent window
+ for all child widgets
"""
+ page_index = 0
+ container_sizer = None
+
# -------------------------------------------------------------------------
# Create a new page widget
# -------------------------------------------------------------------------
def _create_widget_(self, event, spacer):
+ """
+ Create the wx.Panel for the page and add it to the page-container of
+ the form. The spacer is ignored for page tags.
- self._pageIndex = len(self._uiForm.pages)
+ @param event: the creation-event instance carrying information like
+ container (parent-widget)
+ @param spacer: not used for pages
+
+ @returns: the wx.Panel instance which is the parent for all child
+ widgets of this page. This instance is already added to the
+ page-container of the form.
+ """
+
+ self.page_index = len(self._uiForm.pages)
+
parent = event.container
+ page_panel = wx.Panel(parent, -1)
+ page_sizer = wx.BoxSizer(wx.VERTICAL)
+ page_panel.SetSizer(page_sizer)
- self.page_panel = wx.Panel(parent, -1)
- self.page_sizer = wx.BoxSizer(wx.VERTICAL)
- self.page_panel.SetSizer(self.page_sizer)
-
if isinstance(parent, wx.Notebook):
title = "%s" % (self._gfObject.caption or self._gfObject.name)
- parent.AddPage(self.page_panel, title, False)
+ parent.AddPage(page_panel, title, False)
else:
- parent.GetSizer().Add(self.page_panel, 1, wx.EXPAND)
+ parent.GetSizer().Add(page_panel, 1, wx.EXPAND)
- self._uiForm.pages.append(self.page_panel)
+ self._uiForm.pages.append(page_panel)
# Add the container-sizer depending on the page-management
if self.managed:
@@ -69,10 +96,10 @@
self.container_sizer = wx.GridBagSizer(hgap, vgap)
self.container_sizer.SetEmptyCellSize((5, 10))
- self.page_sizer.Add(self.container_sizer, 1, wx.EXPAND)
+ page_sizer.Add(self.container_sizer, 1, wx.EXPAND | wx.ALL, 4)
- self._containerToolkitWidget = self.page_panel
- return self.page_panel
+ self._containerToolkitWidget = page_panel
+ return page_panel
# -------------------------------------------------------------------------
@@ -80,7 +107,13 @@
# -------------------------------------------------------------------------
def add_widgets(self, ui_widget, spacer):
+ """
+ Add a given UI widget to the page.
+ @param ui_widget: widget to add to the page
+ @param spacer: not used for pages
+ """
+
item = ui_widget.widget
if self.managed:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r8530 - trunk/gnue-forms/src/uidrivers/wx26/widgets,
johannes <=