summaryrefslogtreecommitdiff
path: root/tcl/bin/popimage
blob: 58acd23585d726ec353a74bc610f7c49fca58aa2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/sh
# the next line restarts using wish \
exec ${LINUXCNC_EMCSH-wish} "$0" "$@"

###############################################################
# Description:  popimage
#               A Tcl/Tk script that displays the image listed  
#               in the relevant ini file for the time listed in
#               that file.
#
#  Derived from a work by Fred Proctor & Will Shackleford
#  Author: 
#  License: GPL Version 2
#
#  Copyright (c) 2005 All rights reserved.
#
#  Last change:
###############################################################
#  INI variables include
#  [DISPLAY]
#  Introductory graphic
#  INTRO_GRAPHIC = emc2.gif
#  INTRO_TIME = 5
#  If time is set to zero no image is used
###############################################################


if {$argc < 1} {
  puts stderr "syntax: popimage <image file>"
  exit
}

load [file join [file dirname [info script]] .. linuxcnc.so]

. configure -borderwidth 0 -highlightthickness 0

set img [lindex $argv 0]

set imgtime 5
if {$argc > 1} {
  set imgtime [lindex $argv 1]
}
if {$imgtime <= 0} {
  set imgtime 5
}
# now convert imgtime to milliseconds
set imgtime [expr {int($imgtime * 1000)}]

if {! [file exists $img]} {
  puts stderr "can't find file $img"
  exit
}

if {[catch {image create photo -file $img} image]} {
  puts stderr "bad image file $img"
  exit
}

set w [image width $image]
set h [image height $image]
canvas .c -width $w -height $h -borderwidth 0 -highlightthickness 0
.c create image 0 0 -anchor nw -image $image
.c create text 4 [expr $h-4] -anchor sw \
    -text $env(LINUXCNCVERSION) -fill white -font {Helvetica 18}

pack .c

# Center popup in screen.

set si [lindex [multihead] 0]
set x0 [lindex $si 0]
set y0 [lindex $si 1]
set x1 [lindex $si 2]
set y1 [lindex $si 3]
set cx [expr {($x0+$x1)/2}]
set cy [expr {($y0+$y1)/2}]
set x [expr {$cx-$w/2}]
set y [expr {$cy-$h/2}]
wm geometry . "+$x+$y"
wm overrideredirect . 1

after $imgtime exit