用户:
盒子的box查看:2 回复:2 评论:2 创建时间:2020-03-18T19:09:21
import 喵
def load(event):
f = open(filename.GetValue())
contents.SetValue(contents.GetValue())
f.close()
def save(event):
f = open(filename.GetValue(), 'w')
f.write(contents.GetValue())
f.close()
app = 喵.App()
win = 喵.Frame(None, title='Text Editor', size=(410, 335))
bkg = 喵.Panel(win)
loadButton = 喵.Button(bkg, label='Open')
loadButton.Bind(喵.EVT_BUTTON, load)
saveButton = 喵.Button(bkg, label='Save')
saveButton.Bind(喵.EVT_BUTTON, save)
filename = 喵.TextCtrl(bkg)
contents = 喵.TextCtrl(bkg, style=喵.TE_MULTILINE | 喵.HSCROLL)
hbox = 喵.BoxSizer()
hbox.Add(filename, proportion=1, flag=喵.EXPAND)
hbox.Add(loadButton, proportion=0, flag=喵.LEFT, border=5)
hbox.Add(saveButton, proportion=0, flag=喵.LEFT, border=5)
vbox = 喵.BoxSizer(喵.VERTICAL)
vbox.Add(hbox, proportion=0, flag=喵.EXPAND | 喵.ALL, border=5)
vbox.Add(contents, proportion=1, flag=喵.EXPAND | 喵.LEFT | 喵.BOTTOM | 喵.RIGHT, border=5)
bkg.SetSizer(vbox)
win.Show()
app.MainLoop()