~ubuntu-branches/ubuntu/raring/wxwidgets2.8/raring

« back to all changes in this revision

Viewing changes to wxPython/demo/Cairo.py

  • Committer: Package Import Robot
  • Author(s): Stéphane Graber
  • Date: 2012-01-07 13:59:25 UTC
  • mfrom: (1.1.9) (5.1.10 sid)
  • Revision ID: package-import@ubuntu.com-20120107135925-2601miy9ullcon9j
Tags: 2.8.12.1-6ubuntu1
* Resync from Debian, changes that were kept:
  - debian/rules: re-enable mediactrl. This allows libwx_gtk2u_media-2.8 to be
    built, as this is required by some applications (LP: #632984)
  - debian/control: Build-dep on libxt-dev for mediactrl.
  - Patches
    + fix-bashism-in-example
* Add conflict on python-wxgtk2.8 (<< 2.8.12.1-6ubuntu1~) to python-wxversion
  to guarantee upgrade ordering when moving from pycentral to dh_python2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
98
98
 
99
99
        # Drawing a bitmap.  Note that we can easily load a PNG file
100
100
        # into a surface, but I wanted to show how to convert from a
101
 
        # wx.Bitmap here instead.
 
101
        # wx.Bitmap here instead.  This is how to do it using just cairo:
102
102
        #img = cairo.ImageSurface.create_from_png(opj('bitmaps/toucan.png'))
 
103
 
 
104
        # And this is how to convert a wx.Btmap to a cairo image
 
105
        # surface.  NOTE: currently on Mac there appears to be a
 
106
        # problem using conversions of some types of images.  They
 
107
        # show up totally transparent when used. The conversion itself
 
108
        # appears to be working okay, because converting back to
 
109
        # wx.Bitmap or writing the image surface to a file produces
 
110
        # the expected result.  The other platforms are okay.
103
111
        bmp = wx.Bitmap(opj('bitmaps/toucan.png'))
104
112
        #bmp = wx.Bitmap(opj('bitmaps/splash.png'))
105
 
        #print 'depth:', bmp.GetDepth()
106
 
        #print 'alpha:', bmp.HasAlpha()
107
113
        img = wx.lib.wxcairo.ImageSurfaceFromBitmap(bmp)
 
114
        
108
115
        ctx.set_source_surface(img, 70, 230)
109
116
        ctx.paint()
110
117
 
111
 
        #bmp = wx.lib.wxcairo.BitmapFromImageSurface(img)
112
 
        #dc.DrawBitmap(bmp, 280, 300)
 
118
        # this is how to convert an image surface to a wx.Bitmap
 
119
        bmp2 = wx.lib.wxcairo.BitmapFromImageSurface(img)
 
120
        dc.DrawBitmap(bmp2, 280, 300)
113
121
        
114
122
        
115
123
    def warpPath(self, ctx, tw, th, dx, dy):
142
150
#----------------------------------------------------------------------
143
151
 
144
152
if not haveCairo:
145
 
    from Main import MessagePanel
 
153
    from wx.lib.msgpanel import MessagePanel
146
154
    def runTest(frame, nb, log):
147
155
        win = MessagePanel(nb, 'This demo requires the Pycairo package,\n'
148
156
                           'or there is some other unmet dependency.',