Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/atoidejouer/ui/screen/help.py
blob: b592aff8e45eb3927b5dcf5500c6b702c72a9a72 (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
# 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
        self.__v_box = gtk.VBox(spacing=2)
        self.__v_box.show()
        self.add_with_viewport(self.__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)
                    c_widget = gtk.Image()
                    c_widget.set_from_file(i_path)
                    c_widget.show()
                self.__v_box.pack_start(c_widget, expand=False, fill=True)

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