AlkantarClanX12

Your IP : 3.142.40.195


Current Path : /usr/lib64/python3.6/site-packages/__pycache__/
Upload File :
Current File : //usr/lib64/python3.6/site-packages/__pycache__/snack.cpython-36.pyc

3

��^�y�@sdZddlmZmZmZddlZddlZddlZddlmZm	Z	m
Z
mZmZm
Z
mZdFZdIZdJZdKZdLZddMiZGdd�d�ZGd	d
�d
e�ZGdd�de�ZGd
d�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Zej ej!ej"ej#ej$ej%ej&ej'ej(ej)ej*ej+ej,ej-ej.ej/ej0ej1ej2e3d�d�Z4x"e5e4j6��D]Z7e7e4e4e7<�q�Wx4dd �ej8ej9D�D]\Z:Z;e:e4e;<e;e4e:<�q�WGd!d"�d"�Z<Gd#d$�d$�Z=ej>ej?ej@ejAejBejCejDejEejFejGejHejIejJejKejLejMejNejOejPejQejRejSejTd%�ZUGd&d'�d'�ZVdNd)d*�ZWGd+d,�d,e�ZXGd-d.�d.e=�ZYGd/d0�d0e=�ZZGd1d2�d2e=�Z[Gd3d4�d4e[�Z\Gd5d6�d6e�Z]dQd:d;�Z^d7d8gd9dddfd<d=�Z_dd9d>d7d8gdfd?d@�Z`GdAdB�dBe=�ZadCdD�ZbdS)Ra�
This module provides the NEWT Windowing toolkit API for Python
This is a lightweight text-mode windowing library, based on slang.

Classes:

 - Widget  
 - Button  
 - CompactButton
 - Checkbox
 - SingleRadioButton
 - Listbox
 - Textbox
 - TextboxReflowed
 - Label
 - Scale
 - Entry
 - Form
 - Grid
 - SnackScreen
 - RadioGroup
 - RadioBar
 - ButtonBar
 - GridFormHelp
 - GridForm
 - CheckboxTree
 - Clistbox

Functions:

 - ListboxChoiceWindow
 - ButtonChoiceWindow
 - EntryWindow
�)�absolute_import�print_function�unicode_literalsN)�
FLAG_DISABLED�	FLAGS_SET�FLAGS_RESET�FLAGS_TOGGLE�FD_READ�FD_WRITE�	FD_EXCEPT��appendc@s"eZdZdZddd�Zdd�ZdS)�Widgetz�Base class for NEWT toolkit - Do not use directly

    methods:

     - Widget(self)
     - setCallback(self, obj, data = None) : 
          The callback for when object activated.
          data is passed to obj.
    NcCs$|r|jj||�n|jj|�dS)N)�w�setCallback)�self�obj�data�r�/usr/lib64/python3.6/snack.pyrDszWidget.setCallbackcCst�dS)N)�NotImplementedError)rrrr�__init__JszWidget.__init__)N)�__name__�
__module__�__qualname__�__doc__rrrrrrr:s	
rc@seZdZdZdd�ZdS)�ButtonzqBasic button class, takes button text as parameter

    method:

     - Button(self, text): returns a button
    cCstj|�|_dS)N)�_snack�buttonr)r�textrrrrTszButton.__init__N)rrrrrrrrrrMsrc@seZdZdZdd�ZdS)�
CompactButtonz�Compact Button class (less frilly button decoration).

    methods:

     - CompactButton(self,text) : create button, with text.
    cCstj|�|_dS)N)rZ
compactbuttonr)rrrrrr^szCompactButton.__init__N)rrrrrrrrrr Wsr c@s:eZdZdZdd�Zdd�Zdd�Zdd	�Zddd�Zd
S)�Checkboxa�A checkbox.

    methods:
    
      - Checkbox(self, text, isOn = 0) : text, and boolean as to default value
      - setValue(self)                 : set value
      - value(self, value)             : return checkbox value
      - selected(self)                 : returns boolean
      - setFlags(self, flag, sense)    : set flags

      flags:  FLAG_DISABLED, FLAGS_SET, FLAGS_RESET
    cCs|jjS)N)r�
