Solved

error while populating wx.textCtrl

Posted on 2010-11-26
2
617 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
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Python Hue issue with import 12 77
.properties file to call function/method 9 61
Python Regex Problem 24 134
Python:compare IP with IP:blahblah and output the entire line?? 7 61
A set of related code is known to be a Module, it helps us to organize our code logically which is much easier for us to understand and use it. Module is an object with arbitrarily named attributes which can be used in binding and referencing. …
Sequence is something that used to store data in it in very simple words. Let us just create a list first. To create a list first of all we need to give a name to our list which I have taken as “COURSE” followed by equals sign and finally enclosed …
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…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …

813 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now