python - Drawing my own object on a layout: problem with subclassing gtk.drawable -
i want draw own object on layout, i'm trying subclass gdk.drawable,
class link(gtk.gdk.drawable): def __init__(self,comp1,comp2,layout): super(link, self).__init__() self.x1=comp1.xpos self.y1=comp1.ypos self.x2=comp2.xpos self.y2=comp2.ypos self.layout=layout error:
cannot create instance of abstract (non-instantiable) type `gdkdrawable'
i can without subclassing drawable using layout.bin_window.draw_line() in method drawlink() of link object, i'm not able create custom graphic context gdk.gc each object , have use layout.get_style() same links!
def drawlink(self): gc = self.layout.get_style().fg_gc[gtk.state_normal] gc.line_style=gtk.gdk.line_on_off_dash gc.line_width=6 self.layout.bin_window.draw_line(gc,self.x1, self.y1, self.x2, self.y2) this reason want subclass drawable. if can use custom gc without subclassing drawable or(window, pixmap) great.
thanks
any alternative?
if understand correctly, want not subclassing gtk.gdk.drawable populating gtk.drawingarea widget own content. description of widget is:
the
gtk.drawingareawidget used creating custom user interface elements. it's blank widget containinggtk.gdk.windowcan draw on.
Comments
Post a Comment