checkboxValue)rrrr�valuenszCheckbox.valuecCs|jjdkS)Nr)rr")rrrr�selectedqszCheckbox.selectedcCs|jj||�S)N)rZcheckboxSetFlags)r�flag�senserrr�setFlagstszCheckbox.setFlagscCs|jj|�S)N)rZcheckboxSetValue)rr#rrr�setValuexszCheckbox.setValuercCstj||�|_dS)N)rZcheckboxr)rr�isOnrrrr{szCheckbox.__init__N)r)	rrrrr#r$r'r(rrrrrr!asr!c@s"eZdZdZdd�Zddd�ZdS)	�SingleRadioButtonz�Single Radio Button.

    methods:
    
     -  SingleRadioButton(text, group, isOn = 0)  : create button
     -  selected(self)                            : returns bool, whether or not is selected.
    cCs|jj|jjkS)N)r�keyZ
radioValue)rrrrr$�szSingleRadioButton.selectedrcCs,|rtj||j|�|_ntj|d|�|_dS)N)rZradiobuttonr)rr�groupr)rrrr�szSingleRadioButton.__init__N)r)rrrrr$rrrrrr*~sr*c@sZeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zddd�ZdS)�Listboxa�Listbox class.

    methods:

     - Listbox(self, height, scroll = 0, returnExit = 0, width = 0, showCursor = 0, multiple = 0, border = 0)
     - insert(self, text, item, before) : insert element; before = key to item to insert before, or None.
     - delete(self, item)               : delete item from list.
     - replace(self, text,item)         : Replace a given item's text
     - current(self)                    : returns currently selected item
     - getSelection(self)               : returns a list of selected items
     - setCurrent(self,i tem)           : select current.
     - clear(self)                      : clear listbox
    cCs$|jj|�}||j|<||j|<dS)N)rZlistboxAddItem�key2item�item2key)rr�itemr+rrrr
�s
zListbox.appendcCs@|s|jj|d�}n|jj||j|�}||j|<||j|<dS)Nr)r�listboxInsertItemr/r.)rrr0�beforer+rrr�insert�s

zListbox.insertcCs,|jj|j|�|j|j|=|j|=dS)N)r�listboxDeleteItemr/r.)rr0rrr�delete�szListbox.deletecCsL|jj||j|�}|jj|j|�|j|j|=||j|<||j|<dS)N)rr1r/r4r.)rrr0r+rrr�replace�s

zListbox.replacecCs|j|jj�S)N)r.rZlistboxGetCurrent)rrrr�current�szListbox.currentcCs0g}|jj�}x|D]}|j|j|�qW|S)N)rZlistboxGetSelectionr
r.)r�	selection�listr+rrr�getSelection�s


zListbox.getSelectioncCs|jj|j|�dS)N)rZlistboxSetCurrentr/)rr0rrr�
setCurrent�szListbox.setCurrentcCsi|_i|_|jj�dS)N)r.r/rZlistboxClear)rrrr�clear�sz
Listbox.clearrcCs6tj||||||�|_i|_i|_|r2|jj|�dS)N)r�listboxrr.r/ZlistboxSetWidth)r�height�scroll�
returnExit�widthZ
showCursorZmultipleZborderrrrr�s
zListbox.__init__N)rrrrrr)
rrrrr
r3r5r6r7r:r;r<rrrrrr-�s
r-c@s*eZdZdZdd�Zdd�Zd
dd�Zd	S)�TextboxaTextbox, container for text.

    methods:

     - Textbox(self, width, height, scroll = 0, wrap = 0): scroll, wrap are flags
                                   include scroll bars, or text wrap.
     - setText(text) : set text.
     - setHeight(height): set height.
    cCs|jj|�dS)N)rZtextboxText)rrrrr�setText�szTextbox.setTextcCs|jj|�dS)N)rZ
