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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# !/usr/bin/python
# -*- coding: utf-8 -*-
# Glitter Toolkit
__authors__ = ["Jan Jokela <janjokela@gmail.com>"]
__licenses__ = ["LICENSE.LGPL"]
__description__ = "Tests for the list widget"
import os
import sys
# Change sys path to glitter path
glitter_path = os.path.split(sys.path[0])[0]
sys.path[0] = glitter_path
from window import Window
import gtk
from scroll_area import ScrollArea
from list import List
from image import Image
from label import Label
from slider import Slider
class TestList(object):
""" Tests for the list widget """
def __init__(self):
""" Initialize test """
self.window = Window("Glitter tests")
self.window.connect("destroy", self.destroy)
self.stage = self.window.get_stage()
self.stage.connect('notify::width', self.do_resize)
self.stage.connect('notify::height', self.do_resize)
self.scroll_area = ScrollArea(2.0)
self.stage.add(self.scroll_area)
# Lets override the default size and pos
self.scroll_area.natural_x = 0.1
self.scroll_area.natural_y = 0.1
self.scroll_area.natural_width = 0.8
self.scroll_area.natural_height = 0.8
# Explicitly updating the layout is only necessary because we are
# adding directly to the stage instead of an aspect frame
self.scroll_area._update_layout()
self.list = List()
self.scroll_area.pack(self.list)
self.list.natural_x = 0.1
self.list.natural_y = 0.1
self.list.natural_width = 0.8
self.list.natural_height = 0.8
self.list._update_layout()
self._os_lusiadas_canto_1 = [
" OS LVSIADAS",
" Canto Primeiro",
" ",
" As armas, & os barões aβinalados,",
" Que da Occidental praya Luʃitana,",
" Por mares nunca de antes navegados,",
" Paʃʃaram ainda alem da Taprobana,",
" Em perigos, & guerras esforçados,",
" Mais do que prometia a força humana,",
" E entre gente remota edificarão",
" Novo Reino, que tanto sublimarão;"
]
self.image = []
for i in xrange(11):
self.image.append(Label(self._os_lusiadas_canto_1[i]))
self.list.append(self.image[i])
self.window.show_all()
gtk.main()
def do_resize(self, stage, event):
self.scroll_area._update_layout()
self.list._update_layout()
for i in xrange(10):
self.image[i]._update_layout()
def destroy(self, widget, data=None):
gtk.main_quit()
if __name__ == '__main__':
TestList()
|