Package muntjac :: Package ui :: Module password_field
[hide private]
[frames] | no frames]

Source Code for Module muntjac.ui.password_field

 1  # Copyright (C) 2012 Vaadin Ltd.  
 2  # Copyright (C) 2012 Richard Lincoln 
 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  """Defines a field that is used to enter secret text information like 
17  passwords.""" 
18   
19  from muntjac.ui.abstract_text_field import AbstractTextField 
20  from muntjac.data.property import IProperty 
21   
22   
23 -class PasswordField(AbstractTextField):
24 """A field that is used to enter secret text information like passwords. 25 The entered text is not displayed on the screen. 26 """ 27 28 CLIENT_WIDGET = None #ClientWidget(VPasswordField, LoadStyle.EAGER) 29
30 - def __init__(self, *args):
31 """Constructs a PasswordField with caption and/or value/data source. 32 33 @param args: tuple of the form 34 - () 35 - (caption) 36 1. the caption for the field 37 - (dataSource) 38 1. the property data source for the field 39 - (caption, dataSource) 40 1. the caption for the field 41 2. the property data source for the field 42 - (caption, value) 43 1. the caption for the field 44 2. the value for the field 45 """ 46 super(PasswordField, self).__init__() 47 48 nargs = len(args) 49 if nargs == 0: 50 self.setValue('') 51 elif nargs == 1: 52 if isinstance(args[0], IProperty): 53 dataSource, = args 54 self.setPropertyDataSource(dataSource) 55 else: 56 caption, = args 57 PasswordField.__init__(self) 58 self.setCaption(caption) 59 elif nargs == 2: 60 if isinstance(args[1], IProperty): 61 caption, dataSource = args 62 PasswordField.__init__(self, dataSource) 63 self.setCaption(caption) 64 else: 65 caption, value = args 66 self.setValue(value) 67 self.setCaption(caption) 68 else: 69 raise ValueError, 'too many arguments'
70