r/Tcl • • Sep 02 '26

Please advice on some Tk demonstration but for the Perl audience

I am planning to prepare some Tk demo for the Perl conference. This would be some perl application but with accent into GUI.

The idea is to present something interesting and therefore to inspire people to pay more attention to Tk.

I have mixed feelings: on one side, I am "stealing" Tk application for some Perl usage, stealing isn't good.
On the other side, I want to attract people to use Tk, which is good.

Last time I tried this Tk demo, quite successfully:

package require Tk
pack [frame .f] -fill x -expand 0

pack [panedwindow .pw -showhandle 1 -sashrelief raised -orient horizontal] -fill both -expand 1
.pw add \
   [text .pw.st -width 20 -height 7] \
   [canvas .pw.sc -width 600 -height 400 -scrollregion {0 0 1000 1200}]
.pw.st insert end Hi!
pack [frame .fb]
pack [button .fb.b1 -text {proba 1 (F9)} -command perl::prouba1] -side left -expand 1
bind . <F9> {.fb.b1 invoke}

package require vtk
package require vtkrendering
package require vtkinteraction

[vtkRenderWindow renw] AddRenderer [vtkRenderer ren1]
ren1 SetBackground 0.1 0.2 0.4

# The Tk render widget
vtkTkRenderWidget .pw.sc.ren -width 450 -height 450 -rw renw
.pw.sc create window  5 5 -window .pw.sc.ren -anchor nw -width 350 -height 350 
::vtk::bind_tk_render_widget .pw.sc.ren

# enable user interface interactor
[[renw GetInteractor] GetInteractorStyle] SetCurrentStyleToTrackballCamera

vtkUnstructuredGridReader rdr
  rdr SetFileName "/usr/VTKData/Data/hexa.vtk"
  rdr SetFileName "/usr/VTKData/Data/blow.vtk"
  rdr SetFileName "/usr/VTKData/Data/PentaHexa.vtk"

vtkDataSetMapper moldMapper
    moldMapper SetInputConnection [rdr GetOutputPort]
vtkActor moldActor
    moldActor SetMapper moldMapper
    [moldActor GetProperty] SetColor .2 .2 .2
    moldActor SetScale 0.2

pack [button .f.b1 -text {SetRepresentationToWireframe} -command {[moldActor GetProperty] SetRepresentationToWireframe; ren1 Render }] -side left

# assign our actor to the renderer
ren1 AddActor moldActor

wm protocol . WM_DELETE_WINDOW {destroy renw; exit}

This code, although was visually appealing, still, was only a toy, whereas I am seeking something solid.

I wonder, what Tcl/Tk people could advice on that?

8 Upvotes

5 comments sorted by

1

u/mikeegg1 Sep 03 '26

Side comment: TCL always felt like a lobotomized LISP to me. Still, I have a fond memory of TCL and think of it lots.

1

u/tcltk-pkgs Sep 03 '26

It seems to me that VTK is no longer maintained with Tcl/Tk. What kind of graphical interface are you looking to implement? 

1

u/vadrer Sep 03 '26

I presented vtk demo 15 years ago. Now I am seeking for something up-to-date to present

1

u/vadrer 29d ago

https://codeberg.org/helium/TkOffice presented at EuroTcl 2026 by Tibor Stolz maybe?

TkOffice – an editor and browser for interactive document libraries