Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/atoidejouer/ui/screen/help.py
blob: 2ea95c44621f6f0dfab85c5519e9e2cb81d8896a (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
52
53
54
55
# python import
import logging

# gtk import
import gtk

# html simple viewer
from lib.htmltextview import HtmlTextView

# atoidejouer import
from atoidejouer.tools import storage

# get application logger
logger = logging.getLogger('atoidejouer')


class ScreenHelp(gtk.ScrolledWindow):

    def __init__(self, activity_):
        gtk.ScrolledWindow.__init__(self)
        self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        # init main box
        __v_box = gtk.VBox()
        __v_box.show()
        self.add_with_viewport(__v_box)
        # keep activity
        self.activity = activity_
        # load html content
        with open(storage.get_html_path('help')) as f:
            for content in f.read().split('----'):
                content = content.strip()
                c_widget = None
                if '\n' in content:
                    c_widget = HtmlTextView()
                    c_widget.display_html(content)
                    c_widget.show()
                else:
                    i_path = storage.get_html_img_path(content)
                    logger.debug(i_path)
                    # an image
                    im = gtk.Image()
                    im.set_from_file(i_path)
                    im.show()
                    # put in an event box for color
                    c_widget = gtk.EventBox()
                    c_widget.add(im)
                    c_widget.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('white'))
                    c_widget.show()
                __v_box.pack_start(c_widget, expand=False, fill=True)

    def _show(self):
        # show all
        self.show()
        # update activity
        self.activity.set_canvas(self)