Advertisement
Mashudi

Source_percobaan

Nov 1st, 2013
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.92 KB | None | 0 0
  1. #!/usr/bin/python
  2. # Ini Aplikasi Pengambil Sample Warna.
  3. #
  4. # Pembuat : Mashudi Castol
  5.  
  6. # Judul Terminal
  7.  
  8. if __name__ == '__main__':
  9.     print "############################################"
  10.     print "               PEMETIK WARNA                "
  11.     print "                  Versi 1                   "
  12.     print "############################################"
  13.  
  14. # Judul Terminal
  15.  
  16. # Properti Jendela
  17.  
  18. import gtk, sys
  19.  
  20. class PyApp(gtk.Window):
  21.  
  22.     def __init__(self):
  23.         super(PyApp, self).__init__()
  24.        
  25.         self.set_title("Pemetik Warna")
  26.         self.set_size_request(650, 300)
  27.         self.set_position(gtk.WIN_POS_CENTER)
  28.        
  29.         self.connect("destroy",gtk.main_quit)
  30.         self.show()
  31.        
  32. # Ikon1
  33.         try:
  34.       self.set_icon_from_file("/home/hudi/Pemetik_Warna/Ikon/ikon.svg")
  35.     except Exception, e:
  36.       print e.message
  37.       sys.exit(1)
  38. # Ikon
  39.  
  40. # Tombol, Penampil Warna
  41.         label = gtk.Label("tempat colorname")
  42.        
  43.         self.darea = gtk.DrawingArea()
  44.         self.darea.set_size_request(150, 150)
  45.        
  46.         button = gtk.Button("Petik Warna")
  47.         button.set_tooltip_text("Petik Warna")
  48.         button.connect("clicked", self.on_clicked)
  49.        
  50.         fix = gtk.Fixed()
  51.         fix.put(button, 10, 30)
  52.         fix.put(self.darea, 10, 60)
  53.         fix.put(label, 200, 30)
  54.         self.add(fix)
  55.        
  56.         self.show_all()
  57.            
  58.     def on_clicked(self, widget):
  59.         cdia = gtk.ColorSelectionDialog("Petik Warnamu Sekarang")
  60.         cdia.set_icon_from_file("/home/hudi/Pemetik_Warna/Ikon/ikon.svg")
  61.        
  62.         response = cdia.run()
  63.        
  64.         if response == gtk.RESPONSE_OK:
  65.             colorsel = cdia.colorsel
  66.             color = colorsel.get_current_color()
  67.             self.darea.modify_bg(gtk.STATE_NORMAL, color)
  68.        
  69.         cdia.destroy()
  70. # Tombol, Penampil Warna
  71.        
  72.        
  73. PyApp()
  74. gtk.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement