Solved

error while populating wx.textCtrl

Posted on 2010-11-26
2
622 Views
Last Modified: 2012-08-13
im trying to populate wx.Textctrl , multiline
(self.name_of1 = wx.TextCtrl(panel, -1,self.staff1,pos=(30,30),size=(500,500),style = wx.TE_MULTILINE)
from a file a text file.... this is the error im getting and the code im running

'clay', 'riley', 'nicole', 'fartgameone', 'two', 'three', 'forgut', 'food', 'hobo', 'thunder', 'dog']
['clay', 'riley', 'nicole', 'fartgameone', 'two', 'three', 'forgut', 'food', 'hobo', 'thunder', 'dog', 'dod']
['clay', 'riley', 'nicole', 'fartgameone', 'two', 'three', 'forgut', 'food', 'hobo', 'thunder', 'dog', 'dod', 'fut']
['clay', 'riley', 'nicole', 'fartgameone', 'two', 'three', 'forgut', 'food', 'hobo', 'thunder', 'dog', 'dod', 'fut', 'kkfkjkfj']
['clay', 'riley', 'nicole', 'fartgameone', 'two', 'three', 'forgut', 'food', 'hobo', 'thunder', 'dog', 'dod', 'fut', 'kkfkjkfj', 'kkfkjkfj']
Traceback (most recent call last):
  File "C:\Python26\sign\turkeydayversionnov27.py", line 987, in staffing
    self.name_of1 = wx.TextCtrl(panel, -1,self.staff1,pos=(30,30),size=(500,500),style = wx.TE_MULTILINE)
  File "C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\_controls.py", line 1736, in __init__
    _controls_.TextCtrl_swiginit(self,_controls_.new_TextCtrl(*args, **kwargs))
TypeError: String or Unicode type required

 def staffing(self,event):
        frameV = wx.Frame(None, -1,
                         "Staffing",
                         pos=(50,50), size=(720,720),
                         style=wx.DEFAULT_FRAME_STYLE)
        panel=wx.Panel(frameV)
        self.population(self)
        certlist=['Basic','Intermediate','Paramedic']
       
        wx.StaticText(panel, -1, 'Name of Provider',(30,0))
        self.name_of1 = wx.TextCtrl(panel, -1,self.staff1,pos=(30,30),size=(500,500),style = wx.TE_MULTILINE)
        #-------------------buttons---------------------------------------
        self.btnsave = wx.Button(panel, -1, "&Save", (30,630))
        self.btnsave.Bind(wx.EVT_BUTTON, self.personelstaff, self.btnsave)        
        self.btnupdate = wx.Button(panel, -1, "&Update", (120,630))
        self.btnupdate.Bind(wx.EVT_BUTTON, self.updatepersonelstaff, self.btnupdate)
        #-------------------------------------------------------------------------
        self.frameV = frameV      
        self.frameV.Show()
    def personelstaff(self,event):
        
        dlg = wx.MessageDialog(self, "Caution", caption = "If you have data already saved it will be lost" , style = wx.OK | wx.ICON_EXCLAMATION)
        dlg.ShowModal()
        dlg == wx.OK
        dlg.Destroy()
        self.personelstaffcontinue(self)
        
    def personelstaffcontinue(self,event):              
         
        fileD= open("staffer.txt","w")
        fileD.write("%s\n" %self.name_of1.GetValue())
        self.personel(self)
    def population(self,event):
        try:
            staff=[]
            staffing=open("staffer.txt")
            for line in staffing:
                staff.append(line.rstrip())
                self.staff1=staff 
                print self.staff1
                
            return staff
        except NameError:
            pass 
        
    def updatepersonelstaff(self,event):
         
        fileD= open("staffer.txt","a")
        fileD.write("%s\n" %self.name_of1.GetValue())
        fileD.close()
        self.repopulate(self)
        self.frameV.Destroy
    def supplies(self,event):

Open in new window

0
Comment
Question by:dolamitejenkins
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
Mytix earned 500 total points
ID: 34227730
the code in :
self.name_of1 = wx.TextCtrl(panel, -1,self.staff1,pos=(30,30),size=(500,500),style = wx.TE_MULTILINE)
should look something like:
self.name_of1 = wx.TextCtrl(panel, -1," ".join(self.staff1),pos=(30,30),size=(500,500),style = wx.TE_MULTILINE)
the reason is that self.staff1 is a list but it should be a string when you're trying to use it in the wx.TextCtrl.
Hope that makes sense
0
 

Author Closing Comment

by:dolamitejenkins
ID: 34227784
solved
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Less strange, but still introduction This introduction was added (1st August, 2011) to reflect some reactions.  Firstly, the term basics in the title of the article...  As any other word, it is a symbol with meaning attached to the word by some a…
Variable is a place holder or reserved memory locations to store any value. Which means whenever we create a variable, indirectly we are reserving some space in the memory. The interpreter assigns or allocates some space in the memory based on the d…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question