CustomItem not displaying on mouse click
- From: Shashank Bandari <mail shashank-bandari in>
- To: <goocanvas-list gnome org>
- Subject: CustomItem not displaying on mouse click
- Date: Wed, 22 Dec 2010 09:01:21 +0000
Hi,
I am trying to use a custom item to draw objects onto the canvas on a
mouse click. The item is not displayed on mouse click.
However if I minimise the window and then maximise, the item is
displayed. The code is shown below.
#!/usr/bin/env python
import sys
import pygtk
import string
pygtk.require('2.0')
import gtk
import gobject
import gtk.glade
import goocanvas
import cairo
import os.path
from Objects import GeneratorItem
class MainWindow:
def __init__(self):
self.edit_state=0
self.builder = gtk.Builder()
self.builder.add_from_file("sample_glade.glade")
self.window=self.builder.get_object("sample_window")
self.canvas_window=self.builder.get_object("main_canvas") #Scrolled
Window
self.canvas=goocanvas.Canvas()
self.canvas_window.add(self.canvas)
self.window.show_all()
self.canvas.connect("button_release_event",self.canvas_mouse_up,None)
def canvas_mouse_up(self,item,event,cr):
root = self.canvas.get_root_item()
item = GeneratorItem.GeneratorItem(x=100, y=100, width=100,
height=100,line_width=20)
root.add_child(item)
self.canvas.request_update()
self.canvas_window.show_all()
window=MainWindow()
gtk.main()
GeneratorItem is the sample CustomRectItem from the demos directory.
Kindly suggest the points I am missing in the code.
Regards,
Shashank Bandari
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]