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 / dialogs.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2010-05-11  |  4KB  |  110 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. '''Dialog and Message Boxes
  5.  
  6. Dialog widgets are used to pop up a transient window for user feedback.'''
  7. import gtk
  8.  
  9. class DialogAndMessageBoxesDemo(gtk.Window):
  10.     counter = 1
  11.     
  12.     def __init__(self, parent = None):
  13.         gtk.Window.__init__(self)
  14.         
  15.         try:
  16.             self.set_screen(parent.get_screen())
  17.         except AttributeError:
  18.             self.connect('destroy', (lambda : gtk.main_quit()))
  19.  
  20.         self.set_title(self.__class__.__name__)
  21.         self.set_border_width(8)
  22.         frame = gtk.Frame('Dialogs')
  23.         self.add(frame)
  24.         vbox = gtk.VBox(False, 8)
  25.         vbox.set_border_width(8)
  26.         frame.add(vbox)
  27.         hbox = gtk.HBox(False, 8)
  28.         vbox.pack_start(hbox)
  29.         button = gtk.Button('_Message Dialog')
  30.         button.connect('clicked', self.on_message_dialog_clicked)
  31.         hbox.pack_start(button, False, False, 0)
  32.         vbox.pack_start(gtk.HSeparator(), False, False, 0)
  33.         hbox = gtk.HBox(False, 8)
  34.         vbox.pack_start(hbox, False, False, 0)
  35.         vbox2 = gtk.VBox()
  36.         button = gtk.Button('_Interactive Dialog')
  37.         button.connect('clicked', self.on_interactive_dialog_clicked)
  38.         hbox.pack_start(vbox2, False, False, 0)
  39.         vbox2.pack_start(button, False, False, 0)
  40.         table = gtk.Table(2, 2)
  41.         table.set_row_spacings(4)
  42.         table.set_col_spacings(4)
  43.         hbox.pack_start(table, False, False, 0)
  44.         label = gtk.Label('Entry _1')
  45.         label.set_use_underline(True)
  46.         table.attach(label, 0, 1, 0, 1)
  47.         self.entry1 = gtk.Entry()
  48.         table.attach(self.entry1, 1, 2, 0, 1)
  49.         label.set_mnemonic_widget(self.entry1)
  50.         label = gtk.Label('Entry _2')
  51.         label.set_use_underline(True)
  52.         table.attach(label, 0, 1, 1, 2)
  53.         self.entry2 = gtk.Entry()
  54.         table.attach(self.entry2, 1, 2, 1, 2)
  55.         label.set_mnemonic_widget(self.entry2)
  56.         self.show_all()
  57.  
  58.     
  59.     def on_message_dialog_clicked(self, button):
  60.         if not self.counter > 1 or 's':
  61.             pass
  62.         dialog = gtk.MessageDialog(self, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, 'This message box has been popped up %d time%s.' % (self.counter, ''))
  63.         dialog.run()
  64.         dialog.destroy()
  65.         self.counter += 1
  66.  
  67.     
  68.     def on_interactive_dialog_clicked(self, button):
  69.         dialog = gtk.Dialog('Interactive Dialog', self, 0, (gtk.STOCK_OK, gtk.RESPONSE_OK, '_Non-stock button', gtk.RESPONSE_CANCEL))
  70.         hbox = gtk.HBox(False, 8)
  71.         hbox.set_border_width(8)
  72.         dialog.vbox.pack_start(hbox, False, False, 0)
  73.         stock = gtk.image_new_from_stock(gtk.STOCK_DIALOG_QUESTION, gtk.ICON_SIZE_DIALOG)
  74.         hbox.pack_start(stock, False, False, 0)
  75.         table = gtk.Table(2, 2)
  76.         table.set_row_spacings(4)
  77.         table.set_col_spacings(4)
  78.         hbox.pack_start(table, True, True, 0)
  79.         label = gtk.Label('Entry _1')
  80.         label.set_use_underline(True)
  81.         table.attach(label, 0, 1, 0, 1)
  82.         local_entry1 = gtk.Entry()
  83.         local_entry1.set_text(self.entry1.get_text())
  84.         table.attach(local_entry1, 1, 2, 0, 1)
  85.         label.set_mnemonic_widget(local_entry1)
  86.         label = gtk.Label('Entry _2')
  87.         label.set_use_underline(True)
  88.         table.attach(label, 0, 1, 1, 2)
  89.         local_entry2 = gtk.Entry()
  90.         local_entry2.set_text(self.entry2.get_text())
  91.         table.attach(local_entry2, 1, 2, 1, 2)
  92.         label.set_mnemonic_widget(local_entry2)
  93.         dialog.show_all()
  94.         response = dialog.run()
  95.         if response == gtk.RESPONSE_OK:
  96.             self.entry1.set_text(local_entry1.get_text())
  97.             self.entry2.set_text(local_entry2.get_text())
  98.         
  99.         dialog.destroy()
  100.  
  101.  
  102.  
  103. def main():
  104.     DialogAndMessageBoxesDemo()
  105.     gtk.main()
  106.  
  107. if __name__ == '__main__':
  108.     main()
  109.  
  110.