电子木鱼
after 10 :修改刷新时间
-file {C:\Users\Today\Downloads\Image1.gif} :指定文件路径
鼠标右键关闭窗口
package require Tk
package require Img
catch {destroy .top}
set top [toplevel .top]
wm title $top "GIF Player"
wm overrideredirect .top 1
set gif [image create photo -file {C:\Users\Today\Downloads\Image1.gif}]
label $top.lbl -image $gif
pack $top.lbl
set frames 0
while {1} {
if {[catch {$gif configure -format "gif -index $frames"}]} {
break
}
incr frames
}
set current_frame 0
proc change_frame {} {
global gif
global frames
global current_frame
$gif configure -format "gif -index $current_frame"
set current_frame [expr {($current_frame + 1) % $frames}]
update
after 10 change_frame
}
change_frame
bind .top <Button-3> {destroy .top}