diff browser_side/panels.py @ 181:c0b78a3af06d

browser side: web widget first draft
author Goffi <goffi@goffi.org>
date Sun, 24 Feb 2013 18:15:38 +0100
parents 8475a29d7214
children 97d5e9de1106
line wrap: on
line diff
--- a/browser_side/panels.py	Sun Feb 24 15:58:19 2013 +0100
+++ b/browser_side/panels.py	Sun Feb 24 18:15:38 2013 +0100
@@ -28,8 +28,9 @@
 from pyjamas.ui.TabPanel import TabPanel
 from pyjamas.ui.HTMLPanel import HTMLPanel
 from pyjamas.ui.FlexTable import FlexTable
-from pyjamas.ui.Grid import Grid
+from pyjamas.ui.Frame import Frame
 from pyjamas.ui.TextArea import TextArea
+from pyjamas.ui.TextBox import TextBox
 from pyjamas.ui.Label import Label
 from pyjamas.ui.Button import Button
 from pyjamas.ui.HTML import HTML
@@ -663,7 +664,7 @@
         HTML.__init__(self, "<div class='occupant'>%s</div>" % html_sanitize(nick))
 
     def __str__(self):
-        return nick
+        return self.nick
 
 class OccupantsList(AbsolutePanel):
     """Panel user to show occupants of a room"""
@@ -818,6 +819,35 @@
         elif game_type=="RadioCol":
             return self.radiocol_panel 
 
+class WebPanel(LiberviaWidget):
+    """ (mini)browser like widget """
+    
+    def __init__(self, host, url=None):
+        """
+        @param host: SatWebFrontend instance
+        """
+        LiberviaWidget.__init__(self, host)
+        self._vpanel = VerticalPanel()
+        self._vpanel.setSize('100%', '20')
+        self._url = TextBox()
+        self._url.setText(url or "")
+        self._url.setWidth('100%')
+        hpanel = HorizontalPanel()
+        hpanel.add(self._url)
+        btn = Button("Go", self.onUrlClick)
+        hpanel.setCellWidth(self._url, "100%")
+        #self.setCellWidth(btn, "10%")
+        hpanel.add(self._url)
+        hpanel.add(btn)
+        self._vpanel.add(hpanel)
+        self._frame = Frame(url or "")
+        self._frame.setSize('100%', '100%')
+        self._vpanel.add(self._frame)
+        self.setWidget(self._vpanel)
+
+    def onUrlClick(self, sender):
+        self._frame.setUrl(self._url.getText())
+
 class WidgetsPanel(ScrollPanelWrapper):
     
     def __init__(self, host):