#!/usr/bin/python
''' handle commands.'''

import ri_widget
import os
import ri_tk

def quit():
    ''' correspond to quit button '''
    # maybe a quit in current widget, so call widget.hide()
    # get current widget, call its quit()
    q, t = ri_widget.Sequence.current()
    ri_widget.Widget.dict[t].hide()
    display.quit()
    ri_data.to_xml()

def previous():
    ''' correspond to previous button '''
    q, t = ri_widget.Sequence.current()
    wid_name = ri_widget.Sequence.previous()
    if wid_name is not None:
        ri_widget.Widget.dict[t].hide()

        ri_widget.Widget.dict[wid_name].show()
    else:
        ri_widget.MessageBox.dict["previous"].show()

def next():
    ''' correspond to next button '''
    q, t = ri_widget.Sequence.current()
    ri_widget.Widget.dict[t].hide()
    wid_name = ri_widget.Sequence.next()
    if wid_name is not None:
        ri_widget.Widget.dict[wid_name].show()
    else:
        code = ri_widget.MessageBox.dict["next"].show()
        if code == True:
            os.execl('/usr/bin/python','python','ri_install.py', "-d","tk","-l",ri_tk.language)
from ri_tk_cmd import *

        
