zoukankan      html  css  js  c++  java
  • Python 12---图形界面

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

    def save(event):
    newcontents = contents.GetValue()
    with open(filename.GetValue(),'w') as f:
    f.write(newcontents)
    contents.SetValue('')

    import wx
    app = wx.App()

    win = wx.Frame(None,title ='Simple Editor', size=(410,335))
    bkg = wx.Panel(win)
    loadbtn = wx.Button(bkg,label='Open')
    savebtn = wx.Button(bkg,label='Save')
    filename = wx.TextCtrl(bkg)
    contents = wx.TextCtrl(bkg,style=wx.TE_MULTILINE | wx.HSCROLL)

    loadbtn.Bind(wx.EVT_BUTTON,load)
    savebtn.Bind(wx.EVT_BUTTON,save)

    hbox = wx.BoxSizer()
    hbox.Add(filename,proportion=1,flag=wx.EXPAND)
    hbox.Add(loadbtn,proportion=0,flag = wx.LEFT, border = 5)
    hbox.Add(savebtn,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内存管理简介:
    排序算法优劣
    排序
    HTTPs
    http和https的异同
    HTTP协议
    FTP与TFTP
    tomcat热部署
    开发心得体会
  • 原文地址:https://www.cnblogs.com/ahMay/p/5684962.html
Copyright © 2011-2022 走看看