小白问题,Python新手,记录一下。
刚才新写了一段代码,如下:
import wxapp = wx.App()win = wx.Frame(None,title = "编辑器", size=(410,335))bkg = wx.Panel(win)loadButton = wx.Button(bkg, label = '打开')saveButton = wx.Button(bkg, label = '保存')filename = wx.TextCtrl(bkg)contents = wx.TextCtrl(bkg, style = wx.TE_MULTILINE | wx.HSCROLL)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()
发现用Windows下装的Python IDE 写的保存不了
查找原因,发现是代码有问题,就保存不了,这个问题一般是代码中有中文,开头要写上 #coding=gbk (Windows下),Linux下要写上#coding=utf-8,即可
再次保存就保存成功了。
有一个博客写得很好,有空可以学习一下,谢谢原作者:http://blog.chinaunix.net/uid-7208369-id-2658427.html
以上。