guile-pstk

A Tk interface for Guile (A fork of (and hopefully a future merge?) https://github.com/kikyTokamuro/guile-pstk/).
Log | Files | Refs | README | LICENSE

slider.scm (825B)


      1 ; PS/Tk Example Program "Slider"
      2 ; Copyright (C) 2022 Daniil Archangelsky aka Kiky Tokamuro
      3 ; See the PS/Tk license for conditions of use.
      4 
      5 (add-to-load-path
      6  (string-append
      7   (dirname (current-filename))
      8   "/../"))
      9 
     10 (use-modules (pstk)
     11 	     (ice-9 format))
     12 
     13 (tk-start)
     14 
     15 (tk/wm 'title tk "Slider")
     16 (tk/wm 'resizable tk 0 0)
     17 
     18 (tk 'configure 'background: "#ffffff")
     19 
     20 (ttk-map-widgets 'all)
     21 (ttk/set-theme "clam")
     22 
     23 (let* ((entry  (tk 'create-widget 'entry
     24 		   'width: 20))
     25        (slider (tk 'create-widget 'scale
     26 		   'from: 0
     27 		   'to: 100
     28 		   'command: (lambda (x)
     29 			       (entry 'delete 0 "end")
     30 			       (entry 'insert 0 (format #f "~,2f" x))))))
     31   (tk/grid entry  'row: 0 'columnspan: 4 'sticky: 'ew 'padx: 20 'pady: 10)
     32   (tk/grid slider 'row: 1 'columnspan: 4 'sticky: 'ew 'padx: 20 'pady: 10)
     33   (tk-event-loop))
     34