~ubuntu-tour/+junk/new-lang-system

« back to all changes in this revision

Viewing changes to old/tour.py

  • Committer: Anthony Stewart
  • Date: 2011-04-13 21:04:26 UTC
  • Revision ID: madnessred@gmail.com-20110413210426-x336oab2lh2h2b35
starting with new tour.py system

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
import glob
 
4
import os
 
5
import re
 
6
import locale
 
7
import gtk
 
8
import pygtk
 
9
from translate import Translate
 
10
 
 
11
 
 
12
class T:
 
13
        
 
14
        #When the class is loaded
 
15
        def __init__(self, tour, directory):
 
16
 
 
17
                #Folder
 
18
                self.folder = directory
 
19
                
 
20
                #Parent tour class
 
21
                self.tour = tour
 
22
                
 
23
                #Some empty values to fill later
 
24
                self.lang, self.info, self.parent, self.name, self.pos, self.default, self.id, self.t_pages = None, None, None, None, None, None, None, None
 
25
                
 
26
                #Run some stuff
 
27
                self.detect_lang()
 
28
                self.get_tour_info()
 
29
                self.num_pages()
 
30
        
 
31
        
 
32
        #Def detect lang
 
33
        def detect_lang(self):
 
34
                
 
35
                #Try using the language and country
 
36
                if os.path.isdir(os.path.join(self.folder, self.tour.user_lang)):
 
37
                        self.lang = self.tour.user_lang
 
38
                
 
39
                #Fallback on just the language
 
40
                elif os.path.isdir(os.path.join(self.folder, self.tour.user_lang.split('_')[0])):
 
41
                        self.lang = self.tour.user_lang.split('_')[0]
 
42
                
 
43
                #Fallback on default language
 
44
                else:
 
45
                        self.lang = self.tour.default_lang
 
46
                
 
47
                #And return
 
48
                return self.lang
 
49
        
 
50
        
 
51
        #Get the tour info
 
52
        def get_tour_info(self):
 
53
                
 
54
                #Try and open the file
 
55
                try:
 
56
                        #Load the info
 
57
                        info = open(os.path.join(self.folder, self.lang, 'tour.info'),'r').read()
 
58
                        
 
59
                        #Parse the info
 
60
                        self.info = {}
 
61
                        for line in info.split('\n'):
 
62
                                if ':' in line:
 
63
                                        l = line.split(':')
 
64
                                        self.info[l[0]] = l[1]
 
65
                        
 
66
                        #This is deliberately bad coding, so that if the tour is invalid, it will break the try and force the except to work.
 
67
                        self.parent = self.info['parent']
 
68
                        self.name = self.info['name']
 
69
                        try:
 
70
                                self.pos = int(self.info['position'])
 
71
                        except:
 
72
                                self.pos = 1000
 
73
                        try:
 
74
                                self.default = int(self.info['default'])#TODO: impliment features using this.
 
75
                        except:
 
76
                                self.default = 0
 
77
                        
 
78
                        #If it survived that it's valid.
 
79
                        self.is_valid = True
 
80
                
 
81
                #Tour is not valid.
 
82
                except:
 
83
                        self.tour.p(self.folder + " does not have a tour.info, folder rejected.")
 
84
                        self.is_valid = False
 
85
        
 
86
        
 
87
        #How many pages
 
88
        def num_pages(self):
 
89
                
 
90
                #Get all the pages
 
91
                pages = glob.glob(os.path.join(self.folder, self.lang, "*"))
 
92
                
 
93
                #Loop through the pages
 
94
                count = 0
 
95
                for p in pages:
 
96
                        if '_' in p.split('/')[-1]:
 
97
                                try:
 
98
                                        page = int(p.split('/')[-1].split('_')[0])
 
99
                                        if page > count:
 
100
                                                count = page
 
101
                                except:
 
102
                                        self.tour.p('Warning, ' + p.split('/')[-1] + ' contains an underscore, please rename.')
 
103
                
 
104
                #Set
 
105
                self.t_pages = count
 
106
                
 
107
                #How many then?
 
108
                return self.t_pages
 
109
        
 
110
        
 
111
        #Set id
 
112
        def set_id(self, n):
 
113
                self.id = n
 
114
 
 
115
 
 
116
class Tour:
 
117
 
 
118
        #Things to do when class is loaded
 
