Exemplo n.º 1
0
    def draw(self, dc):
        print 'rect:', dc.rect
        dc.moveto(0, 0)
        dc.lineto(100, 100)
        print dc.currentpoint()
        dc.stroke()
        dc.selectfont("Nimbus Sans L", 0, 0)
        dc.setfontsize(12)
        dc.moveto(50, 10)
        dc.showtext(u"\u00a1hello, world!")
        print dc.textextents(u"\u00a1hello, world!")


win = x3.window(0, "foo", my_callback)

m = x3.menu(win, "bar")

x3.menuitem(m, "baz", "bazz", "<ctrl>b")
x3.menusep(m)
x3.menuitem(m, "Quit", "quit", "<ctrl>q")

v = x3.vbox(win, 0, 12)

v.setpacking(True, False, 0)
x3.button(v, "butt", u"\u00a1hello!")
x3.edittext(v, "quux")
v.setpacking(True, True, 0)
x3.view(v, 263, my_viewclient())

x3.main()
Exemplo n.º 2
0
        print buttons, mods, x, y
    def draw(self, dc):
        print 'rect:', dc.rect
        dc.moveto(0, 0)
        dc.lineto(100, 100)
        print dc.currentpoint()
        dc.stroke()
        dc.selectfont("Nimbus Sans L", 0, 0)
        dc.setfontsize(12)
        dc.moveto(50, 10)
        dc.showtext(u"\u00a1hello, world!")
        print dc.textextents(u"\u00a1hello, world!")

win = x3.window(0, "foo", my_callback)

m = x3.menu(win, "bar")

x3.menuitem(m, "baz", "bazz", "<ctrl>b")
x3.menusep(m)
x3.menuitem(m, "Quit", "quit", "<ctrl>q")

v = x3.vbox(win, 0, 12)

v.setpacking(True, False, 0)
x3.button(v, "butt", u"\u00a1hello!")
x3.edittext(v, "quux")
v.setpacking(True, True, 0)
x3.view(v, 263, my_viewclient())

x3.main()
Exemplo n.º 3
0
        dc.curveto(coords[1][0], coords[1][1], coords[2][0], coords[2][1],
                   coords[3][0], coords[3][1])
        dc.stroke()
        dc.setrgba(0, 0.5, 0, 0.5)
        dc.moveto(coords[0][0], coords[0][1])
        dc.lineto(coords[1][0], coords[1][1])
        dc.stroke()
        dc.moveto(coords[2][0], coords[2][1])
        dc.lineto(coords[3][0], coords[3][1])
        dc.stroke()
        dc.setrgba(1, 0, 0, .5)
        for x, y in coords:
            dc.rectangle(x - 3, y - 3, 6, 6)
            dc.fill()
    def mouse(self, button, mods, x, y):
        if button == 1:
            for i in range(4):
                if hypot(x - self.coords[i][0], y - self.coords[i][1]) < 4:
                    self.hit = i
        elif button == -1:
            self.hit = None
        elif self.hit != None:
            self.coords[self.hit] = (x, y)
            self.view.dirty()

win = x3.window(0, "beztest", my_callback)

x3.view(win, 259, bez())

x3.main()
Exemplo n.º 4
0
        dc.stroke()
        dc.setrgba(0, 0.5, 0, 0.5)
        dc.moveto(coords[0][0], coords[0][1])
        dc.lineto(coords[1][0], coords[1][1])
        dc.stroke()
        dc.moveto(coords[2][0], coords[2][1])
        dc.lineto(coords[3][0], coords[3][1])
        dc.stroke()
        dc.setrgba(1, 0, 0, .5)
        for x, y in coords:
            dc.rectangle(x - 3, y - 3, 6, 6)
            dc.fill()

    def mouse(self, button, mods, x, y):
        if button == 1:
            for i in range(4):
                if hypot(x - self.coords[i][0], y - self.coords[i][1]) < 4:
                    self.hit = i
        elif button == -1:
            self.hit = None
        elif self.hit != None:
            self.coords[self.hit] = (x, y)
            self.view.dirty()


win = x3.window(0, "beztest", my_callback)

x3.view(win, 259, bez())

x3.main()