This commit is contained in:
Sam Parkinson 2016-01-03 16:45:10 +11:00
commit 37d3b63a90

View File

@ -15,21 +15,25 @@
# Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA. # Boston, MA 02111-1307, USA.
"""Notebook class '''
Notebook class
This class create a Gtk.Notebook() widget supporting This class creates a :class:`Gtk.Notebook` widget supporting
a close button in every tab when the 'can-close-tabs' gproperty a close button in every tab when the `can-close-tabs` gproperty
is enabled (True) is enabled (True).
STABLE. .. literalinclude:: ../examples/notebook.py
""" '''
from gi.repository import Gtk from gi.repository import Gtk
from gi.repository import GObject from gi.repository import GObject
class Notebook(Gtk.Notebook): class Notebook(Gtk.Notebook):
'''
Notebook class that creates a :class:`Gtk.Notebook`. It is possible to set
the `can-close-tabs` property from the constructor through Notebook(can_close_tabs=True)
'''
__gtype_name__ = 'SugarNotebook' __gtype_name__ = 'SugarNotebook'
__gproperties__ = { __gproperties__ = {
@ -52,23 +56,9 @@ class Notebook(Gtk.Notebook):
self.show() self.show()
def do_set_property(self, pspec, value): def do_set_property(self, pspec, value):
""" '''
Set notebook property Implementation method. Use notebook.props to set properties.
'''
Parameters
----------
pspec :
property for which the value will be set
Returns
-------
None
Raises
------
AssertionError
"""
if pspec.name == 'can-close-tabs': if pspec.name == 'can-close-tabs':
self._can_close_tabs = value self._can_close_tabs = value
else: else:
@ -114,21 +104,16 @@ class Notebook(Gtk.Notebook):
return event_box return event_box
def add_page(self, text_label, widget): def add_page(self, text_label, widget):
""" '''
Adds a page to the notebook. Adds a page to the notebook and sets the newly added page as current.
Returns True if the page is successfully added to the notebook.
If `can-close-tabs` is true, then a GtkEventBox is also created to close the tab.
Parameters Args:
---------- text_label (string): label of page to be added
text_label :
widget : widget (Gtk.Widget): widget to be used as contents of current page
'''
Returns
-------
Boolean
Returns TRUE if the page is successfully added to the notebook.
"""
# Add a new page to the notebook # Add a new page to the notebook
if self._can_close_tabs: if self._can_close_tabs:
eventbox = self._create_custom_tab(text_label, widget) eventbox = self._create_custom_tab(text_label, widget)