Typing Arabic language in TK entry and text on starting from Mac OS X 10.9 plus starting from Windows Xp , is easy and comes out of the box, and without any interference from the programmers. However, on Linux this is not the case. The Arabic characters are put isolated and the words come in the reversed order. Therefore, I made the widget text to let the user type Arabic in a more readable way. This is still a starting point. I am soon going to develop it to make it better.

text .t

bind .t <KeyRelease> {
 #Keys that must not modify the order of the letters
 set keys [list Arabic_comma Arabic_semicolon Arabic_question_mark ISO_Next_Group BackSpace Space Home End Tab CapsLock Delete F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 KP_Enter Return Escape Up Right Down Left Win_R Win_L Pause Insert Alt_R Alt_L Shift_R Shift_L]
 if  { [lsearch $keys "%K"] > -1 } {
 return
 }

 set last_char [ .t get "insert-1 chars" ] ; #the last character is the one before insert cursor position
 set previous_to_last [ .t get "insert-2 chars" ] ; #the previous_to_last character is the one before insert cursor by two positions
 puts $last_char
 if { [regexp {[A-Za-z0-9]} $last_char ] ==1 } { return }
 set punctuations [list " " ؟  , < > ! ّ َ ً ِ ٍ ُ ٌ ْ"\t"]
 if { [lsearch $punctuations $last_char] > -1 } { 
  if { [regexp {[A-Za-z0-9.]} $previous_to_last ] !=1 } { 
    
    
    .t mark set insert "insert-1 chars" 
    return
    }
 return 
 }

  
     
        .t mark set insert "insert-1 chars"
        set sub_word [ .t get "insert+1c" ] ; #the last ARABIC character

        puts "convert1 $sub_word"
        set sub_word [ string map {
        \u0628 \ufe91
        \u062A \ufe97
        \u062B \ufe9b
        \u062C \ufe9f
        \u062d \ufea3
        \u062e \ufeA7
        \u0633 \ufeb3
        \u0634 \ufeb7
        \u0635 \ufebb
        \u0636 \ufebf
        \u0637 \ufec3
        \u0638 \ufec7
        \u0639 \ufeCb
        \u063A \ufeCF
        \u0641 \ufeD3
        \u0642 \ufeD7
        \u0643 \ufeDb
        \u0644 \ufedf
        \u0645 \ufee3
        \u0646 \ufee7
        \u0647 \ufeeb
        \u064A \ufef3
        \u0626 \ufe8b
        } $sub_word] ;#ba2
        if {$sub_word ==" " } { return }
        .t delete "insert+1c"
        .t insert "insert+1c" $sub_word
        #.t mark set insert "insert-1 chars"
        puts "convert $sub_word" 
 puts [.t index insert]
}


pack .t