Example
Example
Code:
#!/usr/bin/env Python3 # Created by Xiaosanyu on 16/7/6 # section 147 TITLE = ' donut ' DESCRIPTION = "" "In this example we Create a complex shape by rotating a bunch of ellipses "" "The Import GI gi.require_version (" GTK "," 3.0 ") from Gi.repository
Import GTK Import Math class Pyapp (Gtk.window): def __init__ (self): Super (Pyapp, self). __init__ () Self.set_title ("Donut") Self.set_size_request Self.connect ("Destroy", Gtk.main_quit) da REA = Gtk.drawingarea () darea.connect ("Draw", Self.draw) Self.add (Darea) self.show_all () @sta
Ticmethod def draw (Drawingarea, CR): Cr.set_line_width (0.5) w = drawingarea.get_allocated_width ()
h = drawingarea.get_allocated_height () cr.translate (W/2, H/2) cr.arc (0, 0, 0, 2 * math.pi) Cr.stroke () for I in Range (): Cr.save () cr.rotate (i * math.pi/36) CR
. scale (0.3, 1) Cr.arc (0, 0, 0, 2 * math.pi) Cr.restore () Cr.stroke () def main (): Pyapp () gtk.ma
In () if __name__ = = "__main__": Main ()
Code download address: http://download.csdn.net/detail/a87b01c14/9594728