<s> import calendar <EOL> import datetime <EOL> import os <EOL> import time <EOL> from ajenti . api import * <EOL> from ajenti . ui import p , UIElement , on <EOL> @ p ( '<STR_LIT:value>' , default = '<STR_LIT>' , bindtypes = [ str , unicode , int , long ] ) <EOL> @ p ( '<STR_LIT>' , type = bool , default = False ) <EOL> @ p ( '<STR_LIT:type>' , default = '<STR_LIT:text>' ) <EOL> @ plugin <EOL> class TextBox ( UIElement ) : <EOL> typeid = '<STR_LIT>' <EOL> @ p ( '<STR_LIT:value>' , default = '<STR_LIT>' , bindtypes = [ str , unicode , int , long ] ) <EOL> @ plugin <EOL> class PasswordBox ( UIElement ) : <EOL> typeid = '<STR_LIT>' <EOL> @ p ( '<STR_LIT:value>' , default = '<STR_LIT>' , type = int , bindtypes = [ str , unicode , int , long ] ) <EOL> @ plugin <EOL> class DateTime ( UIElement ) : <EOL> typeid = '<STR_LIT>' <EOL> @ property <EOL> def dateobject ( self ) : <EOL> if self . value : <EOL> return datetime . fromtimestamp ( self . value ) <EOL> @ dateobject . setter <EOL> def dateobject__set ( self , value ) : <EOL> if value : <EOL> self . value = calendar . timegm ( value . timetuple ( ) ) <EOL> else : <EOL> self . value = None <EOL> @ p ( '<STR_LIT:value>' , default = '<STR_LIT>' , bindtypes = [ str , unicode ] ) <EOL> @ p ( '<STR_LIT>' , default = None ) <EOL> @ p ( '<STR_LIT>' , default = None ) <EOL> @ plugin <EOL> class Editable ( UIElement ) : <EOL> typeid = '<STR_LIT>' <EOL> @ p ( '<STR_LIT:text>' , default = '<STR_LIT>' ) <EOL> @ p ( '<STR_LIT:value>' , default = False , bindtypes = [ bool ] ) <EOL> @ plugin <EOL> class CheckBox ( UIElement ) : <EOL> typeid = '<STR_LIT>' <EOL> @ p ( '<STR_LIT>' , default = [ ] , type = list ) <EOL> @ p ( '<STR_LIT>' , default = [ ] , type = list , public = False ) <EOL> @ p ( '<STR_LIT:value>' , bindtypes = [ object ] , public = False ) <EOL> @ p ( '<STR_LIT:index>' , default = <NUM_LIT:0> , type = int ) <EOL> @ p ( '<STR_LIT>' , default = False , type = bool ) <EOL> @ p ( '<STR_LIT>' , default = False , type = bool ) <EOL> @ plugin <EOL> class Dropdown ( UIElement ) : <EOL> typeid = '<STR_LIT>' <EOL> def value_get ( self ) : <EOL> if self . index < len ( self . values ) : <EOL> try : <EOL> return self . values [ self . index ] <EOL> except TypeError : <EOL> return None <EOL> return None <EOL> def value_set ( self , value ) : <EOL> if value in self . values : <EOL> self . index = self . values . index ( value ) <EOL> else : <EOL> self . index = <NUM_LIT:0> <EOL> value = property ( value_get , value_set ) <EOL> @ p ( '<STR_LIT>' , default = [ ] , type = list ) <EOL> @ p ( '<STR_LIT>' , default = [ ] , type = list ) <EOL> @ p ( '<STR_LIT>' , default = None , type = str ) <EOL> @ p ( '<STR_LIT:value>' , default = '<STR_LIT>' , bindtypes = [ str , unicode ] ) <EOL> @ plugin <EOL> class Combobox ( UIElement ) : <EOL> typeid = '<STR_LIT>' <EOL> @ p ( '<STR_LIT:target>' , type = str ) <EOL> @ plugin <EOL> class FileUpload ( UIElement ) : <EOL> typeid = '<STR_LIT>' <EOL> @ p ( '<STR_LIT>' , type = int ) <EOL> @ p ( '<STR_LIT>' , type = int ) <EOL> @ plugin <EOL> class Paging ( UIElement ) : <EOL> typeid = '<STR_LIT>' <EOL> @ p ( '<STR_LIT:value>' , default = '<STR_LIT>' , bindtypes = [ str , unicode ] ) <EOL> @ p ( '<STR_LIT>' , default = False , type = bool ) <EOL> @ p ( '<STR_LIT:type>' , default = '<STR_LIT:text>' ) <EOL> @ plugin <EOL> class Pathbox ( UIElement ) : <EOL> typeid = '<STR_LIT>' <EOL> def init ( self , * args , ** kwargs ) : <EOL> if self . directory : <EOL> self . dialog = self . ui . create ( '<STR_LIT>' ) <EOL> else : <EOL> self . dialog = self . ui . create ( '<STR_LIT>' ) <EOL> self . append ( self . dialog ) <EOL> self . dialog . id = '<STR_LIT>' <EOL> self . dialog . visible = False <EOL> def on_start ( self ) : <EOL> self . find ( '<STR_LIT>' ) . navigate ( os . path . split ( self . value or '<STR_LIT>' ) [ <NUM_LIT:0> ] or '<STR_LIT:/>' ) <EOL> self . find ( '<STR_LIT>' ) . visible = True <EOL> @ on ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def on_select ( self , path = None ) : <EOL> self . find ( '<STR_LIT>' ) . visible = False <EOL> if path : <EOL> self . value = path </s>
