The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Python Programming
|
Program w/ text that can be highlighted
Discuss Program w/ text that can be highlighted in the Python Programming forum on Dev Shed. Program w/ text that can be highlighted Python Programming forum discussing coding techniques, tips and tricks, and Zope related information. Python was designed from the ground up to be a completely object-oriented programming language.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

October 30th, 2012, 11:40 PM
|
|
Registered User
|
|
Join Date: Oct 2012
Posts: 3
Time spent in forums: 52 m 14 sec
Reputation Power: 0
|
|
|
Program w/ text that can be highlighted
i just started python and am writing an error detection program - this program will present sentences to users and ask them to indicate errors - i would like to allow the users to click to highlight the error(s) in a sentence, move to the next sentence and repeat - whatever is highlighted will be copied and coded to a text file - so far, i haven't been able to find out how to create/code highlightable text, or if this is possible in python- if anyone knows how to do this it'd be appreciated -
|

October 31st, 2012, 12:34 AM
|
 |
Commie Mutant Traitor
|
|
Join Date: Jun 2004
Location: Norcross, GA (again)
|
|
First off, is this a console program, or a GUI program using a toolkit such as Tkinter? If the latter, it should be just a matter of setting the font properties for the highlighted section.
If it is a console program, then things are a bit trickier, and will depend on the operating system you are running under. If you are using a Unix type system such as Linux or MacOS X, you should be able to use the curses library. You'd need to read the documentation on it to work out how to set the colors. Under Windows, you can use the Python for Windows Extensions, I think, though I'm not certain how it would work; again, the documentation is the key.
|

October 31st, 2012, 01:31 AM
|
|
Registered User
|
|
Join Date: Oct 2012
Posts: 3
Time spent in forums: 52 m 14 sec
Reputation Power: 0
|
|
|
thanks for the steer - it's going to be a console program, the lab i'm in is being refurbished (i'm assuming windows but should probably ask) - i built something similar on matlab, then started on perl, now they want everyone to switch to python - python seems pretty friendly but i didn't know where to look - thanks again -
|

October 31st, 2012, 09:36 AM
|
 |
Contributing User
|
|
|
|
__________________
[code] Code tags[/code] are essential for python code!
|

October 31st, 2012, 01:59 PM
|
|
Contributing User
|
|
Join Date: Feb 2004
Location: San Francisco Bay
|
|
Quote: | Originally Posted by happer55 thanks for the steer - it's going to be a console program, the lab i'm in is being refurbished (i'm assuming windows but should probably ask) - i built something similar on matlab, then started on perl, now they want everyone to switch to python - python seems pretty friendly but i didn't know where to look - thanks again - | Then curses is your friend, but keep in mind that the highlighting, etc. will have to be done using the keyboard. There is no clicking to highlight or dragging/dropping with the mouse on the console. A particular terminal emulator may provide some mouse functionality to allow you to implement those, but (1) I don't know of any that do, (2) the protocol would be completely terminal-specific and nonportable if it did, and (3) curses will not help you here. If you're not okay with a keyboard-driven interface, I'd ditch the console for your interface and go with a GUI.
|

October 31st, 2012, 02:37 PM
|
|
Registered User
|
|
Join Date: Oct 2012
Posts: 3
Time spent in forums: 52 m 14 sec
Reputation Power: 0
|
|
|
Thanks to all, you saved me a lot of time. I'll go for a GUI, but this may get shot down (might confound the error detection task). I'm sure I'll have other problems, thanks again.
|

October 31st, 2012, 03:00 PM
|
 |
Contributing User
|
|
|
|
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|