CrunchBang Linux Pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

CrunchBang Linux Pastebin

Posted by tao_te on Fri 5th Oct 17:12 (modification of post by view diff)
download | new post

  1. #!/usr/bin/env python
  2.  
  3. import pygtk
  4. pygtk.require('2.0')
  5. import gtk
  6. import os
  7. import getpass
  8.  
  9. class cb_exit:
  10.         def disable_buttons(self):
  11.                 self.shutdown.set_sensitive(False)
  12.                 self.reboot.set_sensitive(False)
  13.                 self.suspend.set_sensitive(False)
  14.                 self.cancel.set_sensitive(False)
  15.  
  16.         def shutdown_action(self,btn):
  17.                 self.disable_buttons()
  18.                 self.status.set_label("Shutting down, please standby...")
  19.                 os.system("dbus-send --system --print-reply --dest=\"org.freedesktop.ConsoleKit\" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop")
  20.  
  21.         def reboot_action(self,btn):
  22.                 self.disable_buttons()
  23.                 self.status.set_label("Rebooting, please standby...")
  24.                 os.system("dbus-send --system --print-reply --dest=\"org.freedesktop.ConsoleKit\" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart")
  25.  
  26.         def suspend_action(self,btn):
  27.                 self.disable_buttons()
  28.                 self.status.set_label("Suspending, please standby...")
  29.                 os.system("cb-lock")
  30.                 os.system("dbus-send --system --print-reply --dest=\"org.freedesktop.UPower\" /org/freedesktop/UPower org.freedesktop.UPower.Suspend")
  31.                 gtk.main_quit()
  32.  
  33.         def cancel_action(self,btn):
  34.                 self.disable_buttons()
  35.                 gtk.main_quit()
  36.  
  37.         def create_window(self):
  38.                 self.window = gtk.Window()
  39.                 title = "exit menu"
  40.                 self.window.set_title(title)
  41.                 self.window.set_border_width(1)
  42.                 self.window.set_size_request(400, 50)
  43.                 self.window.set_resizable(False)
  44.                 self.window.set_keep_above(True)
  45.                 self.window.stick
  46.                 self.window.set_position(1)
  47.                 self.window.connect("delete_event", gtk.main_quit)
  48.                 windowicon = self.window.render_icon(gtk.STOCK_QUIT, gtk.ICON_SIZE_MENU)
  49.                 self.window.set_icon(windowicon)
  50.  
  51.                
  52.                 #Create HBox for buttons
  53.                 self.button_box = gtk.HBox()
  54.                 self.button_box.show()
  55.                
  56.                 #Shutdown button
  57.                 self.shutdown = gtk.Button("_Shutdown")
  58.                 self.shutdown.set_border_width(4)
  59.                 self.shutdown.connect("clicked", self.shutdown_action)
  60.                 self.button_box.pack_start(self.shutdown)
  61.                 self.shutdown.show()
  62.                
  63.                 #Reboot button
  64.                 self.reboot = gtk.Button("_Reboot")
  65.                 self.reboot.set_border_width(4)
  66.                 self.reboot.connect("clicked", self.reboot_action)
  67.                 self.button_box.pack_start(self.reboot)
  68.                 self.reboot.show()
  69.                
  70.                 #Suspend button
  71.                 self.suspend = gtk.Button("_Suspend")
  72.                 self.suspend.set_border_width(4)
  73.                 self.suspend.connect("clicked", self.suspend_action)
  74.                 self.button_box.pack_start(self.suspend)
  75.                 self.suspend.show()
  76.                
  77.                 #Cancel button
  78.                 self.cancel = gtk.Button("_cancel")
  79.                 self.cancel.set_border_width(4)
  80.                 self.cancel.connect("clicked", self.cancel_action)
  81.                 self.button_box.pack_start(self.cancel)
  82.                 self.cancel.show()
  83.                
  84.                 #Create HBox for status label
  85.                 self.label_box = gtk.HBox()
  86.                 self.label_box.show()
  87.                 self.status = gtk.Label()
  88.                 self.status.show()
  89.                 self.label_box.pack_start(self.status)
  90.                
  91.                 #Create VBox and pack the above HBox's
  92.                 self.vbox = gtk.VBox()
  93.                 self.vbox.pack_start(self.button_box)
  94.                 self.vbox.pack_start(self.label_box)
  95.                 self.vbox.show()
  96.                
  97.                 self.window.add(self.vbox)
  98.                 self.window.show()
  99.                
  100.         def __init__(self):
  101.                 self.create_window()
  102.  
  103.  
  104. def main():
  105.     gtk.main()
  106.  
  107. if __name__ == "__main__":
  108.     go = cb_exit()
  109.     main()

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me