41 lines
947 B
Python
Executable File
41 lines
947 B
Python
Executable File
#!/usr/bin/env pythonw
|
|
|
|
import os
|
|
import sys
|
|
import gtk
|
|
import pango
|
|
import cairo
|
|
import pangocairo
|
|
|
|
class MyWidget(gtk.DrawingArea):
|
|
def __init__(self):
|
|
gtk.DrawingArea.__init__(self)
|
|
self.set_size_request(200, 200)
|
|
self.connect('expose-event', self.expose)
|
|
|
|
def expose(self, widget, event):
|
|
cr = widget.window.cairo_create()
|
|
cr.select_font_face("Courier",
|
|
cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
|
|
cr.set_font_size(20)
|
|
cr.set_source_rgb(1.0, 0.3, 0.0)
|
|
cr.move_to(0, 15)
|
|
cr.text_path("Hello")
|
|
cr.stroke()
|
|
|
|
def destroy(window):
|
|
gtk.main_quit()
|
|
|
|
def main():
|
|
window = gtk.Window()
|
|
window.set_title("Custom pygtk widget hello world")
|
|
widget = MyWidget()
|
|
window.add(widget)
|
|
window.connect_after('destroy', destroy)
|
|
window.show_all()
|
|
gtk.main()
|
|
return 0
|
|
|
|
if __name__ == '__main__':
|
|
sys.exit(main())
|