textboxHeight)rr>rrr�	setHeight�szTextbox.setHeightrcCstj|||||�|_dS)N)rZtextboxr)rrAr>rr?Zwraprrrr�szTextbox.__init__N)rr)rrrrrCrDrrrrrrB�s	rBc@seZdZddd�ZdS)	�TextboxReflowed��
rcCsNt||||�\}}}|dkr8||kr8tj||||d�ntj||||d�dS)Nrr���)�reflowrBr)rrAr�flexDown�flexUp�	maxHeightZnewtextr>rrrr�szTextboxReflowed.__init__NrH)rFrGrH)rrrrrrrrrE�srEc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�Labelz�A Label (simple text).

    methods:

     - Label(self,text)   : create label
     - setText(self,text) : change text.
     - setColors(self, colorset) : change individual colors
    cCs|jj|�dS)N)rZ	labelText)rrrrrrC�sz
Label.setTextcCstj|�|_dS)N)r�labelr)rrrrrr�szLabel.__init__cCs|jj|�dS)N)rZlabelSetColors)r�colorsetrrr�	setColors�szLabel.setColorsN)rrrrrCrrPrrrrrM�srMc@s eZdZdZdd�Zdd�ZdS)�Scalez�A Scale (progress bar).

    methods:

     - Scale(self,width, total) : create scale; width: size on screen, fullamount: integer.
     - set(self,amount)         : set amount to integer.
    cCs|jj|�dS)N)rZscaleSet)rZamountrrr�setsz	Scale.setcCstj||�|_dS)N)rZscaler)rrAZtotalrrrrszScale.__init__N)rrrrrRrrrrrrQsrQc@s4eZdZdZdd�Zddd�Zdd�Zddd�Zd
S)�EntryaEntry widget.

    methods:

     - Entry(self, width, text = "", hidden = 0, password = 0, scroll = 1, returnExit = 0)
          constructor. hidden doesn't show text, password stars it out,
          scroll includes scroll bars;
          if returnExit is set, return from Form when exiting this element, else
           proceed to next entry widget.
     - value(self): return value.
     - set(text, cursorAtEnd = 1) : set the text
     - setFlags (flag, sense) : flags can be FLAG_DISABLED, FLAGS_SET, FLAGS_RESET, FLAGS_TOGGLE
    cCs|jjS)N)rZ
entryValue)rrrrr#szEntry.valuercCs|jj||�S)N)rZ
entrySetValue)rrZcursorAtEndrrrrRsz	Entry.setcCs|jj||�S)N)rZ
entrySetFlags)rr%r&rrrr'"szEntry.setFlags�rcCstj||||||�|_dS)N)r�entryr)rrArZhiddenZpasswordr?r@rrrr%szEntry.__init__N)r)rTrrrr)rrrrr#rRr'rrrrrrSs

rS� )ZF1ZF2ZF3ZF4ZF5ZF6ZF7ZF8ZF9ZF10ZF11ZF12ZESCZENTERZSUSPENDZ	BACKSPACEZDELETEZINSERTZRESIZErVcCsg|]}t|�|f�qSr)�ord)�.0�crrr�
<listcomp>7srZc@sReZdZdZdd�Zdd�Zdd�Zdd	�Zddd�Zd
d�Z	dd�Z
dd�Zd
S)�Forma� Base Form class, from which Grid, etc. inherit

    methods:

     - Form(self, helpArg = None) : constructor. 
     - addHotKey(self, keyname) : keynames of form "F1" through "F12", "ESC"
     - add(self, widget) : Add a widget
     - run(self): run a  form, expecting input
     - draw(self): draw form.
     - setTimer(self, timer) : add a timer
     - watchFile(self, file, flags) : watch a named file
     - setCurrent (self, co): Set a given widget as the current focus
    cCs|jjt|�dS)N)rZ	addhotkey�hotkeys)r�keynamerrr�	addHotKeyIszForm.addHotKeycCsxd|jkr(x|jj�D]}|j|�qWd|jkrNx@|jD]}|j|�q:Wn&d|jkrt||j|jj<|jj|j�SdS)Nr\�gridmembersr)	�__dict__r\�keysr^r_�add�transrr+)r�widgetr+rrrrrbLs


zForm.addcCsb|jj�\}}|tjkr"|j|S|tjkr0dS|tjkrD|j|S|tjkrVt	|St
d��dS)NZTIMERzEOF or IO error)r�runrZFORM_EXIT_WIDGETrcZFORM_EXIT_TIMERZFORM_EXIT_FDREADY�filemapZFORM_EXIT_HOTKEYr\�RuntimeError)r�whatZwhichrrrreYs