119
        def __init__(self, debug, html, colours):
 
120
                self.default_lang = 'en'
 
121
                self.user_lang = self.detect_lang()
 
122
                self.dialect = self.load_dialect()
 
123
                
 
124
                self.debug = debug
 
125
                self.html = html
 
126
                self.colours = colours
 
127
                self.parse_colours()
 
128
                
 
129
                self.folder=None
 
130
                self.page=0
 
131
                self.t_pages = 0
 
132
                
 
133
                self.progression_reqs = ''
 
134
                self.fullscreen = False
 
135
                
 
136
                self.get_sections()
 
137
                
 
138
                self.catagories = ['Hidden', 'Getting Started', 'Internet', 'Office', 'Multimedia', 'Continue Playing']
 
139
        
 
140
        #Debug print function
 
141
        def p(self, string):
 
142
                if self.debug:
 
143
                        print string
 
144
 
 
145
 
 
146
        #Get a list of tutorials available
 
147
        def get_sections(self):
 
148
                #Get all for folders
 
149
                if os.path.exists(os.path.join(os.getcwd(), "tours")):
 
150
                        dirs = glob.glob(os.path.join(os.getcwd(), "tours", "*"))
 
151
                elif os.path.exists(os.path.join("/", "usr","share","ubuntu-tour","tours")):
 
152
                        dirs = glob.glob(os.path.join("/", "usr","share","ubuntu-tour","tours","*"))
 
153
                elif os.path.exists(os.path.join(os.path.expanduser('~'), ".ubuntu-tour", "tours")):
 
154
                        dirs = glob.glob(os.path.join(os.path.expanduser('~'), ".ubuntu-tour", "tours", "*"))
 
155
                
 
156
                #Go through the folders
 
157
                self.tours = []
 
158
                n = 0
 
159
                for folder in dirs:
 
160
                        tour = T(self, folder)
 
161
                        if tour.is_valid:
 
162
                                tour.set_id(n)
 
163
                                self.tours.append(tour)
 
164
                                n+=1
 
165
                                
 
166
                #Return the list
 
167
                return self.tours
 
168
 
 
169
 
 
170
                def GetDefaultApp(Type):
 
171
                        if (Type.lower() == "browser"):
 
172
                                return os.popen("gconftool-2 -g /desktop/gnome/applications/browser/exec").read()[:-1]
 
173
                        elif (Type.lower() == "music" or Type.lower() == "media"):
 
174
                                return os.popen("gconftool-2 -g /desktop/gnome/applications/media/exec").read()[:-1]
 
175
                        else:
 
176
                                print "There's no support for looking up the apps for \"" + Type + "\""
 
177
                        return 0
 
178
 
 
179
        #Load page
 
180
        def load_page(self, tour_id, page=0, fullscreen=False, dark=False):
 
181
                #Debug
 
182
                self.p("Loading page")
 
183
                
 
184
                #Get the folder name and page number
 
185
                self.page = int(page)
 
186
                
 
187
                #Get the tour
 
188
                self.current_tour = self.tours[int(tour_id)]
 
189
                tour = self.current_tour
 
190
                
 
191
                #Try and read the page, if not, return a generic page
 
192
                try:
 
193
                        #Get the files
 
194
                        files = glob.glob(tour.folder + "/" + tour.lang + '/' + str(self.page) + "_*")
 
195
                        
 
196
                        #Find the html one
 
197
                        html = -1
 
198
                        for n in range(0, len(files)):
 
199
                                if files[n].split('.')[-1] == 'html':
 
200
                                        html = n
 
201
                        
 
202
                        #Are we using the html
 
203
                        if self.html:
 
204
                        
 
205
                                #Is there a html file?
 
206
                                if html >= 0:
 
207
                                        #Open the html file
 
208
                                        msg = open(files[html],'r')
 
209
                                        
 
210
                                        #Get the text
 
211
                                        text = msg.read()
 
212
                                
 
213
                                else:
 
214
                                        #Open the text file
 
215
                                        msg = open(files[html],'r')
 
216
                                        
 
217
                                        #Get the text
 
218
                                        text = msg.read()
 
219
                                        
 
220
                                        #Convert to html
 
221
                                        text = self.raw_to_html(text)
 
222
                        
 
223
                        #Otherwise we are using plain text
 
224
                        else:
 
225
                                #Usually the file will be 0
 
