Skip to content

Instantly share code, notes, and snippets.

@robotlolita
Created March 7, 2011 21:19
Show Gist options
  • Save robotlolita/859254 to your computer and use it in GitHub Desktop.
Save robotlolita/859254 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
###############################################################################
### ~efl-ttt.game~ ###
### '''''''''''''' ###
### Simple tic-tac-toe game in Python using EFL/Elementary. ###
### ###
### ###
### Copyright (c) 2011 Quildreen Motta // Licenced under MIT/X11 ###
###############################################################################
from elementary import Window, Background, shutdown, ELM_WIN_BASIC \
, run as elm_run \
, exit as elm_exit
from evas import EVAS_HINT_EXPAND as EH_EXPAND
#### Helper functions #########################################################
def expandable(obj):
obj.size_hint_weight_set(EH_EXPAND, EH_EXPAND)
return obj
def add(obj, win):
win.resize_object_add(obj)
obj.show()
return obj
#### Game's class #############################################################
class MainWindow(Window):
"""The main game window.
"""
def __init__(self):
super(MainWindow, self).__init__("main", ELM_WIN_BASIC)
self.title_set("Tic-Tac-Toe")
self.resize(500, 450)
self.callback_destroy_add(self.on_destroy)
self.show()
def on_destroy(self, obj):
elm_exit()
class TicTacToe(object):
"""Represents a tic-tac-toe game.
"""
def __init__(self):
"""Sets up the game environment.
"""
self.win = MainWindow()
add(expandable(Background(self.win)), self.win)
def run(self):
"""Runs the game.
"""
elm_run()
shutdown()
if __name__ == '__main__':
TicTacToe().run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment