From 2eee2f293a3bab7388c390ec8507afa2dd3958f9 Mon Sep 17 00:00:00 2001 From: Cristhofer Travieso Date: Thu, 18 Jul 2013 00:32:41 +0000 Subject: Fixing bugs of pocition Signed-off-by: Cristhofer Travieso --- (limited to 'game.py') diff --git a/game.py b/game.py index 2a58d77..70df87e 100644 --- a/game.py +++ b/game.py @@ -19,30 +19,32 @@ from gi.repository import Gtk from gi.repository import GObject +WIDTH = 1200 +HEIGHT = 700 class Fixed(Gtk.Fixed): def __init__(self): Gtk.Fixed.__init__(self) - width = 1300 - height = 700 - #opponent cards opponent_card1 = Card() - self.put(opponent_card1, width/2, 0) + self.put(opponent_card1, WIDTH/2, 0) opponent_card2 = Card() - self.put(opponent_card2, width/2, 10) + self.put(opponent_card2, WIDTH/2, 10) opponent_card3 = Card() - self.put(opponent_card3, width/2, 20) + self.put(opponent_card3, WIDTH/2, 20) #my cards card1 = MyCard() - self.put(card1, width/2, height-10) + card1.connect('clicked', self.play_card) + self.put(card1, WIDTH/2, HEIGHT-10) card2 = MyCard() - self.put(card2, width/2, height-20) + card2.connect('clicked', self.play_card) + self.put(card2, WIDTH/2, HEIGHT-20) card3 = MyCard() - self.put(card3, width/2, height-30) + card3.connect('clicked', self.play_card) + self.put(card3, WIDTH/2, HEIGHT-30) #sample sample = Gtk.Image() @@ -53,7 +55,7 @@ class Fixed(Gtk.Fixed): self.put(deck, 0, 50) grid = Gtk.Grid() - self.put(grid, width*0.90, height*0.90) + self.put(grid, WIDTH*0.90, HEIGHT*0.90) truco_btn = Gtk.Button('Truco') grid.add(truco_btn) @@ -67,20 +69,23 @@ class Fixed(Gtk.Fixed): flor_btn = Gtk.Button('Flor') grid.add(flor_btn) + def play_card(self, widget): + self.move(widget, WIDTH/2, HEIGHT/2+100) + + def back(self): + fixed.move(self, self.x, self.y) + class Card(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) @@ -99,11 +104,6 @@ class MyCard(Gtk.Button): 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