示例#1
0
    t = gdi.TextBox()
    t.set_position(350, 90)
    ww.add_component(t)

    l = gdi.Label()
    l.set_position(250, 130)
    l.set_width(100)
    l.set_text("User")
    ww.add_component(l)

    t = gdi.TextBox()
    t.set_position(350, 130)
    ww.add_component(t)

    rr = gdi.RadioButton()
    rr.set_text("Yes")
    rr.set_group("GRP1")
    rr.set_position(250, 170)
    ww.add_component(rr)

    rr = gdi.RadioButton()
    rr.set_text("No")
    rr.set_group("GRP1")
    rr.set_position(250, 210)
    rr.set_selected(True)
    ww.add_component(rr)

    pbr = gdi.ProgressBar()
    pbr.set_position(250, 250)
    pbr.set_percent(0.4)
示例#2
0
文件: ui.py 项目: landv/agent
 def _show_chooser(self,  chs):
     if self._gui_enable is True:
         self._prepare_main_panel()
         h=chs.get_message_height()
         w=_CONTENT_WIDTH-(2*_GAP_TEXT)
         l = gdi.Label() 
         l.set_wordwrap(True)
         l.set_text_align(gdi.TEXT_ALIGN_LEFTTOP)
         l.set_text(chs.get_message())
         l.set_position(_GAP_TEXT, _GAP_TEXT)
         l.set_size(w, h)
         
         self._pnlmain.add_component(l)
     
         ar = chs.get_choices()
         p=h+_GAP_TEXT
         for i in range(len(ar)):
             inp=ar[i]
             rb = gdi.RadioButton()
             rb.set_text(inp['label'])
             rb.set_position(_GAP_TEXT, p)
             rb.set_size(_CONTENT_WIDTH-(2*_GAP_TEXT), 30)
             rb.set_name(inp['key'])
             rb.set_group("RADIOBUTTON")
             if chs.get_variable().get()==inp['key']:
                 rb.set_selected(True);
             rb.set_action(chs.on_selected)
             self._pnlmain.add_component(rb)
             p+=30
         chs.set_main(self)
     else:
         self._printcl(u"")
         self._printcl(chs.get_message())
         self._printcl(u"")
         ar = chs.get_choices()
         df = u""
         ar_idx_accept=[]
         idx_default=None
         for i in range(len(ar)):
             inp=ar[i]
             self._printcl(str(i+1) + u". " + inp['label'])
             if chs.get_variable().get()==inp['key']:
                 idx_default=i+1
                 df = u" (" + str(idx_default) + u")"
             if chs.is_accept_key(inp['key']):
                 ar_idx_accept.append(i+1)
         rd = self._clmode_read(messages.get_message('option') + df + u":")
         if rd is not None:
             if rd=="":
                 rd=str(idx_default)
             try:
                 ird=int(rd)
                 if (ird>len(ar)):
                     raise Exception("")
                 if len(ar_idx_accept) > 0:
                     serr=[]
                     berr=True
                     for idxcur in ar_idx_accept:
                         serr.append(str(idxcur))
                         if ird==idxcur:
                             berr=False
                     if berr:
                         self._show_error(messages.get_message('mustAccept').format((u" " + messages.get_message('or') + u" ").join(serr)))
                         return
                 inp=ar[ird-1]
             except:
                 self._show_error(messages.get_message('optionNotValid'))
                 return
             chs.get_variable().set(inp['key'])
             self._clmode_next()