Remove widget

414 views
Skip to first unread message

Sergey Utkin

unread,
Apr 6, 2015, 9:34:18 AM4/6/15
to npys...@googlegroups.com
Hi,
I want to add / remove a widget, depending on the MultiSelect, add I got, but how to remove it?
class Form1(npyscreen.ActionFormV2):

    btn
= None
   
   
def create(self):
       
self.keypress_timeout = 1
       
self.Name = self.add(npyscreen.TitleText, name = u'Test:')
       
self.Check = self.add(npyscreen.MultiSelect,  max_height=2, values = ["Пульт"], scroll_exit=True, width=20)
       
       
   
def beforeEditing(self):
       
if self.HostID == 0:
           
self.Name.value = ""
           
   
def while_waiting(self):
       
if self.btn is None:
           
if len(self.Check.value) != 0:
               
self.btn = self.add(btn, name = u"Add",color='STANDOUT')
           
else:


???

P.S. sorry for my english.

Nicholas Cole

unread,
Apr 7, 2015, 11:22:05 AM4/7/15
to npys...@googlegroups.com
Hi Sergey,

The usual way to do this is not to keep adding and removing the
widget, but to use the the .hidden attribute.
> --
> You received this message because you are subscribed to the Google Groups
> "npyscreen" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to npyscreen+...@googlegroups.com.
> To post to this group, send email to npys...@googlegroups.com.
> Visit this group at http://groups.google.com/group/npyscreen.
> For more options, visit https://groups.google.com/d/optout.

Sergey Utkin

unread,
Apr 8, 2015, 5:29:22 AM4/8/15
to npys...@googlegroups.com
Thank you, it works

вторник, 7 апреля 2015 г., 18:22:05 UTC+3 пользователь Nicholas Cole написал:

Nicholas Cole

unread,
Apr 11, 2015, 6:44:06 AM4/11/15
to npys...@googlegroups.com
Also, have a look at FormControlCheckbox - which you can use to
control which widgets appear or not.
Reply all
Reply to author
Forward
0 new messages