zForm.runcCs|jj�dS)N)r�draw)rrrrries
z	Form.drawNcCs"i|_i|_tj|�|_||_dS)N)rcrfr�formr�helpArg)rrkrrrrisz
Form.__init__cCs|jj|j�dS)N)rZ
setcurrent)r�corrrr;pszForm.setCurrentcCs|jj|�dS)N)rZsettimer)rZtimerrrr�setTimerssz
Form.setTimercCs$||j|j�<|jj|j�|�dS)N)rf�filenorZwatchfd)r�file�flagsrrr�	watchFilevszForm.watchFile)N)rrrrr^rbrerirr;rmrqrrrrr[;s


r[c@s*eZdZdZdd�Zddd�Zdd�Zd	S)�GridayGrid class.

    methods:

     - place(self,x,y): Return what is placed at (x,y)
     - setField(self, what, col, row, padding = (0, 0, 0, 0),
                anchorLeft = 0, anchorTop = 0, anchorRight = 0,
                anchorBottom = 0, growx = 0, growy = 0):
                used to add widget 'what' to grid.
     - Grid(self, *args): eg. g = Grid(2,3) for 2x3 grid
    cCs|jj||�S)N)�g�place)r�x�yrrrrt�sz
Grid.placerc
Cs�|jj|�d}|rtj}n
|r&tj}|r6|tjB}n|rD|tjB}d}|	rRtj}|
r`|tjB}d|j	kr�|j
j|||j
|||�S|j
j|||j||�SdS)Nrrs)
r_r
rZANCHOR_LEFTZANCHOR_RIGHTZ
ANCHOR_TOPZ
ANCHOR_BOTTOMZ
GRID_GROWXZ
GRID_GROWYr`rsZsetfieldr)
rrh�col�row�padding�
anchorLeft�	anchorTop�anchorRight�anchorBottom�growx�growyZanchorFlagsZ	gridFlagsrrr�setField�s&


z
Grid.setFieldcGstj|�|_g|_dS)N)r�gridrsr_)r�argsrrrr�sz
Grid.__init__N�rrrr)r�rrrrrr)rrrrrtr�rrrrrrrzs
rr)ZROOTZBORDERZWINDOWZSHADOWZTITLEZBUTTONZ	ACTBUTTONZCHECKBOXZACTCHECKBOXZENTRYZLABELZLISTBOXZ
ACTLISTBOXZTEXTBOXZ
ACTTEXTBOXZHELPLINEZROOTTEXTZ
EMPTYSCALEZ	FULLSCALEZDISENTRYZ
COMPACTBUTTONZ
ACTSELLISTBOXZ
SELLISTBOXc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	d$dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zd%dd�Zd&dd�Zd d!�Zd"d#�ZdS)'�SnackScreena
A Screen;

    methods:

    - Screen(self) : constructor
    - finish(self)
    - resume(self)
    - suspend(self)
    - doHelpCallback(self,arg) call callback with arg
    - helpCallback(self,cb): Set help callback
    - suspendcallback(self,cb, data=None) : set callback. data=data to pass to cb.
    - openWindow(self,left, top, width, height, title): Open a window.
    - pushHelpLine(self,text): put help line on screen. Returns current help line if text=None
    - setColor(self, colorset, fg, bg): Set foreground and background colors;
            colorset = key from snack.colorsets,
            fg & bg = english color names defined by S-Lang
                (ref: S-Lang Library C Programmer's Guide section:
                8.4.4.  Setting Character Attributes)
    cCs&tj�tj�\|_|_|jd�dS)N)rZinit�sizerAr>�pushHelpLine)rrrrr�szSnackScreen.__init__cCstj�S)N)r�finish)rrrrr��szSnackScreen.finishcCstj�dS)N)r�resume)rrrrr��szSnackScreen.resumecCstj�dS)N)r�suspend)rrrrr��szSnackScreen.suspendcCs|j||�dS)N)�helpCb)r�argrrr�doHelpCallback�szSnackScreen.doHelpCallbackcCs||_tj|j�S)N)r�rZhelpcallbackr�)r�cbrrr�helpCallback�szSnackScreen.helpCallbackNcCs|rtj||�Stj|�S)N)rZsuspendcallback)rr�rrrr�suspendCallback�szSnackScreen.suspendCallbackcCstj|||||�S)N)rZ
