亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

pygtk-menu使用itemfactory

系統 1924 0
    #!/usr/bin/env python

# example itemfactory.py

import pygtk
pygtk.require(’2.0’)
import gtk

class ItemFactoryExample:
# Obligatory basic callback
	def print_hello(self, w, data):
		print "Hello, World!"

		# This is the ItemFactoryEntry structure used to generate new menus.
		# Item 1: The menu path. The letter after the underscore indicates an
		# accelerator key once the menu is open.
		# Item 2: The accelerator key for the entry
		# Item 3: The callback.
		# Item 4: The callback action. This changes the parameters with
		# which the callback is called. The default is 0.
		# Item 5: The item type, used to define what kind of an item it is.
		# Here are the possible values:

		# NULL -> "<Item>"
		# "" -> "<Item>"
		# "<Title>" -> create a title item
		# "<Item>" -> create a simple item
		# "<CheckItem>" -> create a check item
		# "<ToggleItem>" -> create a toggle item
		# "<RadioItem>" -> create a radio item
		# <path> -> path of a radio item to link against
		# "<Separator>" -> create a separator
		# "<Branch>" -> create an item to hold sub items (optional)
		# "<LastBranch>" -> create a right justified branch

	def get_main_menu(self, window):
		accel_group = gtk.AccelGroup()

		# This function initializes the item factory.
		# Param 1: The type of menu - can be MenuBar, Menu,
		# or OptionMenu.
		# Param 2: The path of the menu.
		# Param 3: A reference to an AccelGroup. The item factory sets up
		# the accelerator table while generating menus.
		item_factory = gtk.ItemFactory(gtk.MenuBar, "<main>", accel_group)

		# This method generates the menu items. Pass to the item factory
		# the list of menu items
		item_factory.create_items(self.menu_items)

		# Attach the new accelerator group to the window.
		window.add_accel_group(accel_group)

		# need to keep a reference to item_factory to prevent its destruction
		self.item_factory = item_factory
		# Finally, return the actual menu bar created by the item factory.
		return item_factory.get_widget("<main>")

	def __init__(self):
		self.menu_items = (
		( "/_File", None, None, 0, "<Branch>" ),
		( "/File/_New", "<control>N", self.print_hello, 0, None ),
		( "/File/_Open", "<control>O", self.print_hello, 0, None ),
		( "/File/_Save", "<control>S", self.print_hello, 0, None ),
		( "/File/Save _As", None, None, 0, None ),
		( "/File/sep1", None, None, 0, "<Separator>" ),
		( "/File/Quit", "<control>Q", gtk.main_quit, 0, None ),
		( "/_Options", None, None, 0, "<Branch>" ),
		( "/Options/Test", None, None, 0, None ),
		( "/_Help", None, None, 0, "<LastBranch>" ),
		( "/_Help/About", None, None, 0, None ),
		)
		window = gtk.Window(gtk.WINDOW_TOPLEVEL)
		window.connect("destroy", lambda w: gtk.main_quit(), "WM destroy")
		window.set_title("Item Factory")
		window.set_size_request(300, 200)

		main_vbox = gtk.VBox(False, 1)
		main_vbox.set_border_width(1)
		window.add(main_vbox)
		main_vbox.show()

		menubar = self.get_main_menu(window)

		main_vbox.pack_start(menubar, False, True, 0)
		menubar.show()
		window.show()

def main():
	gtk.main()
	return 0

if __name__ == "__main__":
	ItemFactoryExample()
	main()

  

?

pygtk-menu使用itemfactory
?

?
?

pygtk-menu使用itemfactory


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 国产嘿咻| 亚洲视频在线网站 | 婷婷国产成人久久精品激情 | 亚洲综合免费 | 九九精品视频一区二区三区 | 麻豆69 | 亚洲+自拍+色综合图区一 | 国产精品免费视频一区二区三区 | 国产日产欧美 | 亚洲区精品 | 亚洲国产成人精品女人久久久 | 在线观看年轻的母亲 | 四虎影视最新网站在线播放 | 伊人久久99 | 四虎国产精品永久免费网址 | 妖精视频在线看免费视频 | 亚洲国产中文字幕 | 久9热精品视频在线观看 | 91精品免费在线观看 | 2021国内精品久久久久影院 | 天天操夜夜操天天操 | 亚洲精品高清在线一区二区三区 | 一级特级欧美aaaaa毛片 | 天天久久综合 | 日韩一中文字幕 | 日韩精品福利视频一区二区三区 | 日韩欧美一区二区在线观看 | 日韩字幕一中文在线综合 | 亚洲国产欧美在线不卡中文 | 亚洲高清在线播放 | 国产成人精品一区二区三区 | 天天碰夜夜 | 四虎成人影院网址 | 99视频在线看观免费 | 大片在线播放日本一级毛片 | www香蕉视频| 免费精品精品国产欧美在线 | 亚洲欧美成人综合久久久 | 年级的后妈妈2中文翻译 | 日韩中文字幕一在线 | 久久精品网 |