Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/pynxc/waxy/notebook.py
blob: 5ef5515d38c4ea2b26968cc0315fb572fc57c0de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# notebook.py

import waxyobject
import wx
import styles
import utils

class NoteBook(wx.Notebook, waxyobject.WaxyObject):

    __events__ = {
        'PageChanging': wx.EVT_NOTEBOOK_PAGE_CHANGING,
        'PageChanged': wx.EVT_NOTEBOOK_PAGE_CHANGED,
    }

    def __init__(self, parent, size=(640,480), **kwargs):

        style = 0
        style |= self._params(kwargs)
        style |= styles.window(kwargs)

        self.id = wx.NewId()
        wx.Notebook.__init__(self, parent, self.id, style=style, size=size)
        self.BindEvents()
        styles.properties(self, kwargs)

#    def AddPage(self, window, *args, **kwargs):
#        wx.Notebook.AddPage(self, window, *args, **kwargs)

    def GetCurrentPage(self):
        idx = self.GetSelection()
        if idx == -1:
            raise ValueError, "NoteBook currently has no pages"
        else:
            return self.GetPage(idx)

    #
    # style parameters

    _notebook_orientation = {
        "left": wx.NB_LEFT,
        "right": wx.NB_RIGHT,
        "bottom": wx.NB_BOTTOM,
        "top": 0,
    }

    def _params(self, kwargs):
        flags = 0
        flags |= styles.styledictstart('orientation', self._notebook_orientation, kwargs)
        flags |= styles.stylebool('fixedwidth', wx.NB_FIXEDWIDTH, kwargs)
        flags |= styles.stylebool('multiline', wx.NB_MULTILINE, kwargs)
        return flags