226
                                f = 0
 
227
                                convert = False
 
228
                                
 
229
                                #If however -1 is the html
 
230
                                if html == -1:
 
231
                                        #If there is another file
 
232
                                        if len(files) > 1:
 
233
                                                f = 1
 
234
                                        
 
235
                                        #Otherwise convert the html file to a text file
 
236
                                        else:
 
237
                                                convert = True
 
238
                                
 
239
                                #Open the file
 
240
                                msg=open(files[f],'r')
 
241
                        
 
242
                                #Get the text
 
243
                                text = msg.read()
 
244
                                
 
245
                                #Should we try and convert
 
246
                                if convert:
 
247
                                        text = self.html_to_raw(text)
 
248
                        
 
249
                        #Get the progression requirements
 
250
                        if '"Requirements" -->' in text:
 
251
                                reqs = text.split('"Requirements" -->', 2)[0]
 
252
                                if '<!-- "Requirements"' in reqs:
 
253
                                        reqs = reqs.split('<!-- "Requirements"', 2)[1]
 
254
                                        
 
255
                                        #Save these requirements
 
256
                                        self.progression_reqs = reqs
 
257
                                
 
258
                                else:
 
259
                                        self.progression_reqs = ''
 
260
 
 
261
                        else:
 
262
                                self.progression_reqs = ''
 
263
                                        
 
264
                        #Convert text to the local dialect
 
265
                        if not '_' in tour.lang:
 
266
                                self.p('using dialect')
 
267
                                text = self.convert_to_dialect(text)    
 
268
                        
 
269
                        #Set the text
 
270
                        if self.html:
 
271
                                self.gui.html.load_html_string(self.parse_html(text, dark), 'file://' + tour.folder + "/" + tour.lang + "/")
 
272
                        else:
 
273
                                self.gui.buffer.set_text(text)
 
274
                        
 
275
                        #Category homes
 
276
                        if tour.name == "Home":
 
277
                                if tour.parent == "Hidden":
 
278
                                        self.gui.addressbar.set_items(['Home'])
 
279
                                else:
 
280
                                        self.gui.addressbar.set_items(['Home', tour.parent])
 
281
                        
 
282
                        #General tours
 
283
                        elif tour.parent != "Hidden":
 
284
                                self.gui.addressbar.set_items(['Home', tour.parent, tour.name])
 
285
                                        
 
286
                        
 
287
                        #Close the file
 
288
                        msg.close()
 
289
                        
 
290
                except:
 
291
                        #If we can't load the file, we should give some generic text.
 
292
                        if self.html:
 
293
                                self.gui.html.load_html_string(self.parse_html("Nothing written yet.", dark), 'file://' + tour.folder + "/" + tour.lang + "/")
 
294
                        else:
 
295
                                self.gui.buffer.set_text("Nothing written yet.")
 
296
                
 
297
                finally:
 
298
                        
 
299
                        #Fullscreen?
 
300
                        if fullscreen:
 
301
                                if not self.fullscreen:
 
302
                                        #Hide everything
 
303
                                        self.gui.progressbar.hide()
 
304
                                        self.gui.buttonbox.hide()
 
305
                                        self.gui.menuscroll.hide()
 
306
                                        
 
307
                                        #Set to fullscreen
 
308
                                        self.fullscreen = True
 
309
                                        
 
310
                        else:
 
311
                                if self.fullscreen:
 
312
                                        #Show everything
 
313
                                        self.gui.progressbar.show()
 
314
                                        self.gui.buttonbox.show()
 
315
                                        self.gui.menuscroll.show()
 
316
                                        
 
317
                                        #Now longer fullscreen
 
318
                                        self.fullscreen = False
 
319
                
 
320
                #Now we have loaded the page, lets see about the position.
 
321
                if tour.t_pages == 0:
 
322
                        self.gui.next_button.set_sensitive(False)
 
323
                        self.gui.back_button.set_sensitive(False)
 
324
                elif self.page == 0:
 
325
                        self.gui.next_button.set_sensitive(True)
 
326
                        self.gui.back_button.set_sensitive(False)
 
327
                elif self.page == tour.t_pages:
 
328
                        self.gui.next_button.set_sensitive(False)
 
329
                        self.gui.back_button.set_sensitive(True)
 
330
                else:
 
331
                        self.gui.next_button.set_sensitive(True)
 
