diff options
author | Cristhofer Travieso <cristhofert97@gmail.com> | 2013-05-26 02:28:39 (GMT) |
---|---|---|
committer | Cristhofer Travieso <cristhofert97@gmail.com> | 2013-05-26 02:28:39 (GMT) |
commit | 7b0db958b5bbc728493acd633ea28495fc682c03 (patch) | |
tree | e216e896021b53f1cb08aca87929b42f2490393e | |
parent | c0293bc75b3cf60416c1e29cc17c5537bb8b99a7 (diff) |
Add window file and .gitignore file
Signed-off-by: Cristhofer Travieso <cristhofert97@gmail.com>
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | game.py | 53 | ||||
-rw-r--r-- | window.py | 28 |
3 files changed, 49 insertions, 36 deletions
@@ -1,2 +1,6 @@ *.pyc +*.pyo +*.mo *~ +*.txt +NOTA @@ -1,6 +1,6 @@ #!/usr/bin/env python -# Copyright (C) 2012 Cristhofer Travieso <cristhofert97@gmail.com> +# Copyright (C) 2013 Cristhofer Travieso <cristhofert97@gmail.com> # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,64 +16,45 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -import cairo from gi.repository import Gtk -from gi.repository import Gdk from gi.repository import GObject -try: +sugar = False +if sugar: from sugar3.graphics import style - SIZE = style.zoom(150) BETWEEN_LINE_SPACE = style.zoom(200) -except: - pass - +else: + SIZE = 0 + BETWEEN_LINE_SPACE = 0 LINE_WIDTH = 12 -MODE_CIRCLE = 0 -MODE_CROSS = 1 +BACKGROUND_COLOR = (0, 1, 0) -TICTACTOE_COLOR = (1, 1, 1) -CROSS_COLOR = (0, 0.921568, 0.0627450) -CIRCLE_COLOR = (1, 0.556862, 0) -BACKGROUND_COLOR = (0.50, 0.20, 0) +class Canvas(Gtk.DrawingArea): -class Game(Gtk.DrawingArea): + __gsignals__ = { + 'update': (GObject.SIGNAL_RUN_FIRST, None, [])} def __init__(self): GObject.GObject.__init__(self) - self.add_events(Gdk.EventMask.BUTTON_PRESS_MASK | - Gdk.EventMask.POINTER_MOTION_MASK) + self.cars = [[100, 100, 50, 50, "horizontal", True]] + self.routes = [(10, "horizontal"), (200, "vertical")] self.connect('draw', self._draw_cb) - self.connect('button-press-event', self._click_cb) - self.connect('motion-notify-event', self._motion_notify_cb) self.show_all() def _draw_cb(self, widget, context): - alloc = self.get_allocation() + #redraw + + self.alloc = self.get_allocation() # Background - context.rectangle(0, 0, alloc.width, alloc.height) + context.rectangle(0, 0, self.alloc.width, self.alloc.height) context.set_source_rgb(*BACKGROUND_COLOR) context.fill() - def _motion_notify_cb(self, widget, event): - x_cursor = event.x - y_cursor = event.y - - def _click_cb(self, widget, event): - x_click = event.x - y_click = event.y - -if __name__ == "__main__": - window = Gtk.Window() - window.connect('destroy', lambda w: Gtk.main_quit()) - window.add(Game()) - window.maximize() - window.show_all() - Gtk.main() + #Draw cards diff --git a/window.py b/window.py new file mode 100644 index 0000000..7e11c9a --- /dev/null +++ b/window.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python + +# Copyright (C) 2013 Cristhofer Travieso <cristhofert97@gmail.com> + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +from gi.repository import Gtk +from game import Canvas + +if __name__ == "__main__": + window = Gtk.Window() + window.connect('destroy', lambda w: Gtk.main_quit()) + window.add(Canvas()) + window.maximize() + window.show_all() + Gtk.main() |