2010-11-23 4 views

ответ

7

Это должно сделать трюк:

for i in menu.get_children(): 
    menu.remove(i) # check here if you want to remove this child 

gtk.Menu наследуется от gtk.Container

http://www.pygtk.org/docs/pygtk/class-gtkcontainer.html

EDIT

# First remove all old timer menu items from the gtkMenu 
if TimerAppIndicator.menuList: 
    for i in TimerAppIndicator.menuList: 
     self.menu.remove(TimerAppIndicator.menuList[j]) 
     j+=1 <---- 1) j isn't declared here 
        2) you will skip items why not just self.menu.remove(i) 
         you're already iterating over the menu items 


# Delete all timer menu items from the list storing them 
del TimerAppIndicator.menuList[:] 
j=0 <--------- shouldn't this be before j+=1? 
+0

Nice, спасибо, это работает в какой-то степени. Когда я просто рисую `print self.menu.get_children()`, то вижу, что элемент действительно удален. Но он все еще появляется в моем меню. Возможно ли, что мне все еще нужно обновить или перерисовать его? Если да, то как? – Ingo 2010-11-23 17:45:49

Смежные вопросы