Advertisement
Mashudi

PemetikWarnaRC1.py

Nov 2nd, 2013
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.62 KB | None | 0 0
  1. #!/usr/bin/python
  2. # Ini Aplikasi Pengambil Sample Warna.
  3. #
  4. # Pembuat : Mashudi Castol
  5. #
  6. # Properti Jendela
  7.  
  8. import gtk, sys
  9.  
  10. class PyApp(gtk.Window):
  11.  
  12.     def __init__(self):
  13.         super(PyApp, self).__init__()
  14.        
  15.         self.set_title("Pemetik Warna")
  16.         self.set_size_request(350, 300)
  17.         self.set_position(gtk.WIN_POS_CENTER)
  18.  
  19.         self.connect("destroy", gtk.main_quit)
  20.        
  21.         self.show_all()
  22.        
  23. # Ikon1
  24.         try:
  25.       self.set_icon_from_file("/home/hudi/Pemetik_Warna/Ikon/ikon.svg")
  26.     except Exception, e:
  27.       print e.message
  28.       sys.exit(1)
  29. # Ikon1
  30.  
  31. # Tombol Keluar
  32.         close = gtk.Button("Keluar", gtk.STOCK_QUIT)
  33.         close.set_size_request(80, 35)
  34.         close.connect("clicked", gtk.main_quit)
  35. # Tombol Keluar
  36.  
  37. # Menu
  38.         mb = gtk.MenuBar()
  39.  
  40.         filemenu = gtk.Menu()
  41.         filem = gtk.MenuItem("File")
  42.         filem.set_submenu(filemenu)
  43.        
  44.         exit = gtk.MenuItem("Exit")
  45.         exit.connect("activate", gtk.main_quit)
  46.         filemenu.append(exit)
  47.  
  48.         mb.append(filem)
  49. # Menu
  50.  
  51. # Tombol, Penampil Warna, Ikon2, Pengaturan,
  52.        
  53.         self.label = gtk.Label("Petik Warnamu Di sini")
  54.         self.label2 = gtk.Label("Code Warna")
  55.        
  56.         self.darea = gtk.DrawingArea()
  57.         self.darea.set_size_request(150, 150)
  58.        
  59.         button = gtk.Button("Petik Warna")
  60.         button.set_tooltip_text("Petik Warna")
  61.         button.connect("clicked", self.on_clicked)
  62.        
  63.         fix = gtk.Fixed()
  64.         fix.put(mb, 0, 0)
  65.         fix.put(close, 265, 250)
  66.         fix.put(button, 10, 40)
  67.         fix.put(self.darea, 10, 70)
  68.         fix.put(self.label, 5, 25)
  69.         fix.put(self.label2, 175, 25)
  70.         self.add(fix)
  71.        
  72.         self.show_all()
  73.            
  74.     def on_clicked(self, widget):
  75.         cdia = gtk.ColorSelectionDialog("Petik Warnamu Sekarang")
  76.         cdia.set_icon_from_file("/home/hudi/Pemetik_Warna/Ikon/ikon.svg")
  77.        
  78.         response = cdia.run()
  79.        
  80.         if response == gtk.RESPONSE_OK:
  81.             colorsel = cdia.colorsel
  82.             color = colorsel.get_current_color()
  83.             self.darea.modify_bg(gtk.STATE_NORMAL, color)
  84.        
  85.         cdia.destroy()
  86. # Tombol, Penampil Warna, Ikon2, Pengaturan, Label1, Label2
  87.  
  88. # Judul Terminal
  89.  
  90. if __name__ == '__main__':
  91.     print "############################################"
  92.     print "               PEMETIK WARNA                "
  93.     print "                  Versi 1                   "
  94.     print "############################################"
  95.  
  96. # Judul Terminal
  97.  
  98.        
  99. PyApp()
  100. gtk.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement