我使用GTK 3.4與python(與GObject內省)。GTK 3 - 添加項目後擴展彈出式菜單
我用Gtk.UIManager構建彈出菜單,當菜單實例化時,某些菜單項不是主動/可見的。之後它們被激活,並且它們在菜單中變得可見。
但是有一個小問題 - 大小彈出菜單(高度)似乎保持不變 - 現在我必須滾動菜單項 - 菜單區域的頂部和底部有^ v箭頭以顯示該項目不適合區域,並且可以上下滾動。不過,如果彈出窗口的大小在顯示時發生改變,我會非常喜歡。
彈出窗口在應用程序上實例化一次。對象是這樣的:
menu_manager=Gtk.UIManager()
menu_manager.insert_action_group(self.core_actions)
menu_manager.insert_action_group(self.power_type_actions)
menu_manager.add_ui_from_file(os.path.join(_curr_dir, 'ui', 'menus.xml'))
self.menu_manager=menu_manager
self.popup=menu_manager.get_widget('/popup')
,並與該信號處理程序顯示在任務欄圖標:
def show_menu(self, tray_icon, button, activate_time, user_data=None):
def pos(menu, icon):
p= Gtk.StatusIcon.position_menu(menu, icon)
return p
log.debug('Menu button=%s, time=%s', button, activate_time)
self.popup.popup(None, None, pos, tray_icon, button, activate_time)
有什麼辦法如何強行彈出菜單來調整,以顯示其所有項目的無需要滾動?