initial example, not working, "draw" invalid signal
This commit is contained in:
commit
f50d058304
38
example.py
Executable file
38
example.py
Executable file
@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env pythonw
|
||||
|
||||
import os
|
||||
import sys
|
||||
import gtk
|
||||
import pango
|
||||
import pangocairo
|
||||
|
||||
FONT = "Sans Bold 27"
|
||||
|
||||
class MyWidget(gtk.DrawingArea):
|
||||
def __init__(self):
|
||||
gtk.DrawingArea.__init__(self)
|
||||
self.set_size_request(200, 200)
|
||||
|
||||
def do_draw_cb(self, widget, cr):
|
||||
layout = pangocairo.create_layout(cr)
|
||||
layout.set_text("Text", -1)
|
||||
desc = pango.font_description_from_string(FONT)
|
||||
layout.set_font_description(desc)
|
||||
pangocairo.show_layout(cr, layout)
|
||||
|
||||
def destroy(window):
|
||||
gtk.main_quit()
|
||||
|
||||
def main():
|
||||
window = gtk.Window()
|
||||
window.set_title("Custom pygtk widget hello world")
|
||||
widget = MyWidget()
|
||||
window.add(widget)
|
||||
widget.connect('draw', widget.do_draw_cb)
|
||||
window.connect_after('destroy', destroy)
|
||||
window.show_all()
|
||||
gtk.main()
|
||||
return 0
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
Loading…
x
Reference in New Issue
Block a user