这应该做的伎俩:
for i in menu.get_children():
menu.remove(i) # check here if you want to remove this child
Run Code Online (Sandbox Code Playgroud)
gtk.Menu 继承自 gtk.Container
http://www.pygtk.org/docs/pygtk/class-gtkcontainer.html
编辑
# 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?
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2639 次 |
| 最近记录: |