Text box

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jul 2009
Posts: 15
Reputation: catcit is an unknown quantity at this point 
Solved Threads: 0
catcit catcit is offline Offline
Newbie Poster

Text box

 
0
  #1
Aug 11th, 2009
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.
  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:
  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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,279
Reputation: sneekula has a spectacular aura about sneekula has a spectacular aura about 
Solved Threads: 176
sneekula's Avatar
sneekula sneekula is offline Offline
Nearly a Posting Maven

Re: Text box

 
2
  #2
Aug 11th, 2009
Set up a formatted string before you send it to the Textbox. Here is an example:
  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. """
No one died when Clinton lied.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 15
Reputation: catcit is an unknown quantity at this point 
Solved Threads: 0
catcit catcit is offline Offline
Newbie Poster

Re: Text box

 
0
  #3
Aug 11th, 2009
Thanks! This is exactly what I was looking for.
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 1,026
Reputation: woooee is a jewel in the rough woooee is a jewel in the rough woooee is a jewel in the rough 
Solved Threads: 288
woooee woooee is offline Offline
Veteran Poster

Re: Text box

 
1
  #4
Aug 12th, 2009
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.
Linux counter #99383
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Python Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC