Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

error while populating wx.textCtrl

Posted on 2010-11-26
2
Medium Priority
?
644 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 2000 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

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. …
Article by: Swadhin
Introduction of Lists in Python: There are six built-in types of sequences. Lists and tuples are the most common one. In this article we will see how to use Lists in python and how we can utilize it while doing our own program. In general we can al…
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 …
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…
Suggested Courses

721 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