sugar-toolkit-gtk3/shell/view/home/IconLayout.py

25 lines
526 B
Python
Raw Normal View History

import random
class IconLayout:
2006-09-24 22:55:13 +02:00
def __init__(self, grid):
self._icons = []
2006-09-24 22:55:13 +02:00
self._grid = grid
def add_icon(self, icon):
self._icons.append(icon)
self._layout_icon(icon)
def remove_icon(self, icon):
self._icons.remove(icon)
def _layout_icon(self, icon):
2006-09-24 22:55:13 +02:00
[x1, y1] = self._grid.convert_to_canvas(1, 1)
[x2, y2] = self._grid.convert_to_canvas(78, 59)
size = icon.props.size
x = random.random() * (x2 - x1 - size)
y = random.random() * (y2 - y1 - size)
2006-09-24 22:55:13 +02:00
icon.props.x = x + x1
icon.props.y = y + y1