python实例代码之菜单的分割线

发布时间:2019-08-08编辑:脚本学堂
本文分享一个python的实例代码,教大家实现添加菜单的分割线的方法,有需要的朋友作个参考吧。

python实例之菜单分割线,代码如下:

#!/bin/python

from Tkinter import *

class TestMenu:
    def __init__(self, master):
  self.master = master
  self.menubar = Menu(self.master)

        self.cmdmenu = Menu(self.menubar)
        self.cmdmenu.add_command(label='New...', underline=0)
        self.cmdmenu.add_command(label='Open...', underline=0)
        self.cmdmenu.add_command(label='Wild Font', underline=0,
                         font=('Tempus Sans ITC', 14))
#        self.cmdmenu.add_command(bitmap="someBitMap")
        self.cmdmenu.add('separator')

        self.unused = Menu(self.menubar)

        self.menubar.add_cascade(label="Button Command", menu=self.cmdmenu)

  self.top = Toplevel(menu=self.menubar, width=500, relief=RAISED,
                            borderwidth=2)

def main():
    root = Tk()
    root.withdraw()
    app = TestMenu(root)
    root.mainloop()

if __name__ == '__main__':
    main()

 效果图,如下:
python菜单分割线