From 3ceb14f88491ae7b54e42deae63d2ceafb390399 Mon Sep 17 00:00:00 2001 From: erilyth Date: Tue, 22 Dec 2015 15:12:15 +0530 Subject: [PATCH] et value of "ph" to 0 if division by zero takes place --- src/sugar3/graphics/palettewindow.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/sugar3/graphics/palettewindow.py b/src/sugar3/graphics/palettewindow.py index 62d34ebf..c9cd6b7f 100644 --- a/src/sugar3/graphics/palettewindow.py +++ b/src/sugar3/graphics/palettewindow.py @@ -970,15 +970,19 @@ class Invoker(GObject.GObject): dright = screen_area.x + screen_area.width - rect.x - rect.width ih = 0 + + if palette_dim.width == 0: + ph = 0 - # Set palette_halign to align to screen on left - if dleft > dright: - ph = -float(dleft) / palette_dim.width - - # Set palette_halign to align to screen on right else: - ph = -float(palette_dim.width - dright - rect.width) \ - / palette_dim.width + # Set palette_halign to align to screen on left + if dleft > dright: + ph = -float(dleft) / palette_dim.width + + # Set palette_halign to align to screen on right + else: + ph = -float(palette_dim.width - dright - rect.width) \ + / palette_dim.width return (ph, pv, ih, iv)