From f9ea9e712f8d3e2e5854ffd580add032e5c6670f Mon Sep 17 00:00:00 2001 From: Cristhofer Travieso Date: Sat, 29 Jun 2013 23:11:09 +0000 Subject: Add MyCard class Signed-off-by: Cristhofer Travieso --- (limited to 'game.py') diff --git a/game.py b/game.py index a1c77fa..2a58d77 100644 --- a/game.py +++ b/game.py @@ -25,8 +25,8 @@ class Fixed(Gtk.Fixed): def __init__(self): Gtk.Fixed.__init__(self) - alloc = self.get_allocation() - width = alloc.width() + width = 1300 + height = 700 #opponent cards opponent_card1 = Card() @@ -37,12 +37,12 @@ class Fixed(Gtk.Fixed): self.put(opponent_card3, width/2, 20) #my cards - card1 = Card() - self.put(card1, width/2, 60) - card2 = Card() - self.put(card2, width/2, 70) - card3 = Card() - self.put(card3, width/2, 80) + card1 = MyCard() + self.put(card1, width/2, height-10) + card2 = MyCard() + self.put(card2, width/2, height-20) + card3 = MyCard() + self.put(card3, width/2, height-30) #sample sample = Gtk.Image() @@ -53,19 +53,19 @@ class Fixed(Gtk.Fixed): self.put(deck, 0, 50) grid = Gtk.Grid() - self.put(grid, 1000, 500) + self.put(grid, width*0.90, height*0.90) truco_btn = Gtk.Button('Truco') - grid.next(truco_btn) + grid.add(truco_btn) retruco_btn = Gtk.Button('Retruco') - grid.next(retruco_btn) + grid.add(retruco_btn) vale4_btn = Gtk.Button('Vale 4') - grid.next(vale4_btn) + grid.add(vale4_btn) - flor_btn = Gtk.Button('Vale 4') - grid.next(flor_btn) + flor_btn = Gtk.Button('Flor') + grid.add(flor_btn) class Card(Gtk.Button): @@ -86,3 +86,24 @@ class Card(Gtk.Button): #def repartir(): #repartir cartas + + +class MyCard(Gtk.Button): + + def __init__(self): + Gtk.Button.__init__(self) + + self.image = Gtk.Image() + self.add(self.image) + + self.x = 0#obtener posicion de la carta + self.y = 0#obtener posicion de la carta + + def play(self, center): + fixed.move(self, center[0]/2, center[1]/2) + + def back(self): + fixed.move(self, self.x, self.y) + +#def repartir(): + #repartir cartas -- cgit v0.9.1