vicki@stanfield.net wrote:
Is it possible to specify a newline as the last
parameter to the join command so that the old value
followed by a newline followed by the new value gets
sent to the label? If that option is not available, how
can I make that happen? The code I have is shown below:
if returnedval:
returnedval = `returnedval`
old=self.outputbox.GetLabel()
print old
new=os.path.join(old, "\n", "")
new=os.path.join(new,returnedval)
print new
self.outputbox.SetLabel(new)
Well now... os.path.join() is intended to link together segments of a filename and directory path, in a platform-appropriate way. You seem to be using it to join together arbitrary strings into a single string, which is not its intent, and it will not give you what you want. (On Windows, os.path.join("root", "directory", "file") will return r"root\directory\file", while on Unix it will return "root/directory/file", and on Mac (I believe) "root:directory:file".)
What I believe you actually want is the string method join(), which is called from the string you wish to use as the "glue", and is passed a sequence of elements for that string to connect. Thus, you could call "*".join( ['1', '2', '3'] ) and get a result of "1*2*3". In your case, you want to use a newline ('\n') to join together your old value (old) and your new, returned value (returnedval), so you can do something like this:
new = '\n'.join( [old, returnedval] )
Whether your self.outputbox is something that can support a multi-line label is another question, which I can't answer without knowing just what sort of widget that is. By the way, after you call SetLabel(), it may be necessary to call Refresh() to force the widget to repaint itself before the new label will be visible.
Jeff Shannon
Technician/Programmer
Credit International