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

Tile Button Size


Hello,

I'm trying to create a virtual keyboard for use on a touch screen
monitor. I'm using a grid 8x4 of ttk::button but at the moment the
buttons are too small. I need to make them 98x98 pixels. How can I do
this? I tried defining something below but it doesn't seem to work.
Any ideas?

style configure keyButtons -height 200 -width 200 -pady 2 -padx 2
ttk::button .a -text A -height 200
grid x .a

M.

O/H Michael ???a?e:

> Hello,

> I'm trying to create a virtual keyboard for use on a touch screen
> monitor. I'm using a grid 8x4 of ttk::button but at the moment the
> buttons are too small. I need to make them 98x98 pixels. How can I do
> this? I tried defining something below but it doesn't seem to work.
> Any ideas?

> style configure keyButtons -height 200 -width 200 -pady 2 -padx 2
> ttk::button .a -text A -height 200
> grid x .a

> M.

The following code will ensure that all buttons are at least 98 pixels:

package require tile
for {set row 0} {$row < 4} {incr row} {
   grid rowconfigure . $row -weight 1 -uniform buttons -minsize 98
   for {set col 0} {$col < 8} {incr col} {
     if {!$row} {
       grid columnconfigure . $col -weight 1 -uniform buttons -minsize 98
     }
     grid [ttk::button .b$row$col -text "($row, $col)"] \
       -row $row -column $col -sticky snew
   }

}

George
On 12 May, 23:33, Georgios Petasis <peta@iit.demokritos.gr> wrote:

Thanks George. Your solution is working nicely. So I have:

variable TOP[ttk::frame .base]
pack $TOP -side top -expand true -fill both

set l [ttk::labelframe $pw.l -padding 1 -underline 1]
set l [ttk::labelframe $pw.l -padding 1 -underline 1]
$pw add $l -weight 1

ttk::entry $l.tel_num -textvariable ::tel_num  -width 40
ttk::entry $l.postcode -textvariable ::postcode
ttk::entry $l.property_id -textvariable ::property_id
ttk::label $l.1 -text Telephone
ttk::label $l.2 -text No
ttk::label $l.3 -text Postcode
grid $l.1 $l.tel_num -sticky ew -padx 2 -pady 2
grid $l.2 $l.property_id -sticky ew -padx 2 -pady 2
grid $l.3 $l.postcode -sticky ew -padx 2 -pady 2

set keyboard [ttk::frame $::BASE.keyboard]
for {set row 0} {$row < 4} {incr row} {
   grid rowconfigure  $keyboard $row -weight 1 -uniform buttons -
minsize 98
   for {set col 0} {$col < 8} {incr col} {
     if {!$row} {
       grid columnconfigure  $keyboard $col -weight 1 -uniform buttons
-minsize 98
     }
     grid [ttk::button $keyboard.b$row$col -text "($row, $col)"] \
       -row $row -column $col -sticky snew -command [list
keyBoardAction $row $col]
   }

}

$pw add $keyboard

In my application I the user selects an entry field and then uses the
virtual keyboard to enter the text. Each time a button is pressed then
the focus moves to the button. How can I keep focus on the entry
field?

Also I want to be able to hide and unhide the virtual keyboard. It is
as straight forward as making the height of the panel containing the
keyboard much smaller?

My final problem is that I want to run on a PDA as well as a touch
screen monitor. Is there a way to get the maximum screen size in
pixels automatically?

M.

O/H Michael ???a?e:

use -takefocus 0 when you create each button

> Also I want to be able to hide and unhide the virtual keyboard. It is
> as straight forward as making the height of the panel containing the
> keyboard much smaller?

Well it depends on your code. What widget is $pw?
In your case I will try to unmap the keyboard frame
(using pack/grid forget or similar...)
It is not a good idea to make it very small...
A better solution would have been the keyboard to be on a new toplevel
(without borders) that appears below/above the entry. When it is not
need it any more, you destroy it...

> My final problem is that I want to run on a PDA as well as a touch
> screen monitor. Is there a way to get the maximum screen size in
> pixels automatically?

winfo screenwidth .
winfo screenheight .

George

On 13 May, 14:18, Georgios Petasis <peta@iit.demokritos.gr> wrote:

Thanks George. I've taken your suggestion on destroying the panel for
when I change from letters to numbers and back again. I will use the
same technique for hiding and unhiding. Below is the updated code. The
focus tip you gave is working nicely. I added moving the cursor to the
right place with "icursor" and used the "focus" command to get the
widget name.

I am changing the input to a selection lists and have a question on
this but will start a new topic.

M.

set keys(abc) {
    {A B C D E F G H}
    {I J K L M N O P}
    {Q R S T U V W X}
    {Y Z "" "" 123 BACK DEL DONE}

}

set keys(123) {
    {"" "" 1 2 3 "" "" ""}
    {"" "" 4 5 6 "" "" ""}
    {"" "" 7 8 9 "" "" ""}
    {"" "" "" 0 ABC BACK DEL DONE}

}

proc makeKeyboard { keySet } {
   set keyboard [ttk::frame $::BASE.keyboard]
   for {set row 0} {$row < 4} {incr row} {
      grid rowconfigure  $keyboard $row -weight 1 -uniform buttons -
minsize 50
      for {set col 0} {$col < 8} {incr col} {
        if {!$row} {
          grid columnconfigure  $keyboard $col -weight 1 -uniform
buttons -minsize 50
        }
        set key [lindex [lindex $keySet $row] $col]
        grid [ttk::button $keyboard.b$row$col -takefocus 0 -text $key -
command [list keyAction $key]] \
          -row $row -column $col -sticky snew
      }
   }

   $::pw add $keyboard

}

makeKeyboard $keys(abc)

proc keyAction {key} {
   set Focus(Widget) [focus]

   if {$Focus(Widget) != "\."} {
      set eVar [lindex [split $Focus(Widget) \.] end]
   } else {
      set eVar none
   }
   if {$key == ""} {
      set key " "
   }
   switch -exact $key {
      "123" {
         destroy $::BASE.keyboard
         makeKeyboard $::keys(123)
      }
      "ABC" {
        destroy $::BASE.keyboard
         makeKeyboard $::keys(abc)
      }
      "BACK" {
        set ::$eVar [string range [set ::${eVar}] 0 end-1]
      }
      "DEL" {
        set ::$eVar ""
      }
      "DONE" {
        guigetdetails $::pw.l
      }
      default {
         if {$Focus(Widget) != "\."} {
            append ::$eVar $key
            set pos [string length [set ::$eVar]]
            if {$pos > -1} {
               $Focus(Widget) icursor $pos
            }
         }
      }
   }

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