\documentclass[]{article}
\usepackage{amsmath,graphicx,supertabular,hyperref,tabularx,ifthen}
\title{TIP \#319: Implement Backwards Compatibility for ttk Themed Widgets in tk Widgets}
\date{June 04, 2008}
\author{Eric Taylor}
\urlstyle{sf}
\setlength{\parskip}{1ex}
\setlength{\parindent}{0pt}
\def\tipversion$#1${\texttt{\$#1\$}}
\def\tiplangle#1{\ensuremath{<}}
\def\tiprangle#1{\ensuremath{>}}
\def\tipbar#1{\ensuremath{|}}
\def\tipmail#1#2{\(\langle\){\small\expandafter\url{#1@#2}}\(\rangle\)}
\ifx\pdfoutput\undefined
\newcommand{\tipimage}[2]{\typeout{Make sure you download #1.eps}\ifthenelse{\lengthtest{0.8\textwidth>#2}\and\lengthtest{0pt<#2}}{\includegraphics{#1.eps}}{\includegraphics[width=0.8\textwidth]{#1.eps}}}
\newcommand{\tipxref}[1]{}
\newcommand{\tipxrefend}{}
\else
\newcommand{\tipimage}[2]{\typeout{Make sure you create #1.pdf}\ifthenelse{\lengthtest{0.8\textwidth>#2}\and\lengthtest{0pt<#2}}{\includegraphics{#1.pdf}}{\includegraphics[width=0.8\textwidth]{#1.pdf}}}
\pdfcatalog{/PageMode /UseOutlines}
\newcommand{\tipxref}[1]{\pdfannotlink attr {/C [0.5 0.5 1.0] /Border [0 0 1]} goto name {#1}}
\newcommand{\tipxrefend}{\pdfendlink}
\fi
\newenvironment{tipabstract}{\begin{abstract}}{\end{abstract}}
\begin{document}\maketitle
\begin{center}\begin{tabularx}{\linewidth}{|r@{: }X|}\hline
\textbf{TIP \#319}&\textbf{Implement Backwards Compatibility for ttk Themed Widgets in tk Widgets}\\\hline
Author&

Eric Taylor \tipmail{et2}{rocketship1.biz}
\\
Created&Wednesday, \(\text{4}^{\text{th}}\) June 2008\\
Type&Project\\
Tcl Version&\(8.7\)\\
State&Draft\\
Vote&Pending\\
Version&\tipversion$Revision: 1.4 $\\
Post History&\\
\hline\end{tabularx}\end{center}
\thispagestyle{empty}\pagestyle{empty}
\begin{tipabstract}

This TIP calls for the implementation of backward compatibility between ttk themed widgets and conventional tk widgets. It does this by describing configuration options that specify how to deal with unsupported options (error, ignore, or call supplied callbacks) where full compatibility is not feasible. Configuration should be both global (all widgets) and specific (by class or individual widget).
\end{tipabstract}
\tableofcontents\setcounter{page}{0}\clearpage\pagestyle{plain}

\section{Rationale}

Tk 8.5 now includes a parallel set of widgets, created through calls to similar widget constructors, but invoked using the namespace \textbf{ttk::} prepended to the name of an existing widget. For example, \textbf{ttk::button} creates a themed button, while the unqualified \textbf{button} creates standard Tk button widgets.

One of the stated purposes of these new widgets is to bring Tk up to the standards now expected for attractive looking GUI programs. The \textbf{ttk} package does this quite well, but only for new programs. Imagine the leverage we would have if we could upgrade older programs (easily and automatically) to use these widgets. While one can use an editor and add in the \textbf{ttk::} to each widget creation call (which then begs the question of why we can't have this done automatically with a simple configuration procedure) one is often stuck when trying to implement the same behavior since many Tk options which are currently unsupported in ttk.

In addition, there are packages, such as visual tcl, which write conventional tk code. These programs cannot easily be converted to use the new widgets, but still need to be maintained using the vtcl program.

This TIP proposes that all current Tk widget options be supported where feasible and that the following command be fully implemented to permit older Tk-oriented programs run unaltered using the themed set of widgets.
\begingroup\small\begin{verbatim}
namespace import -force ttk::*
\end{verbatim}
\endgroup

Since the ttk widgets don't have all the same options, there would need to be some compatibility code that could simulate the old behavior. For example, in \textbf{button}, there is no longer a \textbf{-background} color option, nor is there \textbf{-padx} and \textbf{-pady}. Sometimes these missing options can be implemented, for example, using \textbf{-padding} would let one implement partial behavior. While it would be preferable to implement these options directly, an alternative would be to select a compatability handling mode of ignore, error, or callback to aid the developer in implementing missing options.

\section{Proposal}

To that purpose, I propose some kind of configuration option, for example:

\begin{quote}
\textbf{ttk::compatibility} ?\textbf{-onerror} [\textbf{ignore}\tipbar{}\textbf{error}\tipbar{}\textbf{callback}]? ?\textbf{-callback} \textit{proc}? ?\textbf{-class} [\textit{widget-class}\tipbar{}\textbf{all}]?
\end{quote}

When the callback procedure is invoked, it should be passed additional parameters which would completely identify,
\begin{enumerate}
\item{}
The widget (e.g. \textbf{.frame.button})
\setcounter{enumi}{1}
\item{}
The option that is not directly supported (e.g. \textbf{-pady})
\setcounter{enumi}{2}
\item{}
The value specified for that option (the argument following the \textit{-option})
\setcounter{enumi}{3}
\item{}
Anything else I've forgotten
\end{enumerate}

The above should also be configured globally (all widgets) or on a widget by widget basis. For individual widgets, there should be a configuration option for the above.

I would think that most of this should be implementable with pure tcl/tk proc's.

\section{Copyright}

This document has been placed in the public domain.

\section{Colophon}

\textit{TIP AutoGenerator --- written by Donal K. Fellows}
\end{document}
