943,865 Members | Top Members by Rank

Ad:
  • Python Discussion Thread
  • Unsolved
  • Views: 736
  • Python RSS
Aug 11th, 2009
0

Text box

Expand Post »
Hello!

I have a little problem. I have to print a table (four columns from an Excel file) in a text box. I took a string and I kept appending all the cells from the file that interested me and I used the textbox provided by easygui.
Python Syntax (Toggle Plain Text)
  1. textbox(msg='', title=' ', text='', codebox=0)
Here are my problems:

1.I want to format the text to look like one piece. The text looks like this:
Python Syntax (Toggle Plain Text)
  1. TimeStamp Ipv Upv-Ist Power
  2. 6.15 0.0 293.92 0.0
  3. 6.30 0.0 315.21 0.0
  4. 6.45 0.11757 272.14 31.9954998
  5. 7.00 0.19193 283.44 54.4006392
  6. 7.15 0.25029 292.55 73.2223395
  7. 7.30 0.30235 301.25 91.0829375
  8. 7.45 0.35982 320.71 115.3978722
  9. 8.00 0.75405 313.93 236.7189165
  10. 8.15 1.12258 316.05 354.791409
  11. 8.30 1.5482 314.7 487.21854
and I want it to be more nicely arranged (every line to be in it`s place). How can I do that?

2. Is there any way to convert it to read only? Normally the user is able to modify the text but I want it to be read only.

I`m interested if this things are possible using the textbox provided by easygui or I have to modify it and use something else (tkinter etc.).
Thanks!
Last edited by catcit; Aug 11th, 2009 at 9:58 am.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
catcit is offline Offline
22 posts
since Jul 2009
Aug 11th, 2009
2

Re: Text box

Set up a formatted string before you send it to the Textbox. Here is an example:
python Syntax (Toggle Plain Text)
  1. # example to set up a table formatted string
  2.  
  3. import math
  4.  
  5. # set up the format strings (use - for left justified)
  6. header = "%-12s %-12s %-12s \n"
  7. line_fs = "%-12f %-12.4f %-12.4f \n"
  8.  
  9. table = ''
  10. table += (header % ('radians', 'sine', 'cosine'))
  11. for x in range(0, 11):
  12. rad = math.radians(x)
  13. table += (line_fs % (rad, math.sin(rad), math.cos(rad)))
  14.  
  15. print(table)
  16.  
  17. """my output (use a fixed font like Courier) -->
  18. radians sine cosine
  19. 0.000000 0.0000 1.0000
  20. 0.017453 0.0175 0.9998
  21. 0.034907 0.0349 0.9994
  22. 0.052360 0.0523 0.9986
  23. 0.069813 0.0698 0.9976
  24. 0.087266 0.0872 0.9962
  25. 0.104720 0.1045 0.9945
  26. 0.122173 0.1219 0.9925
  27. 0.139626 0.1392 0.9903
  28. 0.157080 0.1564 0.9877
  29. 0.174533 0.1736 0.9848
  30. """
Reputation Points: 961
Solved Threads: 211
Nearly a Posting Maven
sneekula is offline Offline
2,413 posts
since Oct 2006
Aug 11th, 2009
0

Re: Text box

Thanks! This is exactly what I was looking for.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
catcit is offline Offline
22 posts
since Jul 2009
Aug 12th, 2009
1

Re: Text box

Quote ...
2. Is there any way to convert it to read only? Normally the user is able to modify the text but I want it to be read only.
Use the codebox
"Display some text in a monospaced font, with no line wrapping.
This function is suitable for displaying code and text that is
formatted using spaces.

The text parameter should be a string, or a list or tuple of lines to be
displayed in the textbox."
http://easygui.sourceforge.net/curre....html#-codebox

So you can send a list of lines to be printed. Sweet.
Last edited by woooee; Aug 12th, 2009 at 5:29 pm.
Reputation Points: 741
Solved Threads: 692
Nearly a Posting Maven
woooee is offline Offline
2,305 posts
since Dec 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Python Forum Timeline: How to split a string every 3 spaces?
Next Thread in Python Forum Timeline: Pressing a key to type a string





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC