Tile

Difference between version 106 and 107 - Previous - Next
#package require sqlite3
#sqlite3 db :memory:
#
#set a 13
#set b [expr {13 + 0}]
#
#db eval {
#        create table t (
#                v text
#        )
#        ; insert into t values($a)
#}
#
#db eval {
#        select v , typeof(v) as type from t
#} {
#        puts [list hey $type]
#}
#
#db eval {
#        select v , typeof(v) as type from t where v = $b
#} {
#        puts [list jey $type]
#}
#


#package require {ycl proc}
#
#namespace eval n1 {
#        namespace export *
#        proc hello {} {
#                puts hello!
#                rename hello {}
#                proc hello {} {
#                        puts goodbye!
#                }
#        }
#}
#
#namespace eval n2 {
#        [yclprefix]::proc alias hello [namespace parent]::n1::hello
#        hello
#        hello
#}
#
#


#package require sqlite3
#
#sqlite3 db :memory:
#set a 0xfa
#expr {$a + 3}
#puts [::tcl::unsupported::representation $a]
#set a [string range $a[set a {}] 0 end] 
#puts [::tcl::unsupported::representation $a]
#
#db eval {
#        create table t1 (
#                v numeric
#        )
#        ; insert into t1 values (@a)
#}
#
#db eval {
#        select v ,typeof(v) as type from t1
#} {
#        puts [list hey $v $type]
#}
#
'''[http://tktable.sourceforge.net/tile%|%tile]'''  is a re-implementation of
many of the core Tk widgets, along with the addition of several new widgets.
It later was incorprated via [TIP]
[https://core.tcl.tk/tips/doc/trunk/tip/248.md%|%248] into [Tk] as [TTK]. 



** See Also **

   [The difference Tile makes]:   

   [Tile Treatise%|%A Treatise on Tile]:   

   [Applications using Tile]:   

   [How to migrate to Tile]:   



** Attributes **

   repository:   https://chiselapp.com/user/pooryorick/repository/tile

   repository:   https://chiselapp.com/user/pooryorick/repository/tile-themes

   repository:   https://chiselapp.com/user/pooryorick/repository/tile-www

   version:   0.8.4.0

   release time:   2010-11-29

   mailing list:   http://lists.sourceforge.net/lists/listinfo/tktable-tile-dev



** Description **

'''Tile''' implements the [Tk] theming engine work discussed in [Tk Style Support].  Among other things it provides native look and feel [widget]s such as:

   * [ttk::button%|%button%|%]
   * [ttk::checkbutton%|%checkbutton%|%]
   * [checkbox],
   * [ttk::combobox%|%combobox%|%],
   * dialog,
   * [ttk::entry%|%entry%|%],
   * [ttk::frame%|%frame%|%],
   * image
   * [ttk::label%|%label%|%],
   * [ttk::labelframe%|%labelframe%|%],
   * [ttk::menubutton%|%menubutton%|%],
   * [ttk::notebook%|%notebook%|%],
   * [ttk::panedwindow%|%panedwindow%|%],
   * [ttk::progressbar%|%progressbar%|%],
   * [ttk::radiobutton%|%radiobutton%|%],
   * [ttk::scrollbar%|%scrollbar%|%],
   * [ttk::separator%|%separator%|%],
   * [ttk::sizegrip%|%sizegrip%|%],
   * [ttk::treeview%|%treeview%|%]

for [Windows] XP, [MacOS]-X.  [[Notice that Tile also supplies a [style] command.]]

It also provides mechanism to easily create or import [themes].
More concretely, the vernacular goal seems to be the ability to claim that "[Tk widgets look fine under Windows]", both in widget appearance and widget availability.

[JE]: For me, the main goal is to provide a better way to build widgets.  
Making things look fine under Windows (and other platforms) is certainly important,
and it's what end-users will most appreciate, but that's really a secondary goal.

As of October 2006, Tk 8.5 will include Tile (see also [TIP] #248) as [Ttk]. The Tk version 8.5a6 (alpha version 6) already includes Tile in the ttk namespace.

[DKF] 2007-01-15: See below for five screenshots of the ''same'' process with many widgets and different themes. This was prepared with

[http://www.cs.man.ac.uk/~fellowsd/tcl/themes.png]

The themes, from left to right, are: '''classic''', '''clam''', '''alt''', '''xpnative''' (the default on my system), and '''winnative'''. Note that the only thing that changes between them is the theme; nothing else at all changed.

Additional [Tile themes] are being maintained in the tile-themes module of the tile project on SourceForge.

----

[LV]: The move from Tile to [Ttk] has begun. But what puzzles me is that, even though the code appears to have been integrated into the [Tk] 8.5 source line, the Tile source code still is getting updated.

So does this mean that someone is going to have to spend several months porting Tile changes into Tk 8.5?

[JE]: Yes.  Tile will be maintained as an 8.4-compatible extension for as long as Tcl/Tk 8.4 remains a viable platform.
It will take a while before everyone can upgrade to 8.5.



** Usage **

The following instructions are for the Tile ''package'', not for the ttk included in Tk 8.5. There are subtle differences, such as tile::setTheme becoming ttk::setTheme and others.

====== 
package require tile
tile::setTheme <theme name>
====== 

`tile::setTheme` sets the theme to the value specified. The currently available themes are:  classic, default, alt, winnative, xpnative, step, aqua (depending on your platform). More info is here: [http://www.t-ide.com/tcl2005e/2_tile-eurotcl2005.pdf.gz]

To list the available themes in an app with the command:

====== 
tile::availableThemes
====== 

To query the current theme by getting the value of the variable tile::currentTheme

====== 
puts $tile::currentTheme
====== 


If you need to know some colors that are used by a theme, because you need to adjust Tk stuff to fit in, you can use the array tile::theme::<theme name>::colors like e.g.:

======none
parray tile::theme::clam::colors
====== 

'''Output:'''

======none
tile::theme::clam::colors(-dark)       = #cfcdc8
tile::theme::clam::colors(-darker)     = #bab5ab
tile::theme::clam::colors(-darkest)    = #9e9a91
tile::theme::clam::colors(-disabledfg) = #999999
tile::theme::clam::colors(-frame)      = #dcdad5
tile::theme::clam::colors(-lighter)    = #eeebe7
tile::theme::clam::colors(-lightest)   = #ffffff
tile::theme::clam::colors(-selectbg)   = #4a6984
tile::theme::clam::colors(-selectfg)   = #ffffff
====== 

The 'default' theme colors are here (or so I believe):

====== 
parray ::tile::colors
====== 

'''Output:'''

======none
::tile::colors(-activebg)   = #ececec
::tile::colors(-darker)     = #c3c3c3
::tile::colors(-disabledfg) = #a3a3a3
::tile::colors(-frame)      = #d9d9d9
::tile::colors(-indicator)  = #4a6984
::tile::colors(-selectbg)   = #4a6984
::tile::colors(-selectfg)   = #ffffff
====== 

I don't know if this is the official way to query theme colors, but it works!

[ZB] 2008-01-03:: not with every theme - f.e. not with winnative, neither with xpnative. Looks, that more proper way is `ttk::style lookup`

How do you know if a theme has changed?  If you need to be notified of a theme change because you then need to adjust some stuff in your own widgets, bind to the virtual event `<<ThemeChanged>>`. This event will be sent to each widget and you can then react in an appropriate way. Example:

====== 
bind .mytoplevel.mywidget <<ThemeChanged>> {do stuff here to adjust}
====== 



** [GTK]/[KDE] Look **

Some of tile themes try to replicate the look of popular [GTK]/[GNOME] and [QT]/[KDE] themes (like Red Hat Bluecurve).
This is not very useful if the end-goal is to integrate seamlessly with the Linux desktop, since the
default theme varies for each distribution and the user may have chosen a different theme anyways.
I suggest doing the same thing as in Windows XP and using the [QT] or [GTK] theming engine hooks to do the drawing.
Some links that can be useful :

http://www.freedesktop.org/Software/gtk-qt

http://ajgenius.us/Gnome/Themes/Tutorials/?id=GTKThemes

In any case, at the very least, it may be interesting to get ideas for Tile

[George Petasis] is working on a Qt theme for Tile using the QT theming engine (TileQt - [http://www.ellogon.org/petasis/index.php?option=com_content&task=view&id=24&Itemid=40]). Recently, TileGTK has been released (TileGTK -[http://www.ellogon.org/petasis/index.php?option=com_content&task=view&id=29&Itemid=45]) which uses GTK+ 2.12 styles for drawing widgets. Very nice! 



** Building Tile on Windows **

I run into many issues trying to get Tile compiling on Windows with XP theming support.
With help from Pat I managed to get it working. Here are the exact steps and requirements :

Windows XP Pro, no service packs installed (I run into some DLL dependencies when installing the latest
service packs but that may just be me :)

======none
VC++ 6.0
Tcl 8.4.6
Tk 8.4.6
Tile from CVS
Core Platform SDK February 2003 http://www.microsoft.com/msdownload/platformsdk/sdkupdate/
====== 

unpack tcl, tk and tile sources in c:\tcl c:\tk c:\tile

Setup environment:

======none
C:\Program Files\Microsoft Visual Studio\VC98\Bin\vcvars32.bat
C:\Program Files\Microsoft SDK\setenv.bat    (Important to get XP theme support!!)
cd c:\tcl\win
nmake -f makefile.vc INSTALLDIR=c:\opt\tcl
nmake -f makefile.vc INSTALLDIR=c:\opt\tcl install
cd c:\tk\win
nmake -f makefile.vc INSTALLDIR=c:\opt\tk TCLDIR=C:\tcl
nmake -f makefile.vc INSTALLDIR=c:\opt\tk TCLDIR=C:\tcl install
cd c:\tile\win
nmake -f makefile.vc TCLDIR=C:\tcl TKDIR=C:\tk OPTS=none
====== 



** Build instructions for Tile on MacOS X **

See for example [Tile and BLT together on MacOS X].



**  Thanks **

Among the people who deserve much gratitude and recognition for Tile's accomplishments are [Joe English], [Pat Thoyts], [Michael Kirkham], [George Petasis], 
[Mats Bengtsson], [Jeff Hobbs]...


** Regarding Tile 0.7 **

Hi, I tried...

====== 
namespace forget tk::*
namespace import ttk::*
====== 

right after a fresh interpreter start and a "package require tile". But all I get is: ''can't import command "label": already exists''

Would it be better to do:

====== 
interp alias {} label {} ttk::label
====== 

to enable themes without recoding?

[MG]:  The commands (like [label]) aren't imported from the ::tk:: namespace, but just exist in the global one - which is why your 'forget' didn't remove them. You'd have to overwrite them with the -force option:

====== 
namespace import -force ttk::*
====== 

----

[MAK]: Regarding the above, as of 0.7.x, Tile by default doesn't support compatibility options anymore for many widgets, where there are style replacements.  You can enable the compatibility options with a compile flag, in which case an interp alias would be better than namespace import.  BUT, if you don't enable the compatibility options, then you shouldn't do either.  Why?  Because you'll break some of Tk's built-in dialogs and such.  They'll expect to be calling Tk's own widgets and use some options that aren't supported by Tile's and you'll get errors.

Planning for the future, it would probably be better to go the other way: if Tile isn't available, then do:

====== 
interp alias {} ::ttk::label {} ::label
====== 

And change all of your code to use ttk::label, removing all of the uses of no-longer-supported options and moving them to the option database.  See generic/compat.h for a list.


** Misc **

[HP]: Installing on Ubuntu 5.10

Trick to installing on Ubuntu 5.10 was to change the tcl and tk paths to their tclConfig.sh, and tkConfig.sh:

======none
./configure --with-tcl=/usr/lib/tcl8.4 --with-tk=/usr/lib/tk8.4
====== 

----

[RS]: Hacked up this little demo, which shows a [notebook], a [treeview], a [combobox] and a [progressbar]. The combobox lists the available styles; when one is selected, it is immediately applied to all widgets:

[WikiDbImage tiledemo.jpg] [WikiDbImage tiledemo2.jpg]

AW: Note that these screenshots are from a Windows CE machine.

======
package require Tk
package require tile

pack [ttk::notebook .nb]
set t [ttk::treeview .nb.tree -padding 0]
$t heading #0 -text Treeview
.nb add $t -text Tree

set entry1 [$t insert {} end -text "first item"]
$t insert $entry1 end -text "a sublevel"
$t insert $entry1 end -text "another item"
set entry2 [$t insert {} end -text "second item"]

set c [ttk::combobox .nb.cb -values [lsort [style theme names]] -textvar style]
.nb add $c -text Combobox -sticky nw
bind $c <<ComboboxSelected>> {style theme use $style}

set p [ttk::progressbar .nb.pb -variable progress -mode indeterminate]
.nb add $p -text Progress -sticky new
set progress 0proc every {ms body} {eval $body; after $ms [namespace code [info level 0]]}
every 100 {incr ::progress}

.nb select $t

bind . <Escape> {exec wish $argv0 &; exit}
======

----

On TkAqua, TLabel's automatically dim their text when they're not foremost (through $widg state background). How can I disable this for one specific widget (which I always want to have easily readable, even if not foremost)?

[JE]: In current CVS (9 Jul 2006), explicitly setting ''$label configure -foreground black'' will take precedence over the state-specific theme settings.  See also SF bug #1517110.

[PWQ] 2006-03-27: You are not allowed. You want native look and feel don't you?, stop bleating because thats what you have got.

----


[MG] 2006-05-15: Does anyone know if there's full documentation available for Tile? I just started playing around with the Notebook widget but, aside from [RS]'s demonstration above and the error messages from using the commands incorrectly, I couldn't find any docs.

Answer: http://tktable.sourceforge.net/tile/doc/notebook.html

[MG]: Thanks!

Also, it looks like when there isn't enough room for all the tabs in a Notebook widget to be displayed, they're all shrunk to fit. Is this configurable? I'm trying to do an app which will likely have a lot of tabs with long names open at once, so them being in a scrollable frame or something like that would be handy, if possible. Thanks for your help. :)

----

[sbron] 2006-07-19: In a tile application on the Mac a toplevel should be pinstriped, but there is no ttk::toplevel command. So I came up with the following proc to easily convert an existing application that will look right, even on the Mac.

====== 
proc ttk::toplevel {w args} {
    eval [linsert $args 0 ::toplevel $w]
    place [ttk::frame $w.tilebg] -x 0 -y 0 -relwidth 1 -relheight 1
    set w
}
====== 

[WK]: If someone just wants to make an additional tile style for an image based button, here's a small snap-in to do it:

====== 
style default TButton -relief flat
style element create TButton2.button image img0 -map [list disabled img1 pressed img3 active img2]
style layout TButton2 {
    TButton2.button -children {
        Button.label
    }
}

ttk::button .button -command {puts Test} -style TButton2
====== 

(it assumes img0, img1, img2 and img3 are valid Tk images)



----

Important:
"[http://tktable.sourceforge.net/tile/WidgetGuide.html%|%Writing new widgets with Tile]"

Mildly journalistic:  "[http://www.unixreview.com/documents/s=10102/ur0610j/%|%Tile makes Tcl look good]"

Paper by [Joe English] (2004): "[http://tktable.sourceforge.net/tile/tile-tcl2004.pdf%|%The Tile Widget Set]"

----

MSH 2006-11-23: I have a question about style setting in the notebook, I have an application which currently uses a BWidget Notebook to display pages. I modify the font style and color to indicate the current state of the page (ie italic or red text indicates a certain state), As BWidget works badly with Tile, I would like to know how to change the style for individual tabs ? or even set the state of a tab to readonly and use the style map TNotebook.Tab !   One last point BWidget adds scroll buttons to the tabs when there is not enough space, other systems allow multiple rows of tabs, will the notebook have one of these functions added, as its current action (squash them up while I can) is not at all practical.

----

'''[tombert] 2010-03-07 05:17:58:'''

Hi all,

as I understood a widget is a collection of elements. When I enter "ttk::style element names" it returns with:
> focus Spinbox.uparrow downarrow Scrollbar.trough sizegrip leftarrow border Radiobutton.indicator ComboboxPopdownFrame.border Combobox.focus Button.border thumb uparrow rightarrow slider Spinbox.downarrow field Checkbutton.indicator client

But how do I get the layout for a single widget i.e. hows the layout for the combobox? There is nothing written of which element a single widget consists of ...
Can I create new widgets by defining new layouts? i.e. create a combobox with spinnbox arrows inside?

thx


<<categories>> Package | GUI