chessgui has asked for the wisdom of the Perl Monks concerning the following question:
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Eliminate blinking cursor from text widget
by BrowserUk (Patriarch) on Jan 14, 2012 at 13:23 UTC | |
If you add -state => readonly to a normal Entry widget, it both stops it being edited and prevents the insertion cursor (blinking vertical bar) being shown. It might have the same effect on a ROText widget too, but you don't need that if you set normal entry widgets readonly. With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] |
by chessgui (Scribe) on Jan 14, 2012 at 13:37 UTC | |
I also wonder which is the easiest way to determine the field on which I have clicked in terms of _text_ x and y coordinates.
What should ... be? (I admit that I haven't dome my research on that one yet.) | [reply] [d/l] |
by BrowserUk (Patriarch) on Jan 14, 2012 at 14:04 UTC | |
If you do the bind like this:
Then when you click on entry field 1 ($ef1) the subroutine 'fred' will be called with the handle of $ef1 as the first parameter, and the value 'bill' as the second. Now you can program whatever action is required. With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] [select] |
by chessgui (Scribe) on Jan 14, 2012 at 14:49 UTC | |
| [reply] |
by BrowserUk (Patriarch) on Jan 14, 2012 at 15:10 UTC | |
I take it from that you've been using a multi-line Text widget. The problem I foresee is that whilst in a Text widget, a button-1 click sets the insertion cursor to the character under the mouse, if you make it readonly and disable the insertion cursor, will the button-1 binding still work? I would use an 8x8 grid of Entry widgets. That way, each click identifies which symbol is clicked. With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] |
by chessgui (Scribe) on Jan 14, 2012 at 15:12 UTC | |
You should set the insertOnTime option (which controls the time in millisecons for which the blinking cursor is on) to zero. $text_widget->configure(-insertontime=>0); | [reply] |
|
Re: Eliminate blinking cursor from text widget
by zentara (Cardinal) on Jan 15, 2012 at 11:40 UTC | |
Why even use the Text widget? A Canvas can also display any chess font which the Text widget can. The Canvas won't have a cursor to deal with, plus gives many options for implementing drag'n'drop, etc. Here is a chessboard for you to start with.
I'm not really a human, but I play one on earth. Old Perl Programmer Haiku ................... flash japh | [reply] [d/l] |
by chessgui (Scribe) on Jan 16, 2012 at 10:31 UTC | |
On the other hand doing things by using a canvas is much more complicated. You may know that in chess positions are stored in fen strings. If you substitute slashes with newlines and digits with as many spaces as the digit says in the first field of a fen string you practically have a string which inserted in a text widget represents a chess board (you only have to make corrections for white and black squares). This is a matter of few regular expressions. No screen coordinates, sizes etc. need to be calculated whatsoever making things temptingly simple and quicker as well since the drawing of the board is a matter of $text_widget->insert('1.0',$corrected_fen_string) rather than looping over x and y coordinates, calculating the screen coordinates for each and every square then drawing them. | [reply] |
by zentara (Cardinal) on Jan 16, 2012 at 11:38 UTC | |
Yes, but you get the power to do things like a real game. On a Canvas, the trick is to store the relevant data for each piece in a canvas item tag. It's a simple concept, but hard to grab at first. Here are a few examples. The first shows how to drag a text item, like your unicode chess piece. You can tell which square they are dropped in by setting up tags on the positional squares. The second example shows how to use tags creatively. The third shows how to dynamically manipulate tags. Creative tag manipulation More tag manipulation
I'm not really a human, but I play one on earth. Old Perl Programmer Haiku ................... flash japh | [reply] [d/l] [select] |