openwindow)r�left�toprAr>�titlerrr�
openWindow�szSnackScreen.openWindowcCs|stjd�Stj|�SdS)Nz	*default*)rZpushhelpline)rrrrrr��s
zSnackScreen.pushHelpLinecCstj�S)N)rZpophelpline)rrrr�popHelpLine�szSnackScreen.popHelpLinecCstj|||�S)N)rZdrawroottext)rr�r�rrrr�drawRootText�szSnackScreen.drawRootTextcCstj|||�S)N)rZcenteredwindow)rrAr>r�rrr�centeredWindow�szSnackScreen.centeredWindowcCs(|r|rtj|j|||�Stj|j|�S)N)rZgridwrappedwindowrs)rr�r�rurvrrr�gridWrappedWindowszSnackScreen.gridWrappedWindowTcCs|rtj�Stj�S)N)rZ	popwindowZpopwindownorefresh)r�refreshrrr�	popWindowszSnackScreen.popWindowcCstj�S)N)rr�)rrrrr�szSnackScreen.refreshcCs,|tkrtjt|||�Stj|||�SdS)N)�	colorsetsrZsetcolor)rrOZfgZbgrrr�setColorszSnackScreen.setColor)N)NN)T)rrrrrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr��s"


r�rFcCstj||||�S)zR returns a tuple of the wrapped text, the actual width, and the actual height
    )rrI)rrArJrKrrrrIsrIc@s*eZdZdZdd�Zd	dd�Zdd�ZdS)
�
RadioGroupz� Combo widget: Group of Radio buttons

    methods:

     - RadioGroup(self): constructor.
     - add(self,title, value, default = None): add a button. Returns button.
     - getSelection(self) : returns value of selected button | None    
    cCsd|_g|_dS)N)�prev�
buttonlist)rrrrr%szRadioGroup.__init__NcCs<|jr|dkrd}t||j|�}||_|jj||f�|S)Nr)r�r*r�r
)rr�r#�default�brrrrb)szRadioGroup.addcCs$x|jD]\}}|j�r|SqWdS)N)r�r$)rr�r#rrrr:3szRadioGroup.getSelection)N)rrrrrrbr:rrrrr�s

r�c@s eZdZdZdd�Zdd�ZdS)�RadioBarz� Bar of Radio buttons, based on Grid.

    methods:

    - RadioBar(self, screen, buttonlist) : constructor.
    - getSelection(self): return value of selected button 
    cCs~g|_d|_t�|_tj|dt|��xR|D]J\}}}|jj|||�}|jj||f�|j	|d|jdd�|jd|_q,WdS)Nrr)rz)
r9r0r�r,rrr�lenrbr
r�)r�screenr�r�r#r�r�rrrrBszRadioBar.__init__cCs
|jj�S)N)r,r:)rrrrr:MszRadioBar.getSelectionN)rrrrrr:rrrrr�9sr�c@s"eZdZdZddd�Zdd�ZdS)	�	ButtonBara Bar of buttons, based on grid.

    methods:

     - ButtonBar(screen, buttonlist,buttonlist, compact = 0):
     - buttonPressed(self, result):  Takes the widget returned by Form.run and looks to see
                     if it was one of the widgets in the ButtonBar.
    rc		Cs�g|_i|_d|_tj|t|�d�x�|D]�}t|tjdkr@t	nt
�rT|}|j�}n*t|�dkrj|\}}n|\}}}||j|<|r�t|�}nt
|�}|jj||f�|j||jdd�|jd|_q*WdS)Nrr�3�)rrrr)r9r\r0rrrr��
isinstance�sys�version�str�
basestring�lowerr rr
r�)	rr�r�ZcompactZblistr�r#Zhotkeyr�rrrr\s$