332
                        self.gui.back_button.set_sensitive(True)
 
333
                
 
334
                if self.page==1 and self.current_tour.name=="Managing software":
 
335
                        self.gui.next_button.hide()
 
336
                        self.gui.check_button.show()
 
337
                else:
 
338
                        self.gui.next_button.show()
 
339
                        self.gui.check_button.hide()
 
340
                
 
341
                #Progress
 
342
                if tour.t_pages > 0:
 
343
                        progress = float(self.page) / float(tour.t_pages)
 
344
                else:
 
345
                        progress = 1
 
346
                self.gui.progressbar.set_fraction(progress)
 
347
                
 
348
        
 
349
        
 
350
        #How many pages
 
351
        def num_pages(self, tutorial):
 
352
                #Get the path to the tutorial
 
353
                path = os.getcwd() + "/" + tutorial.replace(" ","-").lower() + "/"
 
354
                
 
355
                #Get all the pages
 
356
                pages = glob.glob(path + self.default_lang + "/*")
 
357
                
 
358
                #Loop through the pages
 
359
                count = 0
 
360
                for p in pages:
 
361
                        if '_' in p:
 
362
                                page = int(p.split('/')[-1].split('_')[0])
 
363
                                if page > count:
 
364
                                        count = page
 
365
                
 
366
                #How many then?
 
367
                return count
 
368
 
 
369
 
 
370
        #Detect the language that the user is using.
 
371
        def detect_lang(self):
 
372
                #Return the language 
 
373
                return locale.getdefaultlocale()[0]
 
374
        
 
375
        
 
376
        #Detect the local dialect
 
377
        def load_dialect(self):
 
378
                
 
379
                #Dialects, start off empty
 
380
                dialects = {}
 
381
                
 
382
                #For all the possible paths
 
383
                for path in [os.path.join("/", "usr","share","ubuntu-tour","dialects", self.user_lang), os.path.join(os.getcwd(), "dialects", self.user_lang)]:
 
384
                
 
385
                        #See if the dialect exists here
 
386
                        if os.path.exists(path):
 
387
                                #Read
 
388
                                f = open(path, 'r')
 
389
                                repls = f.read()
 
390
                                f.close()
 
391
                                
 
392
                                #Loop through replacements
 
393
                                for replace in repls.split('\n'):
 
394
                                        #Is it valid
 
395
                                        if '->' in replace:
 
396
                                                #Get the find and replace part
 
397
                                                r = replace.split('->', 1)
 
398
                                                
 
399
                                                #And clean then
 
400
                                                r[0] = r[0].strip()
 
401
                                                r[1] = r[1].strip()
 
402
                                                
 
403
                                                #And add to the dialect, provided there is something
 
404
                                                if len(r[0]) > 0:
 
405
                                                        dialects[r[0]] = r[1]
 
406
                
 
407
                #All done, return the dialects
 
408
                return dialects
 
409
        
 
410
        
 
411
        #Convert text into the dialect
 
412
        def convert_to_dialect(self, text):
 
413
                self.p(self.dialect)
 
414
                
 
415
                #Create a regex search for words which need changing
 
416
                regex = '((.|\\r|\\n)(' + '|'.join(self.dialect.keys()) + ')(.|\\r|\\n))'
 
417
                
 
418
                #Make a note of softkeys to remove
 
419
                softkey_remove = []
 
420
                softkey = '@'
 
421
                
 
422
                #Loop through all items of the original language
 
423
                for i in re.findall(regex,text):
 
424
                        #self.p(i)
 
425
                        #Try and convert it
 
426
                        try:
 
427
                                #If it is being used in the html, then we should not change it. (Protection against colo(u)r and cent[re/er])
 
428
                                if i[2] == 'color' and i[3] == '=':
 
429
                                        replace = i[0]
 
430
                                if i[2] == 'center' and i[1] == '=':
 
431
                                        replace = i[0]
 
432
                                
 
433
                                #If prepended by an softkey symbol, then we don't convert
 
434
                                elif i[1] == softkey:
 
435
                                        softkey_remove.append(i[2] + i[3])
 
436
                                        replace = i[0]
 
437
                                
 
438
                                #Otherwise, we convert
 
439
                                else:
 
440
                                        replace = i[1] + self.dialect[i[2]] + i[3]
 
