Show
Ignore:
Timestamp:
06/12/07 17:51:40 (6 years ago)
Author:
ggpolo
Message:

more one test added to new sample

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branch/ggpolo/umitInventory/new-sample/tests/_test4.py

    r800 r801  
    4848gobject.type_register(test4A) 
    4949 
     50 
     51class test4B(gtk.Widget): 
     52    def __init__(self): 
     53        gtk.Widget.__init__(self) 
     54        self.x = 0 
     55        self.y = 0 
     56 
     57    def do_realize(self): 
     58        self.set_flags(self.flags() | gtk.REALIZED) 
     59 
     60        self.window = gtk.gdk.Window(self.get_parent_window(), 
     61                                     width=self.allocation.width, 
     62                                     height=self.allocation.height, 
     63                                     window_type=gtk.gdk.WINDOW_CHILD, 
     64                                     wclass=gtk.gdk.INPUT_OUTPUT, 
     65                                     event_mask=self.get_events() | 
     66                                                gtk.gdk.EXPOSURE_MASK) 
     67 
     68        self.window.set_user_data(self) 
     69        self.style.attach(self.window) 
     70        self.style.set_background(self.window, gtk.STATE_NORMAL) 
     71        self.window.move_resize(*self.allocation) 
     72 
     73    def do_unrealize(self): 
     74        self.window.set_user_data(None) 
     75 
     76    def do_size_request(self, requisition): 
     77        requisition.width = 250 
     78        requisition.height = 250 
     79 
     80    def do_size_allocate(self, allocation): 
     81        self.allocation = allocation 
     82 
     83        if self.flags() & gtk.REALIZED: 
     84            self.window.move_resize(*allocation) 
     85 
     86    def do_expose_event(self, event): 
     87        cr = self.window.cairo_create() 
     88        cr.rectangle(*event.area) 
     89        cr.clip() 
     90 
     91                 
     92        cr.rectangle(self.x, self.y, 50, 50) 
     93        cr.fill() 
     94 
     95        gobject.timeout_add(25, self.timeout) 
     96 
     97    def timeout(self): 
     98        if self.y + 50 > self.allocation[3]: 
     99            self.y = self.allocation[3] - 50 
     100            self.x += 5 
     101        if self.x + 50 > self.allocation[2]: 
     102            self.y -= 5 
     103            self.x = self.allocation[2] - 49 
     104        else: 
     105            self.y += 5 
     106 
     107        self.queue_draw() 
     108        return False 
     109 
     110 
     111gobject.type_register(test4B)