zButtonBar.__init__cCs8||jkr|j|Sx|jD]\}}||kr|SqWdS)N)r\r9)r�resultrr#rrr�
buttonPressedss

zButtonBar.buttonPressedN)r)rrrrrr�rrrrr�Ss
r�c@sheZdZdZdd�Zddd�Zddd	�Zd
d�Zdd
�Zddd�Z	ddd�Z
dd�Zdd�Zdd�Z
dS)�GridFormHelpa= Subclass of Grid, for the help form text.

    methods:

     - GridFormHelp(self, screen, title, help, *args) :
     - add (self, widget, col, row, padding = (0, 0, 0, 0),
            anchorLeft = 0, anchorTop = 0, anchorRight = 0,
            anchorBottom = 0, growx = 0, growy = 0):
     - runOnce(self, x = None, y = None):  pop up the help window
     - addHotKey(self, keyname):
     - setTimer(self, keyname):
     - create(self, x = None, y = None):
     - run(self, x = None, y = None):
     - draw(self):
     - runPopup(self):
     - setCurrent (self, co):
    cGsJ||_||_t|�|_g|_d|_t|�}|g|dd�<tjt	|��dS)Nr)
r�r�r[rj�	childList�form_createdr9rrr�tuple)rr�r��helpr�rrrr�s
zGridFormHelp.__init__rcCs,|j|||||||||	|
�
|jj|�dS)N)r�r�r
)rrdrwrxryrzr{r|r}r~rrrrrb�szGridFormHelp.addNcCs|j||�}|jj�|S)N)rer�r�)rrurvr�rrr�runOnce�s
zGridFormHelp.runOncecCs|jj|�dS)N)rjr^)rr]rrrr^�szGridFormHelp.addHotKeycCs|jj|�dS)N)rjrm)rr]rrrrm�szGridFormHelp.setTimercCsL|jsH|jdd�x|jD]}|jj|�qW|jj||j||�d|_dS)Nr)r�rtr�rjrbr�r�r�)rrurvZchildrrr�create�szGridFormHelp.createcCs|j||�|jj�S)N)r�rjre)rrurvrrrre�szGridFormHelp.runcCs|j�|jj�S)N)r�rjri)rrrrri�szGridFormHelp.drawcCs0|j�|jj||j�|jj�}|jj�|S)N)r�r�r�r�rjrer�)rr�rrr�runPopup�s


zGridFormHelp.runPopupcCs|jj|�dS)N)rjr;)rrlrrrr;�szGridFormHelp.setCurrent�rrrr)r�rrrrrr)NN)NN)NN)rrrrrrbr�r^rmr�rerir�r;rrrrr�}s