441
                                
 
442
                                #Go ahead and replace
 
443
                                if i[0] != replace:
 
444
                                        self.p(i[0] + " to be replaced with " + replace)
 
445
                                        text = text.replace(i[0], replace)
 
446
                        
 
447
                        #If something goes wrong, complain quitly
 
448
                        except Exception, e:
 
449
                        
 
450
                                #Error!!
 
451
                                #TODO: this spams '' errors. Why?
 
452
                                #self.p(e)
 
453
                                pass
 
454
                
 
455
                #Now remove the softkeys
 
456
                for s in softkey_remove:
 
457
                        text = text.replace(softkey + s, s)
 
458
                
 
459
                #And return the new text
 
460
                return text
 
461
        
 
462
        #Convert a plain text file to html
 
463
        def raw_to_html(self, text):
 
464
                
 
465
                #Convert line breaks
 
466
                text = text.replace('\n', '<br />\n')
 
467
                
 
468
                #Return
 
469
                return text
 
470
        
 
471
        
 
472
        #Convert html to plain
 
473
        def html_to_raw(self, text):
 
474
                
 
475
                #Convert line breaks
 
476
                text = text.replace('\r', '')
 
477
                text = text.replace('\r\n', '\n')
 
478
                text = text.replace('<br />\n', '\n')
 
479
                text = text.replace('<br />', '\n')
 
480
                
 
481
                #Return
 
482
                return text
 
483
        
 
484
        
 
485
        #Parse html, to get a whole page
 
486
        def parse_html(self, html, dark=False):
 
487
        
 
488
                #For Lightbox Effect: Search for screenshot tag and replace with img tag
 
489
                pattern                 = r'''<screenshot([^"]+)src="([^"]+)"([^>]+)'''
 
490
                pattern_string  = re.compile(pattern)
 
491
                replace_string  = r'''<a id="lightbox" href="\2"><img src="\2" \1\3></a'''
 
492
                if re.search(pattern_string,html):
 
493
                        html = re.sub(pattern_string,replace_string,html)
 
494
 
 
495
                #Get the html opening
 
496
                f = open(os.getcwd() + "/html/start.html",'r')
 
497
                start = f.read()
 
498
                f.close()
 
499
                
 
500
                #Get the html closing
 
501
                f = open(os.getcwd() + "/html/end.html",'r')
 
502
                end = f.read()
 
503
                f.close()
 
504
                
 
505
                #Get full html
 
506
                html = start + html + end
 
507
                
 
508
                #Parse colour
 
509
                if dark:
 
510
                        html = html.replace('{{BACK-COLOUR}}', self.colours['background_t'][0])
 
511
                        html = html.replace('{{TEXT-COLOUR}}', self.colours['foreground_t'][0])
 
512
                else:
 
513
                        html = html.replace('{{BACK-COLOUR}}', self.colours['background'][0])
 
514
                        html = html.replace('{{TEXT-COLOUR}}', self.colours['foreground'][0])
 
515
                
 
516
                #Return the combined html
 
517
                return html
 
518
        
 
519
        
 
520
        #Parse the colours
 
521
        def parse_colours(self):
 
522
                #Loop through them
 
523
                for k in self.colours.keys():
 
524
                        #Get 64k colour hex
 
525
                        hex = self.colours[k].to_string()
 
526
                        
 
527
                        #Convert to 256 colour hex
 
528
                        if len(hex) == 13:
 
529
                                hex = hex[0:3] + hex[5:7] + hex[9:11]
 
530
                        
 
531
                        #Set the colour
 
532
                        self.colours[k] = (hex, self.colours[k])
 
533
        
 
534
        
 
535
        #Make the menu
 
536
        def make_menu(self, gui):
 
537
        
 
538
                #Load the gui
 
539
                self.gui = gui
 
540
                
 
541
                #Create a treeview
 
542
                self.tree_menu = gtk.TreeView()
 
543
                
 
544
                #Create a column
 
545
                self.tree_sections = gtk.TreeViewColumn("Chapters", gtk.CellRendererText(), text=0)
 
546
                self.tree_menu.append_column(self.tree_sections)
 
547
                
 
548
                self.tree_ids = gtk.TreeViewColumn("ID", gtk.CellRendererText(), text=1)
 
549
                self.tree_ids.set_visible(False)
 
550
                self.tree_menu.append_column(self.tree_ids)
 
