Package pyjamas :: Package ui
[hide private]
[frames] | no frames]

Source Code for Package pyjamas.ui

 1  # Copyright 2006 James Tauber and contributors 
 2  # Copyright 2009 Luke Kenneth Casson Leighton 
 3  # 
 4  # Licensed under the Apache License, Version 2.0 (the "License"); 
 5  # you may not use this file except in compliance with the License. 
 6  # You may obtain a copy of the License at 
 7  # 
 8  #     http://www.apache.org/licenses/LICENSE-2.0 
 9  # 
10  # Unless required by applicable law or agreed to in writing, software 
11  # distributed under the License is distributed on an "AS IS" BASIS, 
12  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
13  # See the License for the specific language governing permissions and 
14  # limitations under the License. 
15   
16  from pyjamas import DOM 
17   
18 -class HasHorizontalAlignment:
19 ALIGN_LEFT = "left" 20 ALIGN_CENTER = "center" 21 ALIGN_RIGHT = "right"
22
23 -class HasVerticalAlignment:
24 ALIGN_TOP = "top" 25 ALIGN_MIDDLE = "middle" 26 ALIGN_BOTTOM = "bottom"
27
28 -class HasAlignment:
29 ALIGN_BOTTOM = "bottom" 30 ALIGN_MIDDLE = "middle" 31 ALIGN_TOP = "top" 32 ALIGN_CENTER = "center" 33 ALIGN_LEFT = "left" 34 ALIGN_RIGHT = "right"
35
36 -class Applier(object):
37
38 - def __init__(self, **kwargs):
39 """ use this to apply properties as a dictionary, e.g. 40 x = klass(..., StyleName='class-name') 41 will do: 42 x = klass(...) 43 x.setStyleName('class-name') 44 45 and: 46 x = klass(..., Size=("100%", "20px"), Visible=False) 47 will do: 48 x = klass(...) 49 x.setSize("100%", "20px") 50 x.setVisible(False) 51 """ 52 if kwargs: 53 k = kwargs.keys() 54 l = len(k) 55 i = -1 56 while i < l-1: 57 i += 1 58 prop = k[i] 59 fn = getattr(self, "set%s" % prop, None) 60 if fn: 61 args = kwargs[prop] 62 if isinstance(args, tuple): 63 fn(*args) 64 else: 65 fn(args)
66 -class InnerHTML(object):
67
68 - def getHTML(self):
69 return DOM.getInnerHTML(self.getElement())
70
71 - def setHTML(self, html):
72 DOM.setInnerHTML(self.getElement(), html)
73
74 -class InnerText(object):
75
76 - def setText(self, text):
77 DOM.setInnerText(self.getElement(), text)
78
79 - def getText(self):
80 return DOM.getInnerText(self.getElement())
81