Mini Shell
3
<�Zcm � @ s� d dl Z d dlmZ d dlmZ d dlmZ d dlmZm Z d dl
mZ d dlm
Z
mZmZ dd d
ddd
gZG dd� de�ZG dd� de�ZG dd
� d
e�ZG dd� de�ZG dd � d e�ZG dd
� d
e�ZdS )� N)�widgets)�WindowContainer)�Prompt)�UIScreen�
InputState)�PasswordInputHandler)�_�N_�C_�ErrorDialog�GetInputScreen�GetPasswordInputScreen�
HelpScreen�PasswordDialog�YesNoDialogc s@ e Zd ZdZ� fdd�Zd� fdd� Zddd�Zd d
� Z� ZS )
r z+Dialog screen for reporting errors to user.c s t � j� td�| _|| _dS )z\
:param message: the message to show to the user
:type message: str
�ErrorN)�super�__init__r �title�_message)�self�message)� __class__� �!/usr/lib/python3.6/adv_widgets.pyr # s
zErrorDialog.__init__Nc s. t � j|� tj| j�}| jjtj|�� d S )N)r �refreshr �
TextWidgetr �window�add_with_separator�CenterWidget)r �args�text)r r r r , s zErrorDialog.refreshc C s t td�t j �S )NzPress %s to exit)r r �ENTER)r r r r r �prompt1 s zErrorDialog.promptc C s t jd� dS )zUThis dialog is closed by any input.
And causes the program to quit.
� N)�sys�exit)r r �keyr r r �input4 s zErrorDialog.input)N)N) �__name__�
__module__�__qualname__�__doc__r r r# r( �
__classcell__r r )r r r s
c sN e Zd ZdZd
� fdd� Zd� fdd� Zddd�Zed d
� �Zdd� Z � Z
S )r z!Dialog screen for password input.Nc s, t � j� td�| _|ptd�| _d| _dS )zX
:param message: password prompt question
:type message: string
ZPasswordzEnter your passphraseN)r r r r r r � _password)r r )r r r r ? s
zPasswordDialog.__init__c s. t � j|� tj| j�}| jjtj|�� d S )N)r r r r r r r r )r r r! )r r r r I s zPasswordDialog.refreshc C sR t | d�}| jr|j| j� |jtd�� |j� |j� s>d S |j| _| j � d S )N)�sourcezPassphrase: )
r Z
password_funcZ
set_pass_funcZ get_inputr Z
wait_on_inputZinput_successful�valuer. �close)r r Zhandlerr r r r# N s
zPasswordDialog.promptc C s | j S )z?The response can be None (no response) or the password entered.)r. )r r r r �answerb s zPasswordDialog.answerc C s |r|| _ tjS tjS d S )N)r. r �PROCESSED_AND_CLOSE� DISCARDED)r r r'