Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.25 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import pygtk
  4. pygtk.require("2.0")
  5. import gtk
  6. import MySQLdb
  7.  
  8. class TestBar:
  9.     def __init__(self):
  10.         interface = gtk.Builder()
  11.         interface.add_from_file('interface.glade')
  12.        
  13.         self.somme = 0.0
  14.         self.label = interface.get_object("label_1")
  15.         self.statusbar = interface.get_object("statusbar")
  16.         self.combo = interface.get_object("combo")
  17.  
  18.         connexion = MySQLdb.connect(host="localhost", user="root", passwd="converse", db="scores")
  19.         cursor = connexion.cursor()
  20.  
  21.         cursor.execute("SELECT pseudo FROM scores")
  22.         row = cursor.fetchall()
  23.  
  24.  
  25.         for record in row:
  26.             label = ""
  27.             label = str(record[0])
  28.            
  29.  
  30.         interface.connect_signals(self)
  31.  
  32.     def on_main_window_destroy(self, widget):
  33.         gtk.main_quit()
  34.  
  35.     def add_money(self, amount):
  36.         self.somme = float(self.somme) + float(amount)
  37.         label = str(self.somme)
  38.         self.label.set_text(label)
  39.         self.statusbar.push(1, "Added {0} euros".format(amount))
  40.         return
  41.  
  42.     def on_btn_01_clicked(self, widget):
  43.         self.add_money(0.1)
  44.     def on_btn_18_clicked(self, widget):
  45.         self.add_money(1.8)
  46.     def on_btn_10_clicked(self, widget):
  47.         self.add_money(1.0)
  48.     def on_btn_07_clicked(self, widget):
  49.         self.add_money(0.7)
  50.     def on_btn_15_clicked(self, widget):
  51.         self.add_money(1.5)
  52.     def on_btn_08_clicked(self, widget):
  53.         self.add_money(0.8)
  54.     def on_btn_03_clicked(self, widget):
  55.         self.add_money(0.3)
  56.     def on_btn_01_clicked(self, widget):
  57.         self.add_money(0.1)
  58.     def on_btn_05_clicked(self, widget):
  59.         self.add_money(0.5)
  60.     def on_btn_12_clicked(self, widget):
  61.         self.add_money(1.2)
  62.  
  63.        
  64.     def on_btn_reset_clicked(self, widget):
  65.         self.somme = 0.0
  66.         label = str(self.somme)
  67.         self.label.set_text(label)
  68.         self.statusbar.push(1, "Reset")
  69.         return
  70.  
  71.     def on_btn_add_clicked(self, widget):
  72.         self.on_btn_reset_clicked(widget)
  73.         self.statusbar.push(1, "Done")     
  74.         return
  75.  
  76.     def on_btn_test_clicked(self, widget):
  77.         connexion = MySQLdb.connect(host="localhost", user="root", passwd="converse", db="scores")
  78.         cursor = connexion.cursor()
  79.  
  80.         cursor.execute("SELECT pseudo FROM scores")
  81.         row = cursor.fetchall()
  82.  
  83.         label = ""
  84.         for record in row:
  85.             label += str(record[0] + '\n')
  86.         self.label.set_text(label)
  87.        
  88.         return
  89.  
  90.  
  91.        
  92.  
  93.  
  94. if __name__ == "__main__":
  95.     TestBar()
  96.     gtk.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement