0

Right...so, I have two lists. One has 16 entries. The other at least has a couple hundred. Outputting them with EasyGUI is easy enough, with either a textbox() function or msgbox() function. The problem is that I want it to display with one list item per row, instead of a huge blob. How would I achieve this?

Here's an example of the code:

def print_comb_GUI(combinations):
    eg.textbox(combinations) #eg = EasyGUI

combinations is a list with about 100-200 entries (it depends) Every entry is a string.

Hersh S.
  • 197
  • 2
  • 10

2 Answers2

0

use '\n'.join

>>> import easygui as ea
>>> big_list = ['this', 'is', 'no', 'so', 'big']
>>> text = '\n'.join(big_list)
>>> ea.textbox(text=text)
joaquin
  • 82,968
  • 29
  • 138
  • 152
  • When I use that function, I instead get an error message TypeError: sequence item 0: expected str instance, list found – Hersh S. Apr 07 '12 at 23:33
  • It looks like what '/n'.join is for is individual strings. I want to do it for the entire list. – Hersh S. Apr 07 '12 at 23:42
  • @HershS : could you explain what do you understand for an 'entire list'?. why `big_list` in my code is not an 'entire list' for you ?. – joaquin Apr 07 '12 at 23:58
  • well, when I run the '/n'.join, it says that, instead of a list, it expected a string as a parameter. – Hersh S. Apr 08 '12 at 00:04
  • @HershS. : note is `'\n'.join` not `'/n'.join`, and you did not answered my question – joaquin Apr 08 '12 at 00:20
  • @joaquin: Traceback (most recent call last): File "GeneticsGUI.py", line 38, in print_comb_GUI(final) File "GeneticsGUI.py", line 6, in print_comb_GUI text ='\n'.join(combinations) TypeError: sequence item 0: expected str instance, list found – Hersh S. Apr 08 '12 at 00:24
  • Yeah, I know I didn't answer your question. What I'm saying is that '\n'.join doesn't work. – Hersh S. Apr 08 '12 at 00:25
  • @HershS.: You need to supply better information about the structure of your big list. @joaquin's answer works fine on a list of strings. Based on the comments from your other question, `combinations` is a 3-deep nested list. If you want good answers, you need to provide more information. – Joel Cornett Apr 09 '12 at 22:15
0

here is one example code I made. it will use part pseudo code, part python:

from easygui import *
list bigblobofitems = ["item1","item2","item3","item4","item5"]
list ForOutput = [empty]

x = 0
y = bigblobofitem.count()

while x != y and x < y:
    forOutput.append(bigblobofitems(x))
    forOutput.append("\n")
    x = x+1

msgbox(forOutput)