0
我希望在我的tcltk窗口中插入一個'加載'GIF圖像,但是無法讓我的頭部繞過它。以下是一個可重複的例子: -將GIF圖像添加到TclTk窗口
backg <- 'white'
pdlg <- tktoplevel(background=backg)
tcl('wm', 'geometry', pdlg, '500x100+450+350')
tilg <- 'Package installation in progress'
tkwm.title(pdlg, tilg)
fn <- tkfont.create(family = 'helvetica', size = 12)
nwlabel <- " The requisite packages are being installed. This may take several \nminutes... \n"
tllab <- tklabel(pdlg, text = nwlabel, font = fn, pady = 0, background=backg)
clickEv <- tclVar(0)
OK.but <- tkbutton(pdlg, text=' Stop ', command=function() tclvalue(clickEv) <- 1, font=fn, background='grey', pady=0)
tkgrid(tllab, columnspan=1)
tkgrid(OK.but, row=3)
tkbind(pdlg, "<Destroy>", function() tclvalue(done) <- 2)
tkfocus(pdlg)
#This allows me to insert a GIF image but the animation is lost. Also it would be convenient if the output can be obtained using 'tkgrid' instead of 'tkpack'
pdlg2 <- tktoplevel(background='white')
loading <- tclVar()
tcl('image', 'create', 'photo', loading,
file='file path to GIF file')
trial <- tklabel(pdlg2, image=loading)
tkpack(trial)
一個例子GIF文件可以從這裏-http下載://www.dlfpramericalife.com/library/images/final_loading_big.gif
理想的情況下,GIF圖像應放置在「停止」按鈕上方,但位於文本下方。非常感謝您的幫助!
我們從未做過動畫GIF的實際動畫部分(儘管您仍然可以選擇要顯示哪個動畫幀)。有些人可能認爲這是一個功能! –