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

« back to all changes in this revision

Viewing changes to examples/enable/basic_draw.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:
2
2
This demonstrates the most basic drawing capabilities using Enable.  A new
3
3
component is created and added to a container.
4
4
"""
5
 
 
 
5
from __future__ import with_statement
6
6
 
7
7
from enthought.enable.example_support import DemoFrame, demo_main
8
8
from enthought.enable.api import Component, Container, Window
12
12
    resizable = ""
13
13
 
14
14
    def _draw_mainlayer(self, gc, view_bounds=None, mode="default"):
15
 
        gc.save_state()
16
 
        gc.set_fill_color((1.0, 0.0, 0.0, 1.0))
17
 
        dx, dy = self.bounds
18
 
        x, y = self.position
19
 
        gc.rect(x, y, dx, dy)
20
 
        gc.fill_path()
21
 
        gc.restore_state()
 
15
        with gc:
 
16
            gc.set_fill_color((1.0, 0.0, 0.0, 1.0))
 
17
            dx, dy = self.bounds
 
18
            x, y = self.position
 
19
            gc.rect(x, y, dx, dy)
 
20
            gc.fill_path()
22
21
 
23
22
class MyFrame(DemoFrame):
24
23
    def _create_window(self):