Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

TCL(Tool Command Language) Scripting

tablelist key binding and wcb


I am now working on a header detail data entry and I'm having some
trouble with tablelist key binding and how use wcb to validate cell
entry and convert cell entry to uppercase.

   package require Tk
   package require tablelist

   tablelist::tablelist .t -columns {0 "First Column" 0 "Another
   column"} -stretch all -background white

   pack .t

   .t insert end [list "first row" "another value"]
   .t insert end [list "another row" "bla bla"]

   bind [ .t bodytag ] <F9>   \
       { tk_messageBox -title "Pick List" \
         -message "Select an item!" -type ok
         focus .t }

   bind [ .t bodytag] <1> { focus [.t bodypath] }

   .t columnconfigure 0 -editable yes

1. With the example above the F9 key doesn't get triggered when the
cursor is on an editable column/cell.

2. Will someone be kind enough to show me a simple example on how to
use wcb with tablelist. Like limiting length of entry and converting
to uppercase.

Please I urgently need everyones help here since I need to delivery
this program by Monday.

Thanks.

tcltk@aol.com schrieb:

As explained in the documentation, the binding tag [.t bodytag] is only
associated with the body of the tablelist widget, the separators, and
some other embedded widgets, but not with the temporary entry widget
used for interactive cell editing.  For this reason, you will have to
repeat the bind command for that entry (see the example below).
Alternatively, you could add the binding tag [.t bodytag] to the list of
binding tags of the entry widget.

> 2. Will someone be kind enough to show me a simple example on how to
> use wcb with tablelist. Like limiting length of entry and converting
> to uppercase.

The Tablelist demo script "miscWidgets.tcl" illustrates how to do this.
  See below for another example.

> Please I urgently need everyones help here since I need to delivery
> this program by Monday.

> Thanks.

Here is a modified version of your script, with <F9> working during
interactive cell editing, too, and in which the temporary entry widget
limits the user input to max. 20 characters and does automatic uppercase
conversion:

package require Wcb
package require tablelist

tablelist::tablelist .t \
     -columns {0 "First Column" 0 "Another column"} \
     -stretch all -background white -editstartcommand editStartCmd

pack .t -expand yes -fill both

.t insert end [list "FIRST ROW" "another value"]
.t insert end [list "ANOTHER ROW" "bla bla"]

bind [.t bodytag] <F9> {
     tk_messageBox -title "Pick List" \
         -message "Select an item!" -type ok

}

bind [ .t bodytag] <1> { focus [.t bodypath] }

.t columnconfigure 0 -editable yes

proc editStartCmd {tbl row col text} {
     set w [$tbl editwinpath]

     bind $w <F9> {
         tk_messageBox -title "Pick List" \
             -message "Select an item!" -type ok
     }

     wcb::callback $w before insert \
         {wcb::checkEntryLen 20} wcb::convStrToUpper

     return $text

}

--
Csaba Nemethi   http://www.nemethi.de   mailto:csaba.neme@t-online.de
On May 12, 3:14 am, Csaba Nemethi <csaba.neme@t-online.de> wrote:

Thank you very much.
By the way, I have one more question I forgot to ask. How do I
determine/get the current cell where
the cursor actually is?
tcltk@aol.com schrieb:

> By the way, I have one more question I forgot to ask. How do I
> determine/get the current cell where
> the cursor actually is?

If you mean the cursor during interactive cell editing then the answer
is quite simple:  The row and column indices are passed to the
procedures specified as the values of the -editstartcommand and
-editendcommand options.

If you mean the mouse pointer then you can use the containingcell
subcommand within a binding script, as shown in the following example,
taken from the "DEFAULT AND INDIVIDUAL BINDINGS FOR THE TABLELIST BODY"
section of the reference manual:

bind [.tbl bodytag] <Button-1> {
     foreach {tablelist::W tablelist::x tablelist::y} \
         [tablelist::convEventFields %W %x %y] {}
     puts "clicked on cell \
         [.tbl containingcell $tablelist::x $tablelist::y]"

}

--
Csaba Nemethi   http://www.nemethi.de   mailto:csaba.neme@t-online.de
On May 12, 4:55 pm, Csaba Nemethi <csaba.neme@t-online.de> wrote:

> tcltk@aol.com schrieb:

> > By the way, I have one more question I forgot to ask. How do I
> > determine/get the current cell where
> > the cursor actually is?

> If you mean the cursor during interactive cell editing then the answer
> is quite simple:  The row and column indices are passed to the
> procedures specified as the values of the -editstartcommand and
> -editendcommand options.

Yap. I tried it in the example you gave using -editstartcommand and
it's working fine. Thanks.

Using -editendcommand command is there a way I can prevent the user
from moving/clicking another cell if the value is invalid? Will you
kindly show me an example if any.

Thanks again.

tcltk@aol.com schrieb:

Use the rejectinput subcommand, as shown below.  Here are the necessary
changes in the example script:

. . .

tablelist::tablelist .t \
     . . .
     -editendcommand editEndCmd

. . .

proc editEndCmd {tbl row col text} {
     if {$text eq "BAD VALUE"} {
         tk_messageBox -title Error -icon error -type ok -message \
             "Cannot accept this value!"
         $tbl rejectinput
     }

     return $text

}

Type "BAD VALUE" into a cell and then test what happens if you try to
finish the editing by using the mouse or keyboard navigation.

--
Csaba Nemethi   http://www.nemethi.de   mailto:csaba.neme@t-online.de

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc