Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/game.py
diff options
context:
space:
mode:
authorCristhofer Travieso <cristhofert97@gmail.com>2013-08-13 18:13:56 (GMT)
committer Cristhofer Travieso <cristhofert97@gmail.com>2013-08-13 18:13:56 (GMT)
commitf41503959688561a855d37b32a1e9d5da18428a2 (patch)
treef3eddeea0242446089b8fa6fc00e0451f492328c /game.py
parent306db77d94eaa00e46ea85f5879486055a78c9f6 (diff)
Add 4 box to supplant the fixed
Signed-off-by: Cristhofer Travieso <cristhofert97@gmail.com>
Diffstat (limited to 'game.py')
-rw-r--r--game.py51
1 files changed, 50 insertions, 1 deletions
diff --git a/game.py b/game.py
index 825c513..c9908fb 100644
--- a/game.py
+++ b/game.py
@@ -20,10 +20,14 @@ from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import GObject
import os
+import random
WIDTH = 1200
HEIGHT = 700
+OPPONENT_CARDS = [None, None, None]
+MY_CARDS = [None, None, None]
+
class Eventbox(Gtk.EventBox):
def __init__(self):
Gtk.EventBox.__init__(self)
@@ -31,9 +35,54 @@ class Eventbox(Gtk.EventBox):
parse, color = Gdk.Color.parse('green')
self.modify_bg(Gtk.StateType.NORMAL, color)
- self.add(Fixed())
+ self.add(Box())
self.show()
+class Box(Gtk.VBox):
+ def __init__(self):
+
+ self.opponent_box = Gtk.HBox()
+ self.add(self.opponent_box)
+ self.my_box = Gtk.HBox()
+ self.add(self.my_box)
+ self.play_box = Gtk.HBox()
+ self.add(self.play_box)
+
+ self._deal()
+
+ for image in MY_CARDS:
+ b = Gtk.Button()
+ i = Gtk.Image()
+ i.set_from_file(image)
+ b.add(i)
+ b.connect('clicked', self._click)
+ self.my_box.add(b)
+
+ self.show_all()
+
+ def _deal(self):
+ OPPONENT_CARDS[0] = random.choice(os.getcwd() + '/cards')
+ OPPONENT_CARDS[1] = random.choice(os.getcwd() + '/cards')
+ OPPONENT_CARDS[2] = random.choice(os.getcwd() + '/cards')
+
+ MY_CARDS[0] = random.choice(os.getcwd() + '/cards')
+ MY_CARDS[1] = random.choice(os.getcwd() + '/cards')
+ MY_CARDS[2] = random.choice(os.getcwd() + '/cards')
+
+ def _click(self, widget):
+ self.my_box.remove(widget)
+ self.play_box.add(widget)
+
+ image = random.choice(OPPONET_CARDS)
+ btn = Gtk.Button()
+ img = Gtk.Image()
+ img.set_from_file(image)
+ btn.add(img)
+ btn.connect('clicked', self._click)
+ self.paly_box.add(btn)
+
+ del OPPONENT_CARDS[OPPONENT_CARDS.index(image)]
+
class Fixed(Gtk.Fixed):
def __init__(self):