#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    3
    Rep 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 -
  2. #2
  3. Commie Mutant Traitor
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2004
    Location
    Norcross, GA (again)
    Posts
    1,805
    Rep Power
    1570
    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.
    Rev First Speaker Schol-R-LEA;2 JAM LCF ELF KoR KCO BiWM TGIF
    #define KINSEY (rand() % 7) λ Scheme is the Red Pill
    Scheme in Short Understanding the C/C++ Preprocessor
    Taming Python A Highly Opinionated Review of Programming Languages for the Novice, v1.1

    FOR SALE: One ShapeSystem 2300 CMD, extensively modified for human use. Includes s/w for anthro, transgender, sex-appeal enhance, & Gillian Anderson and Jason D. Poit clone forms. Some wear. $4500 obo. tverres@et.ins.gov
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    3
    Rep 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 -
  6. #4
  7. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,837
    Rep Power
    480
    [code]Code tags[/code] are essential for python code and Makefiles!
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    San Francisco Bay
    Posts
    1,939
    Rep Power
    1313
    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.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    3
    Rep 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.
  12. #7
  13. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,837
    Rep Power
    480
    You may face a significant hurdle learning tkinter. This reference has been working for me recently.
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo