add multiple colors and moving layout
This commit is contained in:
parent
a28159215a
commit
23ddad074f
21
example.py
21
example.py
@ -10,18 +10,31 @@ import pangocairo
|
|||||||
class MyWidget(gtk.DrawingArea):
|
class MyWidget(gtk.DrawingArea):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
gtk.DrawingArea.__init__(self)
|
gtk.DrawingArea.__init__(self)
|
||||||
self.set_size_request(200, 200)
|
self.set_size_request(300, 250)
|
||||||
self.connect('expose-event', self.expose)
|
self.connect('expose-event', self.expose)
|
||||||
|
|
||||||
def expose(self, widget, event):
|
def expose(self, widget, event):
|
||||||
cr = widget.window.cairo_create()
|
cr = widget.window.cairo_create()
|
||||||
layout = cr.create_layout()
|
layout = cr.create_layout()
|
||||||
layout.set_text("Hello")
|
|
||||||
desc = pango.FontDescription("Mono Bold 27")
|
desc = pango.FontDescription("Mono Bold 27")
|
||||||
layout.set_font_description(desc)
|
layout.set_font_description(desc)
|
||||||
cr.move_to(10, 150)
|
|
||||||
cr.update_layout(layout)
|
|
||||||
cr.set_source_rgb(1.0, 0.4, 0.0)
|
cr.set_source_rgb(1.0, 0.4, 0.0)
|
||||||
|
cr.move_to(10, 10)
|
||||||
|
layout.set_text("Hello: gjpqy")
|
||||||
|
cr.update_layout(layout)
|
||||||
|
cr.show_layout(layout)
|
||||||
|
|
||||||
|
cr.set_source_rgb(0.0, 0.0, 0.0)
|
||||||
|
cr.move_to(10, 50)
|
||||||
|
layout.set_text("BLACK: Q")
|
||||||
|
cr.update_layout(layout)
|
||||||
|
cr.show_layout(layout)
|
||||||
|
|
||||||
|
cr.set_source_rgb(0.0, 0.0, 1.0)
|
||||||
|
cr.move_to(10, 90)
|
||||||
|
layout.set_text("multiline\nlayout")
|
||||||
|
cr.update_layout(layout)
|
||||||
cr.show_layout(layout)
|
cr.show_layout(layout)
|
||||||
|
|
||||||
def destroy(window):
|
def destroy(window):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user