551
                
 
552
                #Create the store
 
553
                self.update_menu()
 
554
                        
 
555
                #Add a callback
 
556
                self.tree_menu.get_selection().connect("changed", self.row_selected)
 
557
                self.tree_menu.set_property("headers-visible", False)
 
558
                
 
559
                self.tree_menu.modify_base(gtk.STATE_NORMAL, self.colours['background'][1])
 
560
                self.tree_menu.modify_text(gtk.STATE_NORMAL, self.colours['foreground'][1])
 
561
                self.tree_menu.expand_all()
 
562
                
 
563
                #Append, if it's not already there
 
564
                child = self.gui.menuscroll.get_child()
 
565
                if child == None:
 
566
                        self.gui.menuscroll.add(self.tree_menu)
 
567
                #self.gui.hbox.pack_start(self.tree_menu, False, True)
 
568
        
 
569
        
 
570
        #Make the menu
 
571
        def update_menu(self, rescan=True):
 
572
                
 
573
                #Get the tours
 
574
                if rescan:
 
575
                        self.get_sections()
 
576
                
 
577
                #Create the store
 
578
                self.tree_store = gtk.TreeStore(str, int)
 
579
                
 
580
                #See how many times each catagory is used
 
581
                cat_count = {}
 
582
                for cat in self.catagories:
 
583
                        cat_count[cat] = 0
 
584
                for t in self.tours:
 
585
                        cat_count[t.parent] = 1
 
586
                
 
587
                #Catagories
 
588
                self.parents = {}
 
589
                self.tree_catagories = []
 
590
                self.children = {}
 
591
                for cat in self.catagories:
 
592
                        if cat_count[cat] > 0:
 
593
                                #Create the parent
 
594
                                self.children[cat] = []
 
595
                                self.tree_catagories.append(cat)
 
596
                                
 
597
                                #If it's not hidden, add it.
 
598
                                if cat.lower() != 'hidden':
 
599
                                        self.parents[cat] = self.tree_store.append(None, [cat, -1])
 
600
                
 
601
                #Sort the tours
 
602
                self.sorted_tours = sorted(self.tours, cmp=lambda x,y: self.TourCmp(x, y))
 
603
                
 
604
                #Loop through the tours
 
605
                for t in self.sorted_tours:
 
606
                        #Debug
 
607
                        self.p(t.name)
 
608
                        self.p(t.parent)
 
609
                        
 
610
                        #Add the parent if its not common
 
611
                        if not t.parent in self.children.keys():
 
612
                                if t.parent.lower() != 'hidden':
 
613
                                        self.parents[t.parent] = self.tree_store.append(None, [t.parent, -1])
 
614
                                self.tree_catagories.append(t.parent)
 
615
                                self.children[t.parent] = []
 
616
                
 
617
                        #Add to tree store if its not a hidden tour
 
618
                        if t.parent.lower() != 'hidden':
 
619
                                self.tree_store.append(self.parents[t.parent], [t.name, t.id])
 
620
                        
 
621
                        #Add to list of parents children
 
622
                        self.children[t.parent].append(t.id)
 
623
                        
 
624
                #Set the model
 
625
                self.tree_menu.set_model(model=self.tree_store)
 
626
                
 
627
                #Expand
 
628
                self.tree_menu.expand_all()
 
629
        
 
630
        
 
631
        #A function to sort tours
 
632
        def TourCmp(self, a, b):
 
633
                #print a,b
 
634
                if a.pos < b.pos:
 
635
                        return -1
 
636
                elif a.pos > b.pos:
 
637
                        return 1
 
638
                else:
 
639
                        return 0
 
640
        
 
641
        
 
642
        #Row selected callback
 
643
        def row_selected(self, selection, user_param=None):
 
644
                if len(selection.get_selected_rows()[1]) > 0:
 
645
                        #Get the position
 
646
                        pos = selection.get_selected_rows()[1][0]
 
647
                        
 
648
                        #Scroll to the selected value
 
649
                        self.tree_menu.scroll_to_cell(pos)
 
650
                        
 
651
                        #What is the selected value
 
652
                        if len(pos) == 2:
 
653
                                try:
 
654
                                        self.load_page(self.children[self.tree_catagories[pos[0]+1]][pos[1]],0)
 
655
                                except:
 
656
                                        self.p('Could not load ' + pos)