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

Source Code for Module muntjac.ui.native_button

 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 switch button with native styling.""" 
17   
18  from muntjac.ui.button import Button, IClickListener 
19  from muntjac.data.property import IProperty 
20   
21   
22 -class NativeButton(Button):
23 24 CLIENT_WIDGET = None #ClientWidget(VNativeButton) 25
26 - def __init__(self, *args):
27 """Creates a new switch button. 28 29 @param args: tuple of the form 30 - () 31 - (caption) 32 - (state, initialState) 33 1. the Initial state of the switch-button. 34 2. 35 - (state, dataSource) 36 1. the initial state of the switch-button. 37 2. boolean property 38 39 @deprecated: use the L{CheckBox} component instead 40 """ 41 nargs = len(args) 42 if nargs == 0: 43 super(NativeButton, self).__init__() 44 elif nargs == 1: 45 caption, = args 46 super(NativeButton, self).__init__(caption) 47 elif nargs == 2: 48 if isinstance(args[1], IClickListener): 49 caption, listener = args 50 super(NativeButton, self).__init__(caption, listener) 51 elif isinstance(args[1], IProperty): 52 caption, dataSource = args 53 super(NativeButton, self).__init__(caption, dataSource) 54 else: 55 caption, initialState = args 56 super(NativeButton, self).__init__(caption, initialState) 57 elif nargs == 3: 58 caption, target, methodName = args 59 super(NativeButton, self).__init__(caption, target, methodName) 60 else: 61 raise ValueError, 'too many arguments'
62