Exemplo n.º 1
0
 def initialize(self, content, config_data):
     self.anim = self.sub(Animation, static["active"], start=3, run=True)
     self.write(ac.clear + str_top(self))
     self.content = content
     self.menu = self.sub(ColMenu, config_data)
     self.do_refresh()
     value = self.menu.read_until()
     if isinstance(value, str):
         next_f = value
         kwargs = {}
     else:
         next_f, kwargs = value
     self.goto(mark[next_f], **kwargs)
Exemplo n.º 2
0
Arquivo: user.py Projeto: yanwen/argon
    def initialize(self):
        self.write(ac.clear+str_top(self))
        u = self.session['_user'].dump_attr()
        u['gender'] = u'女' if u['gender'] else u'男'
        try:
            self.write(static['user_edit_data'] % u)
        except TypeError:
            self.write(u'数据还没填写!下面开始填写你的数据咯~\r\n')
        else:
            self.write(u'Ctrl+c返回,任意键开始修改。')
            self.pause()
        u = self.session['_user'].dump_attr()
        self.write(u'\r\n\r\n请逐项修改,直接按 <ENTER> 代表使用 [] 内的资料。\r\n')

        input_text = self.sub(TextInput)
        for key,des in ( ('nickname',u'\r\n昵称 [%s] :'%u['nickname']),
                         ('realname',u'\r\n真实姓名 [%s] :'%u['realname']),
                         ('address',u'\r\n居住地址 [%s] :'%u['address']),
                         ('email',u'\r\n电子信箱 [%s] :'%u['email']),
                         ('gender',u'\r\n性别 M.男 F.女 [%s]:' % 'F' if u['gender'] else 'M')) :
            self.write(des)
            input_text.clear()
            text = input_text.read_until()
            if len(text) and getattr(self,'check_'+key)(text) :
                u[key] = text

        u['gender'] = 1 if u['gender'] == 'F' else 0

        self.write(u'\r\n生日 [%s] : ' % u['birthday'].isoformat())
        birthday = self.sub(DatePicker).read_until()
        if birthday :
            u['birthday'] = birthday

        self.write(u'\r\n确定要改变吗 (yes/NO)? [N]')
        g = self.read()
        if g == 'y' :
            self.session['_user'].update_dict(u)
            self.session['_user'].update_user(['nickname','realname','address','email','birthday','gender'])
            self.write(u'\r\修改成功!')
        self.goto(mark['user_edit_data'])