Download presentation
Presentation is loading. Please wait.
Published by῾Ερμιόνη Τοκατλίδης Modified over 6 years ago
1
NexTk/NtkWidget A replacement for Tk ?! 1
2
History of NexTk George Peter Staplin (GPS) started ~ 2 years ago with a system for handling widgets Original title Tk9 Name changed to NexTk NtkWidget is based on NexTk 2
3
Architecture of TK Based on X11, support for windows and MacOS a lot of years later Basic widgets are implemented completely in C Widget parts are built and displayed using X11 (client- )functions Use of system fonts Options for widgets are additionally using an option database Geometry managers: grid, pack and place No alpha blending, no free rotation of texts 3
4
Structure of Tk Entry Widget (Tcl-code) Button Widget (Tcl-code)
Text Widget (Tcl-code) Entry Widget (C-code) Button Widget (C-code) Text Widget (C-code) Tk Base Layer (C-code) X11 Server (unix/linux) API and GDI (windows) X11/native Server (MacOS) 4
5
Architecture of NexTk (1)
Widgets und widget parts are built as images Widget code is Tcl code Images are built using megimage functions Freetpyeext for fonts/text Geometry managers: grid, pack(planned), place(planned) With alpha blending, with free text rotation 5
6
Components of NexTk megaimage: pixel image and blending functions
freetypeext: extension of freetype fonts for building text images and rotating texts objstructure: extension for building simple objects ntk: the collection of Tcl code building the base widgets 6
7
Architecture of NexTk (2)
Every pixel consists of 4 bytes r/g/b and alpha Ntk package is handling root windows and mouse and key events Use of openGL for displaying Running on linux and win32 at the moment 7
8
Architecture of ntkWidget (1)
Based mostly on NexTk with the following differences Use of itcl instead of objstructure and use of ntkWidgetImage instead of megaimage Use of GLMWFW (Graphic Library Multi Window FrameWork) as common platform independent base for handling root windows and mouse/key events Widget parts are constructed using itcl-ng classes with inheritance instead of objstructure 8
9
Architecture of ntkWidget (2)
In the future: use of ttk(tile) like architecture for handling themes (also using itcl-ng classes) ttk like theme handling implemented about 70% Namespace ensemble subcommands for the functionality, so no need to learn itcl for users of the package Linux only at the moment (no development environment for windows MacOS) 9
10
Structure of ntkWidget
… label button entry … grid render freetype megaimage GLMWFW (Graphic Library Multi Window FrameWork) openGL X11-Server (unix/linux) GDI-Library (win32) X11-Server (MacOS) 10
11
Building Tk like widgets
Widget parts are for example: window, border, text, scrollbar Every widget part is an image (a rectangle, a polygon, a text) Widget parts are put together using blending functions (megaimage) Transparency (alpha factor) is taken care of during blending The root window is also a widget/image which is handled during blending 11
13
ntkWidget Hierarchy helpers render gridManager gridData window grid
theme / ttk theme pack button place 13
14
ntkWidget base widgets
Box Button Checkbox Clock Entry Frame Listbox Menu Text Toplevel 14
15
ntkWidget commands ::ntk toplevel [options] ntk button [options]
ntk checkbox [options] ntk clock [options] : ntk window [options] ntk keyPress [options] ntk mousePress [options] ntk widgetImage [options]
16
ntkWidget code example
package require ntkWidget # set the root windows title ::ntk::glmwfw::Glmwfw setWindowTitle $ntk::_win "NtkWidget Button Demo" proc flipName {win} { set name [$win cget -text] switch $name { Arnulf { $win configure -text Wiedemann } Wiedemann { $win configure -text Arnulf set rotate 0 if {[llength $argv] > 0} { set rotate [lindex $argv 0] set wPath [ntk button .w -width 100 -height 100 -xoffset 50 -yoffset 50 \ -text Arnulf -textcolor [list ] -bd 2 -bg [list ]] $wPath configure -command [list flipName $wPath] -rotate $rotate # pack the widget using ntkWidget grid manager ntk grid $wPath
17
Ttk style -anchor center -padding [list 3 3] -width -9 -relief raised
Default style Tbutton options Clam style Tbutton options -anchor center -padding [list 3 3] -width -9 -relief raised -shiftrelief 1 -window #ffffff -frame #d9d9d9 -disabledfg #a3a3a3 -anchor center -padding 5 -width -11 -relief raised -window #ffffff -frame #cdad5 -disabledfg #999999 17
18
Ttk layout Default layout TButton Clam layout TButton Background
Border Focusring Padding Text Background Border Focusring Padding Text 18
19
Ttk state active alternate background disabled focus invalid pressed
readonly selected 19
20
Ttk style map -background [list disabled #9d9d9d active #ececec]
-foreground [list disabled #a3a3a3 -relief [list {pressed !disabled} sunken] 20
21
Ttk theme names alt aqua clam classic default 21
22
Ttk like features With ttk like features you can
Determine the layout of a widget using a theme Determine the style of a widget using a theme Determine the look of a widget depending on the state No need to change the widget code Different look and feel on platforms dependent on default layout for the platform 22
23
ntkWidget andTtk like features
The currently used theme class in ntkWidget will be replaced by the ttk like features The mechanisms used in Ttk are very similar to the mechanisms used in ntkWidget (widget parts -> layout) The currently used methods in the ntkWidget theme class can be modified to handle styles The rendering can be easily adapted to handle layouts The rendering will be enhanced to handle states 23
24
itcl-ng addons for ntkWidget
methodvariable option delegate method delegate proc delegate option 24
25
itk and ntkWidget why not use itk? depending on Archetype
inheritance of options strange option handling of inherited options depending on Tk no support of themes possible 25
26
Status NexTk and ntkWidget are work in progress
NexTk and ntkWidget developers are working together There exist demos for NexTk There exist small demos for ntkWidget (without ttk like themes) 26
27
Conclusions NexTk and ntkWidget could be both a replacement for Tk in the future A huge amount of work to be done before usable as replacement for Tk Newer technology, easier to maintain code base Additional developpers would speed up implementation Will be incompatible to Tk on some places 27
28
ntkWidget „hello world“
Now it is time for some small demo examples 28
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.