记事本编写python程序_Python学习实例:编写一个记事本GUI

#!/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()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值