~ubuntu-branches/ubuntu/trusty/python-enable/trusty

« back to all changes in this revision

Viewing changes to examples/enable/stacked_container_demo.py

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2011-04-05 21:54:28 UTC
  • mfrom: (1.1.5 upstream)
  • mto: (8.2.1 sid)
  • mto: This revision was merged to the branch mainline in revision 10.
  • Revision ID: james.westby@ubuntu.com-20110405215428-1x2wtubz3ok2kxaq
Tags: upstream-3.4.1
ImportĀ upstreamĀ versionĀ 3.4.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
 
 
3
from enthought.enable.example_support import DemoFrame, demo_main
 
4
 
 
5
from enthought.enable.api import Container, Window, TextField
 
6
from enthought.enable.stacked_container import VStackedContainer, HStackedContainer
 
7
from enthought.enable.overlay_container import OverlayContainer
 
8
 
 
9
class MyFrame(DemoFrame):
 
10
    def _create_window(self):
 
11
 
 
12
        stack = VStackedContainer(position=[0,0], bounds=[500,500],
 
13
            halign='center', valign='center', #border_visible=True,
 
14
            fit_components='hv', auto_size=True, stack_order='top_to_bottom',
 
15
            bgcolor='red')
 
16
 
 
17
        strings = ["apple", "banana", "cherry", "durian",
 
18
                         "eggfruit", "fig", "grape", "honeydew"]
 
19
 
 
20
        for i, s in enumerate(strings):
 
21
            label = TextField(text=s, resizable='', bounds=[100+i*10,20],
 
22
                bgcolor='red', #border_visible=True,
 
23
                text_offset=1)
 
24
            number = TextField(text=str(i+1), resizable='',
 
25
                bgcolor='blue', #border_visible=True,
 
26
                text_offset=1, can_edit=False, bounds=[20,20])
 
27
            row = HStackedContainer(fit_components='hv', auto_size=True,
 
28
                resizable='',
 
29
                valign='top', border_visible=True)
 
30
            row.add(number)
 
31
            row.add(label)
 
32
            stack.add(row)
 
33
 
 
34
        #print stack.components
 
35
        container = Container(position=[20,20], bounds=[500,500])
 
36
        container.add(stack)
 
37
        container2 = Container(bounds=[600,600])
 
38
        container2.add(container)
 
39
        return Window(self, -1, component=container2)
 
40
 
 
41
if __name__ == "__main__":
 
42
    demo_main(MyFrame, size=[600,600])
 
43