Exemple #1
0
 def set_mode(self, size, buffered=True, *args, **kwargs):
     """
     Setup the display Surface.
     Argument include size (x,y) of surface and optional buffered surface.
     Return a reference to the display Surface.
     """
     self.canvas = Canvas(size, buffered)
     env.set_env('canvas', self.canvas)
     self.frame = document.body
     env.set_env('frame', self.frame)
     panel = RootPanel()
     panel.add(self.canvas)
     self.panel = panel
     self.vpanel = None
     self.textbox = None
     self.textarea = None
     self.Textbox = Textbox
     self.Textarea = Textarea
     self.surface = self.canvas.surface
     self.surface._display = self
     self._surface_rect = self.surface.get_rect()
     if not self.canvas._bufferedimage:
         self.flip = lambda: None
         self.update = lambda *arg: None
     return self.surface
Exemple #2
0
 def set_panel(self, id):
     """
     Set panel.
     Argument id is the dom element id. App default id is '__panel__'.
     Call at app start to change default.
     """
     RootPanel._set_root_panel(id)
     return None
Exemple #3
0
 def set_mode(self, size, buffered=True, *args, **kwargs):
     """
     Setup the display Surface.
     Argument include size (x,y) of surface and optional buffered surface.
     Return a reference to the display Surface.
     """
     self.canvas = Canvas(size, buffered)
     env.canvas = self.canvas
     self.frame = Window.getDocumentRoot()
     env.frame = self.frame
     panel = FocusPanel(Widget=self.canvas)
     RootPanel().add(panel)
     self.panel = panel
     self.vpanel = None
     self.textbox = None
     self.textarea = None
     self.Textbox = Textbox
     self.Textarea = Textarea
     self.surface = self.canvas.surface
     self.surface._display = self
     self._surface_rect = self.surface.get_rect()
     if not self.canvas._bufferedimage:
         self.flip = lambda: None
         self.update = lambda *arg: None
     return self.surface
Exemple #4
0
 def get_vpanel(self):
     """
     Return VerticalPanel positioned under Panel holding Canvas.
     """
     if not self.vpanel:
         self.vpanel = VerticalPanel()
         RootPanel().add(self.vpanel)
     return self.vpanel
Exemple #5
0
 def __init__(self, size=None, panel=None):
     TextBox.__init__(self)
     if not size:
         self.width, self.height = env.canvas.surface.width - 5, 20
     else:
         self.width, self.height = int(size[0]), int(size[1])
     self.setSize(str(self.width) + 'px', str(self.height) + 'px')
     self.setVisible(False)
     if panel:
         panel.add(self)
     else:
         try:
             env.canvas.surface._display.vpanel.add(self)
         except (TypeError, AttributeError):
             env.canvas.surface._display.vpanel = VerticalPanel()
             RootPanel().add(env.canvas.surface._display.vpanel)
             env.canvas.surface._display.vpanel.add(self)
Exemple #6
0
 def __init__(self, size=None, panel=None):
     TextArea.__init__(self)
     if not size:
         self.width = env.canvas.surface.width - 5
         self.height = int(env.canvas.surface.height / 5) - 5
     else:
         self.width = int(size[0])
         self.height = int(size[1])
     self.setSize(str(self.width) + 'px', str(self.height) + 'px')
     self.setStyleAttribute({'resize': 'vertical'})
     self.setVisible(False)
     if panel:
         panel.add(self)
     else:
         try:
             env.canvas.surface._display.vpanel.add(self)
         except (TypeError, AttributeError):
             env.canvas.surface._display.vpanel = VerticalPanel()
             RootPanel().add(env.canvas.surface._display.vpanel)
             env.canvas.surface._display.vpanel.add(self)
Exemple #7
0
 def __init__(self, size=None, panel=None):
     TextArea.__init__(self)
     if size is None:
         self.width = '100%'
         self.height = str(int(env.canvas.surface.height / 2)) + 'px'
         self.setSize(self.width, self.height)
     else:
         self.width = int(size[0])
         self.height = int(size[1])
         self.setSize(str(self.width) + 'px', str(self.height) + 'px')
     self.setVisible(False)
     if panel:
         panel.add(self)
     else:
         if env.canvas.surface._display.vpanel is not None:
             env.canvas.surface._display.vpanel.add(self)
         else:
             panel = VerticalPanel()
             env.canvas.surface._display.vpanel = panel
             panel._element.style.width = str(env.canvas.surface.width -
                                              2) + 'px'
             RootPanel().add(panel)
             panel.add(self)