Python学习实例:编写一个记事本GUI
2015-12-30 22:49
686 查看
#!/usr/bin/env python #-*- coding:utf-8 -*- from Tkinter import * def donothing(): filewin=Toplevel(root) button=Button(filewin,text="hi 这是菜单响应代码段") button.pack() root=Tk() root.title("记事本") root.geometry("800x500") menubar=Menu(root) filemenu = Menu(menubar, tearoff=0) filemenu=Menu(menubar,tearoff=0) filemenu.add_command(label="新建",accelerator="Ctrl+N",command=donothing) filemenu.add_command(label="打开",accelerator="Ctrl+O",command=donothing) filemenu.add_command(label="保存",accelerator="Ctrl+S",command=donothing) filemenu.add_command(label="另存为",accelerator="Ctrl+Shift+S",command=donothing) filemenu.add_separator() filemenu.add_command(label="页面设置",accelerator="U",command=donothing) filemenu.add_command(label="打印",accelerator="Ctrl+P",command=donothing) filemenu.add_separator() filemenu.add_command(label="退出",accelerator="X",command=root.quit) menubar.add_cascade(label="文件",menu=filemenu) editmenu = Menu(menubar, tearoff=0) editmenu.add_command(label="Undo", command=donothing) editmenu.add_separator() editmenu.add_command(label="Cut", command=donothing) editmenu.add_command(label="Copy", command=donothing) editmenu.add_command(label="Paste", command=donothing) editmenu.add_command(label="Delete", command=donothing) editmenu.add_command(label="Select All", command=donothing) menubar.add_cascade(label="Edit", menu=editmenu) helpmenu = Menu(menubar, tearoff=0) helpmenu.add_command(label="Help Index", command=donothing) helpmenu.add_command(label="About...", command=donothing) menubar.add_cascade(label="Help", menu=helpmenu) root.config(menu=menubar) txt=Text(root,undo=True) txt.pack(expand=YES,fill=BOTH) scl=Scrollbar(txt) txt.config(yscrollcommand=scl.set) scl.config(command=txt.yview()) scl.pack(side=RIGHT,fill=Y) statusbar=Label(root,text="行 1 column 1",bg="#fff",fg="#00c",relief=SUNKEN,anchor=E) statusbar.pack(side=BOTTOM,fill=X) if __name__ == "__main__": mainloop()
相关文章推荐
- 用python爬虫抓站的一些技巧总结
- Python学习笔记3-文件的简单操作
- Python学习笔记3-文件的简单操作
- python 3.5 爬虫日记2
- Python遍历文件,正则选取汉字便于多语言支持
- win 64位系统安装带有c编写的python模块出现ValueError: [u'path']解决
- windows下配置eclipse + Python + PyDev + tornado,并使用pylint进行静态检测
- python学习之元组与文件
- numpy中生成随机矩阵并打印出矩阵的shape
- Python开发简单爬虫(一)
- Python开发简单爬虫(二)
- Python一些字符串判断和转换
- 《Python语言程序设计》前四章学习记录
- python基础:测量python代码的运行时间
- Python学习--基础代码练习
- Python Network Programming(8)---SocketServer模块
- 初写博客,python菜鸟一个,希望热心大神指导
- Python执行系统命令的方法 os.system(),os.popen(),commands
- leetcode之Minimum Depth of Binary Tree
- Windows运行Python服务