Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/canvas.py
blob: ba58b28028e9311752d1dc07407f8979361d45f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2012 S. Daniel Francis <francis@sugarlabs.org>
#
# 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 3 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 Street, Fifth Floor, Boston,
# MA 02110-1301, USA.

import logging
logger = logging.getLogger('canvas')
logger.debug('start canvas')
import math
from gi.repository import Gtk

from number_box import SudokuNumberBox
logger.debug('Import all')

class Canvas(Gtk.AspectFrame):
    def __init__(self, toolbar_box, activity):
        Gtk.AspectFrame.__init__(self)
        self.group_size = 9
        self.set_shadow_type(Gtk.ShadowType.NONE)
        self.activity = activity
        self.table = Gtk.Table(rows = self.group_size, columns = self.group_size, homogeneous = True)
        self.__entries__ = {}
        for x in range(self.group_size):
            for y in range(self.group_size):
                e = SudokuNumberBox(upper = self.group_size)
                e.x = x
                e.y = y
                self.table.attach(e, x, x+1, y, y+1,
                                  )
                self.__entries__[(x, y)] = e

        self.eb = Gtk.EventBox()
        self.eb.add(self.table)
        self.add(self.eb)
        self.table.set_row_spacings(1)
        self.table.set_col_spacings(1)
        box_side = int(math.sqrt(self.group_size))
        for n in range(1, box_side):
            self.table.set_row_spacing(box_side*n-1, 2)
            self.table.set_col_spacing(box_side*n-1, 2)
        self.table.set_border_width(2)

    def write_file(self, path):
        pass

    def read_file(self, path):
        pass


    def new(self):
        pass