Mercurial > libervia-web
diff browser_side/panels.py @ 23:0ce2a57b34ca
added tab panel
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 20 Apr 2011 02:47:22 +0200 |
parents | 586f69e85559 |
children | d89982865c57 |
line wrap: on
line diff
--- a/browser_side/panels.py Sun Apr 17 00:38:33 2011 +0200 +++ b/browser_side/panels.py Wed Apr 20 02:47:22 2011 +0200 @@ -24,6 +24,7 @@ from pyjamas.ui.VerticalPanel import VerticalPanel from pyjamas.ui.HorizontalPanel import HorizontalPanel from pyjamas.ui.ScrollPanel import ScrollPanel +from pyjamas.ui.TabPanel import TabPanel from pyjamas.ui.HTMLPanel import HTMLPanel from pyjamas.ui.Grid import Grid from pyjamas.ui.MenuBar import MenuBar @@ -53,7 +54,8 @@ class Menu(SimplePanel): - def __init__(self): + def __init__(self, host): + self.host = host SimplePanel.__init__(self) menu_general = MenuBar(vertical=True) @@ -72,7 +74,8 @@ Window.alert("Properties selected") def onTarotGame(self): - Window.alert("Tarot selected") + #Window.alert("Tarot selected") + self.host.tab_panel.add(EmptyPanel(self.host), "Tarot") def onXiangqiGame(self): Window.alert("Xiangqi selected") @@ -298,7 +301,7 @@ return""" self.content.add(ChatText(timestamp, nick, mymess, msg)) -class MiddlePannel(HorizontalPanel): +class MainDiscussionPannel(HorizontalPanel): def __init__(self, host): self.host=host @@ -316,6 +319,18 @@ def changePanel(self, idx, panel): self._right.setWidget(0,idx,panel) +class MainTabPannel(TabPanel): + + def __init__(self, host): + self.host=host + TabPanel.__init__(self) + self.tabBar.setVisible(False) + + def add(self, widget, tabText=None, asHTML=False): + TabPanel.add(self, widget, tabText, asHTML) + if self.getWidgetCount()>1: + self.tabBar.setVisible(True) + class MainPanel(VerticalPanel): def __init__(self, host): @@ -325,23 +340,29 @@ self.setHorizontalAlignment(HasAlignment.ALIGN_LEFT) self.setVerticalAlignment(HasAlignment.ALIGN_TOP) - menu = Menu() + menu = Menu(host) uni_box = host.uniBox status = host.statusPanel - self.middle_panel = MiddlePannel(self.host) - self.middle_panel.setWidth('100%') + self.tab_panel = MainTabPannel(self) + self.tab_panel.setWidth('100%') + self.tab_panel.setHeight('100%') + self.discuss_panel = MainDiscussionPannel(self.host) + self.discuss_panel.setWidth('100%') + self.discuss_panel.setHeight('100%') + self.tab_panel.add(self.discuss_panel, "Discussions") + self.tab_panel.selectTab(0) self.add(menu) self.add(uni_box) self.add(status) - self.add(self.middle_panel) + self.add(self.tab_panel) self.setCellHeight(menu, "5%") self.setCellHeight(uni_box, "5%") self.setCellVerticalAlignment(uni_box, HasAlignment.ALIGN_CENTER) self.setCellHorizontalAlignment(uni_box, HasAlignment.ALIGN_CENTER) - self.setCellHeight(self.middle_panel, "90%") - self.setCellWidth(self.middle_panel, "100%") + self.setCellHeight(self.tab_panel, "90%") + self.setCellWidth(self.tab_panel, "100%") self.setWidth("100%") self.setHeight("100%")