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

« back to all changes in this revision

Viewing changes to examples/enable/container_demo.py

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2010-10-17 23:10:41 UTC
  • mto: (1.2.1 upstream) (8.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 10.
  • Revision ID: james.westby@ubuntu.com-20101017231041-rziowhgl7zhxra2i
Tags: upstream-3.3.2
ImportĀ upstreamĀ versionĀ 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from __future__ import with_statement
1
2
 
2
3
import wx
3
4
from enthought.enable.wx_backend.api import Window
24
25
            self.bounds = [100,100]
25
26
 
26
27
    def _draw_plot(self, gc, view_bounds=None, mode="normal"):
27
 
        gc.save_state()
28
 
        gc.set_fill_color(self.color_)
29
 
        gc.rect(self.x, self.y, self.width, self.height)
30
 
        gc.fill_path()
31
 
        gc.restore_state()
 
28
        with gc:
 
29
            gc.set_fill_color(self.color_)
 
30
            gc.rect(self.x, self.y, self.width, self.height)
 
31
            gc.fill_path()
32
32
 
33
33
    def drag_start(self, event):
34
34
        self._offset = (event.x - self.x, event.y - self.y)
53
53
        self.text = text
54
54
 
55
55
    def overlay(self, component, gc, view_bounds=None, mode="normal"):
56
 
        gc.save_state()
57
 
        try:
 
56
        with gc:
58
57
            gc.set_font(self.font)
59
58
            twidth, theight = gc.get_text_extent(self.text)[2:]
60
59
            tx = component.x + (component.width - twidth)/2.0
68
67
 
69
68
            gc.set_text_position(tx, ty)
70
69
            gc.show_text(self.text)
71
 
        finally:
72
 
            gc.restore_state()
73
 
 
74
70
 
75
71
 
76
72
rect1 = Region("orchid", position=[50,50])