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 iggykoopa on Sun 11th Jan 04:44 (modification of post by view diff)
View followups from iggykoopa and Anonymous | download | new post

  1. #!/usr/bin/env python2.5
  2.  
  3. import gtk, os
  4. from PIL import Image, ImageFilter
  5.  
  6. class MyApp():
  7.     def __init__(self):
  8.        
  9.         self.window = gtk.Window()       
  10.         self.window.set_title("Log Out ..")
  11.         self.window.connect("destroy", self.doquit)
  12.         self.window.connect("key-press-event", self.onkeypress)
  13.         self.window.set_size_request(620,200)
  14.         self.window.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("black"))
  15.         self.window.set_decorated(gtk.FALSE)
  16.         self.window.set_position(gtk.WIN_POS_CENTER)
  17.  
  18.         self.window.connect("window-state-event", self.on_window_state_change)
  19.        
  20.         self.mainpanel = gtk.Fixed()
  21.         self.window.add(self.mainpanel)
  22.        
  23.         screen_x , screen_y = gtk.gdk.screen_width(), gtk.gdk.screen_height()
  24.        
  25.         x = ( screen_x / 2 ) - 300
  26.         y = ( screen_y / 2 ) - 150
  27.        
  28.         self.add_bouton("esc",x+30,y+30, self.mainpanel)
  29.         self.add_bouton("logout",x+170,y+30, self.mainpanel)
  30.         self.add_bouton("reboot",x+310,y+30, self.mainpanel)
  31.         self.add_bouton("shutdown",x+450,y+30, self.mainpanel)
  32.        
  33.         self.label_info = gtk.Label('Cancel')
  34.         self.label_info.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse("white"))
  35.         self.mainpanel.put(self.label_info, x+80, y+170)
  36.        
  37.         self.label_info = gtk.Label('Logout')
  38.         self.label_info.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse("white"))
  39.         self.mainpanel.put(self.label_info, x+220, y+170)
  40.        
  41.         self.label_info = gtk.Label('Reboot')
  42.         self.label_info.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse("white"))
  43.         self.mainpanel.put(self.label_info, x+360, y+170)
  44.        
  45.         self.label_info = gtk.Label('Shutdown')
  46.         self.label_info.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse("white"))
  47.         self.mainpanel.put(self.label_info, x+490, y+170)
  48.        
  49.         w = gtk.gdk.get_default_root_window()
  50.         sz = w.get_size()
  51.         pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,sz[0],sz[1])
  52.         pb = pb.get_from_drawable(w,w.get_colormap(),0,0,0,0,sz[0],sz[1])
  53.         if (pb != None):
  54.             pb.save("img/bg.jpg","jpeg")
  55.             image = Image.open("img/bg.jpg")
  56.             for i in range(2):
  57.                 image = image.filter(ImageFilter.BLUR)
  58.             image.save("img/bg.jpg","jpeg")
  59.  
  60.         image = 'img/bg.jpg'
  61.         pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(image, screen_x, screen_y)
  62.         pixmap, mask = pixbuf.render_pixmap_and_mask()
  63.         # width, height = pixmap.get_size()
  64.         self.window.set_app_paintable(True)
  65.         self.window.resize(screen_x, screen_y)
  66.         self.window.realize()
  67.         self.window.window.set_back_pixmap(pixmap, False)
  68.         self.window.move(0,0)
  69.         del pixbuf
  70.         del pixmap                   
  71.  
  72.     def on_window_state_change(self, widget, event, *args):
  73.         if event.new_window_state & gtk.gdk.WINDOW_STATE_FULLSCREEN:
  74.             self.window_in_fullscreen = True
  75.         else:
  76.             self.window_in_fullscreen = False
  77.  
  78.     def add_bouton(self, name, x, y, page):
  79.         image = gtk.Image()
  80.         image.set_from_file("img/" + name + ".png")
  81.         image.show()
  82.         # un bouton pour contenir le widget image
  83.         bouton = gtk.Button()
  84.         bouton.set_relief(gtk.RELIEF_NONE)
  85.         bouton.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("black"))
  86.         bouton.set_focus_on_click(False)
  87.         bouton.set_border_width(0)
  88.         bouton.set_property('can-focus', False)
  89.         bouton.add(image)
  90.         #bouton.set_style(self.style)
  91.         bouton.show()
  92.         page.put(bouton, x,y)
  93.         bouton.connect("clicked", self.clic_bouton, name)
  94.  
  95.     # Cette fonction est invoquee quand on clique sur un bouton.
  96.     def clic_bouton(self, widget, data=None):
  97.         if (data=='esc'):
  98.             self.doquit()
  99.         elif (data=='logout'):
  100.             os.system('openbox --exit')
  101.         elif (data=='reboot'):
  102.             os.system('gdm-control --reboot && openbox --exit')
  103.         elif (data=='shutdown'):
  104.             os.system('gdm-control --shutdown && openbox --exit')
  105.            
  106.  
  107.     def onkeypress(self, widget=None, event=None, data=None):
  108.         if event.keyval == gtk.keysyms.Escape:
  109.             self.doquit()
  110.    
  111.     def doquit(self, widget=None, data=None):
  112.         gtk.main_quit()
  113.  
  114.     def run(self):
  115.         self.window.show_all()
  116.         gtk.main()
  117.  
  118. app = MyApp()
  119. app.run()

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