### r代码来自Vignette Source'DidgetTools.rnw'########################################################### ###代码块数字1:widgettools.rnw:111-113 ###########################################################(1))################################ ###代码块编号2:widgettools.rnw:170-192 ############################################################=“ entry1”,wvalue =“使用浏览”,wenv = pwenv)browse2entry1 < - function(){tempvalue <-tclvalue(tkgetopenfile(tkgetOpenfile())temp)< - 粘贴(tempvalue,sep =“”,collapse =“;”)agiss(wname(entry1),temp,env = pwenv)} button1 button1 < - button(wname =“ button1”,wvalue =“ wvalue =“ browse”,browse“,browse”,wfuns = list(command = browse2entry1),wenv = pwenv)list1 <-listbox(wname =“ list1”,wvalue = c(option1 = true,option2 = false2 = false,option3 = false),wenv = pwenv)text1 < - textbox(wname =“ text1”,wvalue =“ feed me sosings”,wenv = pwenv)label2 < - label(wname =“ label2”,wvalue =“ wvalue =” select One:= PWENV)RADIOS1 <-RADIOBUTTON(WNAME =“ RADIOS1”,WVALUE = C(radio1 = true,Radio2 = falsive,radio3 = false),wenv = pwenv)label3 <-label(wname =“ wname =“ label3”,label3“,select =” select select select select select select select一对一:“,wenv = pwenv)checks1 < - checkbutton(wname =“ checks1”,wvalue = c(check1 = true,check22 = false,check3 = false),wenv = pwenv = pwenv)###########################################:widgettools.rnw:232-236 ######################## wName(label1) wName(label1) <- "YYY" wName(label1) wName(label1) <- "label1" ################################################### ### code chunk number 4: widgetTools.Rnw:251-256 ################################################### pWidgets <- list(topRow = list(label1 = label1, entry1 = entry1, button1 = button1), textRow = list(list1 = list1, text1 = text1), radGroup = list(label2 = label2, radios1 = radios1), chkGroup = list(label3 = label3, checks1 = checks1)) ################################################### ### code chunk number 5: widgetTools.Rnw:303-308 ################################################### if(interactive()){ aWidget <- widget(wTitle = "A test widget", pWidgets, funs = list(), preFun = function() print("Hello"), postFun = function() print("Bye"), env = PWEnv) } ################################################### ### code chunk number 6: widgetTools.Rnw:328-335 ################################################### if(interactive()){ wValue(pWidgets(aWidget)[["topRow"]][["entry1"]]) wValue(pWidgets(aWidget)[["textRow"]][["list1"]]) wValue(pWidgets(aWidget)[["textRow"]][["text1"]]) wValue(pWidgets(aWidget)[["radGroup"]][["radios1"]]) wValue(pWidgets(aWidget)[["chkGroup"]][["checks1"]]) }