r�c@seZdZdZdd�ZdS)�GridFormzh GridForm class (extends GridFormHelp):

    methods:

     - GridForm(self, screen, title, *args):
    cGs|||df|}tj|�dS)N)r�r)rr�r�r�Zmyargsrrrr�szGridForm.__init__N)rrrrrrrrrr��sr�c@s`eZdZdZddd�Zddd�Zdd	�Zdd
d�Zdd
�Zdd�Z	dd�Z
ddd�Zdd�ZdS)�CheckboxTreea� CheckboxTree combo widget,

    methods:

     - CheckboxTree(self, height, scroll = 0, width = None, hide_checkbox = 0, unselectable = 0)
                    constructor.
     - append(self, text, item = None, selected = 0):
     - addItem(self, text, path, item = None, selected = 0):
     - getCurrent(self):
     - getSelection(self):
     - setEntry(self, item, text):
     - setCurrent(self, item):
     - setEntryValue(self, item, selected = 1):
     - getEntryValue(self, item):
    NrcCs|j|tdf||�dS)Nr
)�addItem�	snackArgs)rrr0r$rrrr
�szCheckboxTree.appendcCs4|dkr|}|jj|||�}||j|<||j|<dS)N)rZcheckboxtreeAddItemr.r/)rr�pathr0r$r+rrrr��s

zCheckboxTree.addItemcCs|jj�}|j|S)N)rZcheckboxtreeGetCurrentr.)rZcurrrrr�
getCurrent�s
zCheckboxTree.getCurrentcCs2tj||||�|_i|_i|_|r.|jj|�dS)N)rZcheckboxtreerr.r/ZcheckboxtreeSetWidth)rr>r?rAZ
hide_checkboxZunselectablerrrr�s
zCheckboxTree.__init__cCs0g}|jj�}x|D]}|j|j|�qW|S)N)rZcheckboxtreeGetSelectionr
r.)rr8r9r+rrrr:�s


zCheckboxTree.getSelectioncCs|jj|j||�dS)N)rZcheckboxtreeSetEntryr/)rr0rrrr�setEntry�szCheckboxTree.setEntrycCs|jj|j|�dS)N)rZcheckboxtreeSetCurrentr/)rr0rrrr;szCheckboxTree.setCurrentrcCs|jj|j||�dS)N)rZcheckboxtreeSetEntryValuer/)rr0r$rrr�
setEntryValueszCheckboxTree.setEntryValuecCs|jj|j|�S)N)rZcheckboxtreeGetEntryValuer/)rr0rrr�
getEntryValueszCheckboxTree.getEntryValue)Nr)Nr)rNrr)r)
rrrrr
r�r�rr:r�r;r�r�rrrrr��s



r��Ok�Cancel�(c
Cs�|d	krt|�}t||�}
t||�}t||dd�}d}
xX|D]P}t|�tkrV|\}}n|}|
}||
krl|}n||krx|}|j||�|
d}
q<W|dkr�|j|�t|||	dd�}|j	|dd�|j	|ddd
d�|j	|
dddd�|j
�}|
j|�|j�fS)z�
    - ListboxChoiceWindow(screen, title, text, items, 
            buttons = ('Ok', 'Cancel'), 
            width = 40, scroll = 0, height = -1, default = None,
            help = None):
    r)r?r@rN�)ryr�)r~rH)rrrr)
r�r�rEr-�typer�r
r;r�rbr�r�r7)r�r�r�items�buttonsrAr?r>r�r��bb�t�l�countr0r+rsZrcrrr�ListboxChoiceWindow	s2





r�cCsdt||�}t|||jdd�}	t|||dd�}
|
j|	dddd�|
j|dddd�|j|
j||��S)	z�
     - ButtonChoiceWindow(screen, title, text, 
               buttons = [ 'Ok', 'Cancel' ], 
               width = 40, x = None, y = None, help = None):
    �)rLrr�r)ry)r~)rrrr)r�rEr>r�rbr�r�)r�r�rr�rArurvr�r�r�rsrrr�ButtonChoiceWindow4s
r��c		Cs\t||�}	t||�}
d}x|D]}|d}qWtd|�}
d}g}x�|D]�}t|�tkr�|\}}t|tjdkrptnt	�r�t
||�}nt
|�}|
jt|�d|d
dd�|
j|d|dd�|d}|j
|�qFWt|||dd�}|j|
dddd�|j|
dddd�|j|	dddd	�|j�}g}d}x(|D] }|j
||j��|d}�q&W|	j|�t|�fS)
z�
    EntryWindow(screen, title, text, prompts, allowCancel = 1, width = 40,
        entryWidth = 20, buttons = [ 'Ok', 'Cancel' ], help = None):
    rrr�r�)ryrz)rzr�)ry)r~)rrrr)rrrr)rrrr)r�rErrr�r�r�r�r�r�r�rSr�rMr
r�rbr�r#r�)r�r�rZpromptsZallowCancelrAZ
entryWidthr�r�r�r�r��nZsgZ	entryList�ersr�ZentryValuesrrr�EntryWindowDs:





r�c@sbeZdZdZddd�Zddd�Zdd	d
�Zddd�Zd
d�Zddd�Z	dd�Z
dd�Zdd�ZdS)�CListboxapClistbox convenience class.

    methods:

     - Clistbox(self, height, cols, cols_widths, scroll = 0)       : constructor
     - colFormText(self, col_text, align = None, adjust_width = 0) : column text.
     - append(self, col_text, item, col_text_align = None)         :
     - insert(self, col_text, item, before, col_text_align = None)
     - delete(self, item)
     - replace(self, col_text, item, col_text_align = None)
     - current(self) : returns current item
     - setCurrent(self, item): sets an item as current
     - clear(self): clear the listbox
     
     Alignments may be LEFT, RIGHT, CENTER, None
    rrNcCs�||_|dd�|_||_||_|	dkrjtj|dd�d}|j|	|
|d�}
t|
�|_|j	|jdddd�ntj|dd�d}t
||||�|_|j	|jd|dd�dS)Nrr�)�adjust_widthr)rz)r|)�cols�
col_widths�col_pad�col_text_alignrrr�colFormTextrMrNr�r-r=)rr>r�r�r?r@rAr�r�Z
col_labelsZcol_label_alignr�Zbox_yZlstrrrrr�s
zCListbox.__init__cCs&d}d}t|�}�x||jko$||k�r ||}tj|�}|j||krj|rX||j|<n|d|j|�}|j|tj|�}	|	dkr�|dkr�t}
n||}
|
tkr�|d|	}|
tkr�d|	d|d|	dd}|
tkr�d|	|}||dk�rd|j}nd}|||}|d}qW|S)NrrTrVr�r)	r�r�rZwstrlenr��LEFT�CENTER�RIGHTr�)r�col_textZalignr��ir�Zc_lenZcstrZcstrlenZdelta�aZpstrrrrr��s8
zCListbox.colFormTextcCs,|dkr|j}|j||�}|jj||�dS)N)r�r�r=r
)rr�r0r�rrrrr
�szCListbox.appendcCs.|dkr|j}|j||�}|jj|||�dS)N)r�r�r=r3)rr�r0r2r�rrrrr3�szCListbox.insertcCs|jj|�dS)N)r=r5)rr0rrrr5�szCListbox.deletecCs,|dkr|j}|j||�}|jj||�dS)N)r�r�r=r6)rr�r0r�rrrrr6�szCListbox.replacecCs
|jj�S)N)r=r7)rrrrr7�szCListbox.currentcCs|jj|�dS)N)r=r;)rr0rrrr;�szCListbox.setCurrentcCs|jj�dS)N)r=r<)rrrrr<�szCListbox.clear)rrrrNNNr)Nr)N)N)N)
rrrrrr�r
r3r5r6r7r;r<rrrrr�rs

)


r�cCsd|S)N�r)rurrr�customColorset�sr�rH)rHrrHrH)rHrH)rr)rr)rrrH)rFrF�r�r�rH)r�r�rrHNN)crZ
__future__rrrr�stringr�rrrrr	r
rr�ZDOWNr�ZUPr�r�rrr r!r*r-rBrErMrQrSZKEY_F1ZKEY_F2ZKEY_F3ZKEY_F4ZKEY_F5ZKEY_F6ZKEY_F7ZKEY_F8ZKEY_F9ZKEY_F10ZKEY_F11ZKEY_F12ZKEY_ESCZ	KEY_ENTERZKEY_SUSPENDZ
KEY_BACKSPACEZ
KEY_DELETEZ
KEY_INSERTZ
KEY_RESIZErWr\r9rar�Z
ascii_lettersZdigits�orYr[rrZ
COLORSET_ROOTZCOLORSET_BORDERZCOLORSET_WINDOWZCOLORSET_SHADOWZCOLORSET_TITLEZCOLORSET_BUTTONZCOLORSET_ACTBUTTONZCOLORSET_CHECKBOXZCOLORSET_ACTCHECKBOXZCOLORSET_ENTRYZCOLORSET_LABELZCOLORSET_LISTBOXZCOLORSET_ACTLISTBOXZCOLORSET_TEXTBOXZCOLORSET_ACTTEXTBOXZCOLORSET_HELPLINEZCOLORSET_ROOTTEXTZCOLORSET_EMPTYSCALEZCOLORSET_FULLSCALEZCOLORSET_DISENTRYZCOLORSET_COMPACTBUTTONZCOLORSET_ACTSELLISTBOXZCOLORSET_SELLISTBOXr�r�rIr�r�r�r�r�r�r�r�r�r�r�rrrr�<module>(s�$

A	 ?.
U
*I9
)-s