diff options
author | Gonzalo Odiard <godiard@gmail.com> | 2014-07-21 15:42:43 (GMT) |
---|---|---|
committer | Gonzalo Odiard <godiard@gmail.com> | 2014-07-21 15:42:43 (GMT) |
commit | 62e694366d09cdbd591bf2818b00315dcbee62a1 (patch) | |
tree | f715b6522ee0cd8336cfbb6f84444ede8e2cc7a3 | |
parent | ca7c9d937c267301d06b183b2d81f429335a29c4 (diff) |
When the game reset due to screen rotate, reset scoreboad
-rw-r--r-- | scoreboard.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/scoreboard.py b/scoreboard.py index f381378..9882ad2 100644 --- a/scoreboard.py +++ b/scoreboard.py @@ -25,6 +25,8 @@ class Scoreboard(Gtk.EventBox): def __init__(self): Gtk.EventBox.__init__(self) self.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse('#666666')) + self.connect('size-allocate', self._allocate_cb) + self._width = self.get_allocation().width self.players = {} self.current_buddy = None self.hbox = Gtk.HBox(False) @@ -33,6 +35,12 @@ class Scoreboard(Gtk.EventBox): self.add(self.hbox) self.show_all() + def _allocate_cb(self, widget, allocation): + # check if the width changes (when the screen rotates + if allocation.width != self._width: + self._width = allocation.width + self.reset(widget) + def change_game(self, widget, data, grid): for buddy in self.players.keys(): self.players[buddy].change_game(len(grid)) |