Solved

error while populating wx.textCtrl

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
linux / python expert needed 3 111
Python negative lookahead for aaa:bbb@hostname 6 143
Python Install On Mac Yosemite 8 196
Export Table to CSV - Access to CSV - using python 18 292
Strings in Python are the set of characters that, once defined, cannot be changed by any other method like replace. Even if we use the replace method it still does not modify the original string that we use, but just copies the string and then modif…
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 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 while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

734 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