Difficulty with writing to a document in Python + wxPython -


i'm trying make python gui. simple test see if can user's input in text box, have them click "create" button , have write file.

here current code:

import wx class gui(wx.frame):  def __init__(self,parent,id):     wx.frame.__init__(self,parent,id,'yml generator v1.0', size=(500,800))     panel=wx.panel(self)     wx.statictext(panel, -1, "name", (10,10))      global itemname     boxx = wx.textctrl(panel, -1, pos = (90, 10), size = (100, -1))     itemname=boxx.getvalue()       button=wx.button(panel,label="create!",pos=(100,100),size=(100,40))     self.bind(wx.evt_button, self.writestuff, button)  def writestuff(self, e):     yml = open("output.yml", "wb")     yml.write((itemname) + " entered.")     yml.close def closewindow(self,event):     self.destroy()  if __name__=='__main__':     app=wx.pysimpleapp()            #runs program     frame=gui(parent=none,id=-1)  #displays program     frame.show()                    #shows application     app.mainloop()                  #runs application 

i added itemname global because before getting errors itemname not being defined.

now, " entered" written file, no user input shows up. doing wrong?

itemname getting value of textctrl @ time textctrl created, empty string. want value @ time button pressed. can save reference textctrl in self, , use self.boxx.getvalue() fetch value want write file.


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -