Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import pygtk
- pygtk.require("2.0")
- import gtk
- import MySQLdb
- class TestBar:
- def __init__(self):
- interface = gtk.Builder()
- interface.add_from_file('interface.glade')
- self.somme = 0.0
- self.label = interface.get_object("label_1")
- self.statusbar = interface.get_object("statusbar")
- self.combo = interface.get_object("combo")
- connexion = MySQLdb.connect(host="localhost", user="root", passwd="converse", db="scores")
- cursor = connexion.cursor()
- cursor.execute("SELECT pseudo FROM scores")
- row = cursor.fetchall()
- for record in row:
- label = ""
- label = str(record[0])
- interface.connect_signals(self)
- def on_main_window_destroy(self, widget):
- gtk.main_quit()
- def add_money(self, amount):
- self.somme = float(self.somme) + float(amount)
- label = str(self.somme)
- self.label.set_text(label)
- self.statusbar.push(1, "Added {0} euros".format(amount))
- return
- def on_btn_01_clicked(self, widget):
- self.add_money(0.1)
- def on_btn_18_clicked(self, widget):
- self.add_money(1.8)
- def on_btn_10_clicked(self, widget):
- self.add_money(1.0)
- def on_btn_07_clicked(self, widget):
- self.add_money(0.7)
- def on_btn_15_clicked(self, widget):
- self.add_money(1.5)
- def on_btn_08_clicked(self, widget):
- self.add_money(0.8)
- def on_btn_03_clicked(self, widget):
- self.add_money(0.3)
- def on_btn_01_clicked(self, widget):
- self.add_money(0.1)
- def on_btn_05_clicked(self, widget):
- self.add_money(0.5)
- def on_btn_12_clicked(self, widget):
- self.add_money(1.2)
- def on_btn_reset_clicked(self, widget):
- self.somme = 0.0
- label = str(self.somme)
- self.label.set_text(label)
- self.statusbar.push(1, "Reset")
- return
- def on_btn_add_clicked(self, widget):
- self.on_btn_reset_clicked(widget)
- self.statusbar.push(1, "Done")
- return
- def on_btn_test_clicked(self, widget):
- connexion = MySQLdb.connect(host="localhost", user="root", passwd="converse", db="scores")
- cursor = connexion.cursor()
- cursor.execute("SELECT pseudo FROM scores")
- row = cursor.fetchall()
- label = ""
- for record in row:
- label += str(record[0] + '\n')
- self.label.set_text(label)
- return
- if __name__ == "__main__":
- TestBar()
- gtk.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement