~glitter-team/glitter/trunk

« back to all changes in this revision

Viewing changes to glitter/tests/test3_hbox.py

  • Committer: Jan Jokela
  • Date: 2009-05-12 17:08:05 UTC
  • mto: (38.2.2 trunk)
  • mto: This revision was merged to the branch mainline in revision 25.
  • Revision ID: jan@jan-laptop-20090512170805-jw2qtp149hj5i4v6
(glitter/tests/*) Added and improved a bunch of tests; (glitter/data/themes/nublo/styles/label.json) Fixes in label widget style; (glitter/box.py) Layout code fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# !/usr/bin/python
 
2
# -*- coding: utf-8 -*-
 
3
 
 
4
# Glitter Toolkit
 
5
 
 
6
__authors__ = ["Jan Jokela <janjokela@gmail.com>"]
 
7
__licenses__ = ["LICENSE.LGPL"]
 
8
__description__ = "Tests for the horizontal box widget"
 
9
 
 
10
import os
 
11
import sys
 
12
 
 
13
# Change sys path to glitter path
 
14
glitter_path = os.path.split(sys.path[0])[0]
 
15
sys.path[0] = glitter_path
 
16
 
 
17
from window import Window
 
18
 
 
19
import gtk
 
20
import clutter
 
21
 
 
22
from window import Window
 
23
from box import HBox
 
24
from label import Label
 
25
from image import Image
 
26
from slider import Slider
 
27
 
 
28
class TestHBox(object):
 
29
    """ Tests for the horizontal box widget """
 
30
    
 
31
    def __init__(self):
 
32
        """ Initialize test """
 
33
        
 
34
        self.window = Window("Glitter tests")
 
35
        self.window.connect("destroy", self.destroy)
 
36
 
 
37
        self.stage = self.window.get_stage()
 
38
        self.stage.connect('notify::width', self.do_resize)
 
39
        self.stage.connect('notify::height', self.do_resize)
 
40
                
 
41
        self.hbox = HBox()
 
42
        self.hbox.spacing = 0.0
 
43
        self.stage.add(self.hbox)
 
44
        self.hbox._update_layout()
 
45
        
 
46
        self.label1 = Label("LABEL")
 
47
        self.hbox.pack(self.label1)
 
48
 
 
49
        self.slider = Slider()
 
50
        self.hbox.pack(self.slider)
 
51
        #self.slider.v_offset = 0.1
 
52
 
 
53
        self.label2 = Label("LABEL")
 
54
        self.hbox.pack(self.label2)
 
55
        
 
56
        self.window.show_all()
 
57
        gtk.main()
 
58
 
 
59
    def do_resize(self, stage, event):
 
60
        self.hbox._update_layout()
 
61
        #print self.label1.natural_width
 
62
        
 
63
    def destroy(self, widget, data=None):
 
64
        gtk.main_quit()
 
65
 
 
66
        
 
67
if __name__ == '__main__':
 
68
    TestHBox()