File: macport_test.py

package info (click to toggle)
python-enable 4.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 7,220 kB
  • sloc: cpp: 57,417; python: 28,437; makefile: 314; sh: 43
file content (41 lines) | stat: -rwxr-xr-x 1,225 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env pythonw

import sys

if sys.platform == 'darwin':
    import wx

    from kiva.quartz import get_macport

    class SimpleWindow(wx.Frame):
        """
        Simple test of get_macport().
        """
        def __init__(self):
            wx.Frame.__init__(self, parent=None, id=-1, title="foo",
                               pos=(100,100),
                               size=(300,300))
            oldstyle = self.GetWindowStyle()
            oldstyle = oldstyle | wx.FULL_REPAINT_ON_RESIZE
            self.SetWindowStyle(oldstyle)
            self.Show(1)
            self.Bind(wx.EVT_PAINT, self.OnPaint)
            self.memdc = wx.MemoryDC()
            self.bitmap = wx.EmptyBitmap(200,200)
            self.memdc.SelectObject(self.bitmap)
            print "constructed frame"

        def OnPaint(self, evt):
            dc = wx.PaintDC(self)
            print "paintdc.this:", dc.this
            print "paintdc.macport:", get_macport(dc)
            print "memdc.this:", self.memdc.this
            print "memdc.macport:", get_macport(self.memdc)

    class MyApp(wx.App):
        def OnInit(self):
            w = SimpleWindow()
            return 1

    app = MyApp(False)
    app.MainLoop()