Changeset 3284

Show
Ignore:
Timestamp:
08/01/08 19:55:05 (5 years ago)
Author:
nopper
Message:

fixing show and allocate bugs

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branch/PacketManipulator/widgets/Expander.py

    r3283 r3284  
    3737# Requires PyGTK 2.8.0 or later 
    3838 
     39__all__ = ['AnimatedExpander', 'ToolBox'] 
     40 
    3941class Child: 
    4042    widget = None 
     
    178180 
    179181    def do_expose_event(self, event): 
     182        if self._animating: 
     183            if not self.flags() & gtk.VISIBLE: 
     184                self.show() 
     185        else: 
     186            if self._to_show: 
     187                if not self.flags() & gtk.VISIBLE: 
     188                    self.show() 
     189            else: 
     190                if self.flags() & gtk.VISIBLE: 
     191                    self.hide() 
     192 
    180193        if event.window != self._bin_window: 
    181194            return False 
     
    444457        self.pack_start(self._layout) 
    445458         
    446         self.set_size_request(40, 100) 
    447459        self.show_all() 
    448  
    449     def do_size_allocate(self, allocation): 
    450         # We should force a size allocate to avoid bugs 
    451         # when the widget is getting too small! 
    452         gtk.VBox.do_size_allocate(self, allocation) 
    453         self._layout.size_allocate(self._layout.allocation) 
    454460 
    455461    def do_realize(self): 
     
    460466 
    461467        self._happy_box.modify_bg(gtk.STATE_NORMAL, bg_color) 
     468 
     469        # Uhmma uhmma bad trick! 
     470        if not self._layout._to_show: 
     471            self._layout.hide() 
    462472 
    463473    def add_widget(self, widget, show=False): 
     
    473483 
    474484    def add(self, widget): 
    475         self.add_widget(widget, False) #FIXME 
     485        self.add_widget(widget, True) 
    476486 
    477487    def get_label(self): 
     
    586596        self.pack_start(page, False, False) 
    587597        self._pages.append(page) 
    588         #self.set_active_page(page) 
     598        #self._set_active_page(page) 
    589599     
    590600    # Private API 
     
    667677            # if not ignore the page._expand and set the packing to True 
    668678 
    669             print "yuuuuuuuuu" 
    670  
    671679            for child in self.get_children(): 
    672                 print "OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO" 
    673680                print self.query_child_packing(child) 
    674681 
     
    700707 
    701708    exp = klass("miao") 
    702     exp.add(sw) 
     709    exp.add_widget(sw, False) 
    703710 
    704711    vbox.pack_start(exp, False, False) 
     
    708715 
    709716    exp = klass("miao") 
    710     exp.add(sw) 
     717    exp.add_widget(sw, False) 
    711718    vbox.pack_start(exp) 
    712719 
     
    725732 
    726733if __name__ == "__main__": 
    727     #main(AnimatedExpander) 
     734    main(AnimatedExpander) 
    728735    #main(gtk.Expander) 
    729736    toolbox()