コード例 #1
0
    def set_all_data(self, data):
        self.difficulty = data["difficulty"]
        self.clear()

        self.level = data["level"]
        columns = get_columns_for_difficulty(self.difficulty)

        for x in range(0, columns):
            for y in range(0, 10):
                ballid = data["balls"][x][y]
                ball = BallBox()
                ball.set_ball(ballid)
                self.attach(ball, x, 9 - y, 1, 1)
                self.balls[x][y] = ball

        self.set_drag_level()

        for i in range(0, 10):
            box = ResultBox()
            self.attach(box, columns, 9 - i, 1, 1)
            self.result_boxes.append(box)

            if i < self.level:
                user = []
                for x in range(0, columns):
                    user.append(data["balls"][x][i])

                box.set_data(data["correct"], user)

        self.show_all()
コード例 #2
0
    def reset(self, difficulty=None):
        if difficulty is not None:
            self.difficulty = difficulty

        self.clear()

        x = -1
        y = 0

        columns = get_columns_for_difficulty(self.difficulty)

        for i in range(0, columns * 10):
            x += 1

            if x >= columns:
                x = 0
                y += 1

            box = BallBox()
            self.attach(box, x, y, 1, 1)

            self.balls[x][9 - y] = box

        for i in range(0, 10):
            box = ResultBox(columns)
            self.attach(box, columns, 9 - i, 1, 1)
            self.result_boxes.append(box)

        self.set_drag_level()
        self.show_all()
コード例 #3
0
    def reset(self):
        self.clear()

        x = -1
        y = 0

        for i in range(0, 40):
            x += 1

            if x >= 4:
                x = 0
                y += 1

            box = BallBox()
            self.attach(box, x, y, 1, 1)

            self.balls[x][9 - y] = box

        for i in range(0, 10):
            box = ResultBox()
            self.attach(box, 4, 9 - i, 1, 1)
            self.result_boxes.append(box)

        self.set_drag_level()
        self.show_all()
コード例 #4
0
    def reset(self, difficulty=Difficulty.MEDIUM):
        if difficulty != self.difficulty:
            self.difficulty = difficulty
            self.clear()

            for x in range(0, get_colors_for_difficulty(difficulty)):
                ball = BallBox.new_from_id(x, False, True)
                ball.set_draggable(True)
                self.attach(ball, x + 1, 0, 1, 1)

                idx = ball.connect("id-changed", self._id_changed_cb)
                self.callback_ids[idx] = ball

                self.balls.append(ball)

            self.show_all()

        else:
            for ball in self.balls:
                ball.set_draggable(True)
コード例 #5
0
    def __init__(self):
        Gtk.Grid.__init__(self)

        self.balls = []
        self.callback_ids = {}

        self.set_margin_top(10)
        self.set_margin_bottom(10)
        self.set_column_spacing(5)

        self.eraser_ball = EraserBallBox()
        self.attach(self.eraser_ball, 0, 0, 1, 1)

        for x in range(0, 8):
            ball = BallBox.new_from_id(x, False, True)
            ball.set_draggable(True)
            self.attach(ball, x + 1, 0, 1, 1)

            idx = ball.connect("id-changed", self._id_changed_cb)
            self.callback_ids[idx] = ball

            self.balls.append(ball)

        self.show_all()