home *** CD-ROM | disk | FTP | other *** search
/ tusportal.tus.k12.pa.us / tusportal.tus.k12.pa.us.tar / tusportal.tus.k12.pa.us / Wyse / latest-image.raw / 0.img / usr / lib / pygtk / 2.0 / demos / panes.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2010-05-11  |  4KB  |  107 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. '''Paned Widgets
  5.  
  6. The GtkHPaned and GtkVPaned Widgets divide their content area into two panes
  7. with a divider in between that the user can adjust. A separate child is placed
  8. into each pane.
  9. There are a number of options that can be set for each pane. This test contains
  10. both a horizontal(HPaned) and a vertical(VPaned) widget, and allows you to
  11. adjust the options for each side of each widget.'''
  12. import gtk
  13.  
  14. class PanedWidgetsDemo(gtk.Window):
  15.     
  16.     def __init__(self, parent = None):
  17.         gtk.Window.__init__(self)
  18.         
  19.         try:
  20.             self.set_screen(parent.get_screen())
  21.         except AttributeError:
  22.             self.connect('destroy', (lambda : gtk.main_quit()))
  23.  
  24.         self.set_title(self.__class__.__name__)
  25.         self.set_border_width(0)
  26.         vbox = gtk.VBox(False, 0)
  27.         self.add(vbox)
  28.         vpaned = gtk.VPaned()
  29.         vbox.pack_start(vpaned, True, True)
  30.         vpaned.set_border_width(5)
  31.         hpaned = gtk.HPaned()
  32.         vpaned.add1(hpaned)
  33.         frame = gtk.Frame()
  34.         frame.set_shadow_type(gtk.SHADOW_IN)
  35.         frame.set_size_request(60, 60)
  36.         hpaned.add1(frame)
  37.         button = gtk.Button('_Hi there')
  38.         frame.add(button)
  39.         frame = gtk.Frame()
  40.         frame.set_shadow_type(gtk.SHADOW_IN)
  41.         frame.set_size_request(80, 60)
  42.         hpaned.add2(frame)
  43.         frame = gtk.Frame()
  44.         frame.set_shadow_type(gtk.SHADOW_IN)
  45.         frame.set_size_request(60, 80)
  46.         vpaned.add2(frame)
  47.         vbox.pack_start(self._PanedWidgetsDemo__create_pane_options(hpaned, 'Horizontal', 'Left', 'Right'), False, False, 0)
  48.         vbox.pack_start(self._PanedWidgetsDemo__create_pane_options(vpaned, 'Vertical', 'Top', 'Bottom'), False, False, 0)
  49.         self.show_all()
  50.  
  51.     
  52.     def on_resize_toggled(self, tbutton, child):
  53.         paned = child.parent
  54.         if child == paned.get_children()[0]:
  55.             paned.remove(child)
  56.             paned.pack1(child, tbutton.get_active(), 0)
  57.         else:
  58.             paned.remove(child)
  59.             paned.pack2(child, tbutton.get_active(), 0)
  60.  
  61.     
  62.     def on_shrink_toggled(self, tbutton, child):
  63.         paned = child.parent
  64.         if child == paned.get_children()[0]:
  65.             paned.remove(child)
  66.             paned.pack1(child, 0, tbutton.get_active())
  67.         else:
  68.             paned.remove(child)
  69.             paned.pack2(child, 0, tbutton.get_active())
  70.  
  71.     
  72.     def __create_pane_options(self, paned, frame_label, label1, label2):
  73.         frame = gtk.Frame(frame_label)
  74.         frame.set_border_width(4)
  75.         table = gtk.Table(3, 2, True)
  76.         frame.add(table)
  77.         label = gtk.Label(label1)
  78.         table.attach(label, 0, 1, 0, 1)
  79.         check_button = gtk.CheckButton('_Resize')
  80.         check_button.connect('toggled', self.on_resize_toggled, paned.get_children()[0])
  81.         table.attach(check_button, 0, 1, 1, 2)
  82.         check_button = gtk.CheckButton('_Shrink')
  83.         check_button.set_active(True)
  84.         check_button.connect('toggled', self.on_shrink_toggled, paned.get_children()[0])
  85.         table.attach(check_button, 0, 1, 2, 3)
  86.         label = gtk.Label(label2)
  87.         table.attach(label, 1, 2, 0, 1)
  88.         check_button = gtk.CheckButton('_Resize')
  89.         check_button.set_active(True)
  90.         check_button.connect('toggled', self.on_resize_toggled, paned.get_children()[1])
  91.         table.attach(check_button, 1, 2, 1, 2)
  92.         check_button = gtk.CheckButton('_Shrink')
  93.         check_button.set_active(True)
  94.         check_button.connect('toggled', self.on_shrink_toggled, paned.get_children()[1])
  95.         table.attach(check_button, 1, 2, 2, 3)
  96.         return frame
  97.  
  98.  
  99.  
  100. def main():
  101.     PanedWidgetsDemo()
  102.     gtk.main()
  103.  
  104. if __name__ == '__main__':
  105.     main()
  106.  
  107.