首页新闻找找看学习计划

可以帮忙注释一下python吗看不懂,一个小程序

0
[已解决问题] 解决于 2019-12-27 19:28

import wx

def load(event):
file = open(filename.GetValue())
contents.SetValue(file.read())
file.close()

def save(event):
file = open(filename.GetValue(), 'w')
file.write(contents.GetValue())
file.close()

app = wx.App()
win = wx.Frame(None, title="Simple Editor", size=(410, 335)) #创建窗口
bkg = wx.Panel(win)

loadButton = wx.Button(bkg, label='Open')
loadButton.Bind(wx.EVT_BUTTON, load)
saveButton = wx.Button(bkg, label='Save')
saveButton.Bind(wx.EVT_BUTTON, save)

filename = wx.TextCtrl(bkg)
filename.SetValue('test.txt')

contents = wx.TextCtrl(bkg, style=wx.TE_MULTILINE | wx.HSCROLL)
contents.SetValue("hello, I am wuyouwulv.\nthis is a python editor sample using wxPython plugins.\nto install wxPython,you can input \n\t'sudo apt-get install python-wxtools'\nunder ubuntu")

hbox = wx.BoxSizer()
hbox.Add(filename, proportion=1, flag=wx.EXPAND)
hbox.Add(loadButton, proportion=0, flag=wx.LEFT, border=5)
hbox.Add(saveButton, proportion=0, flag=wx.LEFT, border=5)

vbox = wx.BoxSizer(wx.VERTICAL)
vbox.Add(hbox, proportion=0, flag=wx.EXPAND | wx.ALL, border=5)
vbox.Add(contents, proportion=1,
flag=wx.EXPAND | wx.LEFT | wx.BOTTOM | wx.RIGHT, border=5)
bkg.SetSizer(vbox)
win.Show()

app.MainLoop()

L长安L的主页 L长安L | 菜鸟二级 | 园豆:202
提问于:2019-12-26 14:32
< >
分享
最佳答案
0

缩进都全没了x

奖励园豆:5
jakio6 | 小虾三级 |园豆:777 | 2019-12-27 10:35
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册