addHandlerFocus 'event_decorator' 未找到
addHandlerFocus 'event_decorator' not found
我的包目前是使用 gWidgets2RGtk2 开发的。我试图让它与 gWidgets2tcltk 兼容。但是,我收到这个我无法弄清楚的错误:
Error in connect_to_toolkit_signal(signal, decorator = decorator, emitter = emitter, :
object 'event_decorator' not found
一个使用 gWidgets2RGtk2 工作但使用 gWidgets2tcltk 给出错误的小例子:
require(gWidgets2)
gui_example <- function(){
# Main window.
w <- gwindow(title=paste("GUI test"), visible = FALSE, name=title)
# Main group.
gv <- ggroup(horizontal=FALSE, use.scrollwindow=FALSE, container = w, expand=TRUE)
# Notebook.
nb <- gnotebook(closebuttons = FALSE, dontCloseThese = NULL, container = gv)
# Define groups.
tab_1 <- ggroup(container = nb, label="Tab1")
tab_2 <- ggroup(container = nb, label="Tab2")
tab_3 <- ggroup(container = nb, label="Tab3")
gtext(text="Tab1", expand=TRUE, container = tab_1)
gtext(text="Tab2", expand=TRUE, container = tab_2)
gtext(text="Tab3", expand=TRUE, container = tab_3)
addHandlerChanged(nb, handler = function (h, ...) {
print("CHANGED...")
print(if(is.null(h$page.no)) svalue(h$obj) else h$page.no)
# Get active tab.
tab <- if(is.null(h$page.no)) svalue(h$obj) else h$page.no
tabName <- names(nb)[tab]
print(paste("Active tab:", tab))
print(paste("Active tab name:", tabName))
})
addHandlerFocus(w, handler = function (h, ...) {
print("FOCUS...")
# Get active tab.
tab <- svalue(nb)
tabName <- names(nb)[tab]
print(paste("Active tab:", tab))
print(paste("Active tab name:", tabName))
})
# Show GUI and first tab.
svalue(nb) <- 1
visible(w) <- TRUE
focus(w)
message("Example loaded!")
}
如何在使用 gWidgets2tcltk 包时避免此错误,并保持与 gWidgets2RGtk2 的兼容性?
这是我的系统信息:
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
gWidgets2_1.0-7
gWidgets2RGtk2_1.0-7
RGtk2_2.20.35
gWidgets2tcltk_1.0-5
错误已修复 GitHub - 请参阅@jverzani 的评论
我的包目前是使用 gWidgets2RGtk2 开发的。我试图让它与 gWidgets2tcltk 兼容。但是,我收到这个我无法弄清楚的错误:
Error in connect_to_toolkit_signal(signal, decorator = decorator, emitter = emitter, :
object 'event_decorator' not found
一个使用 gWidgets2RGtk2 工作但使用 gWidgets2tcltk 给出错误的小例子:
require(gWidgets2)
gui_example <- function(){
# Main window.
w <- gwindow(title=paste("GUI test"), visible = FALSE, name=title)
# Main group.
gv <- ggroup(horizontal=FALSE, use.scrollwindow=FALSE, container = w, expand=TRUE)
# Notebook.
nb <- gnotebook(closebuttons = FALSE, dontCloseThese = NULL, container = gv)
# Define groups.
tab_1 <- ggroup(container = nb, label="Tab1")
tab_2 <- ggroup(container = nb, label="Tab2")
tab_3 <- ggroup(container = nb, label="Tab3")
gtext(text="Tab1", expand=TRUE, container = tab_1)
gtext(text="Tab2", expand=TRUE, container = tab_2)
gtext(text="Tab3", expand=TRUE, container = tab_3)
addHandlerChanged(nb, handler = function (h, ...) {
print("CHANGED...")
print(if(is.null(h$page.no)) svalue(h$obj) else h$page.no)
# Get active tab.
tab <- if(is.null(h$page.no)) svalue(h$obj) else h$page.no
tabName <- names(nb)[tab]
print(paste("Active tab:", tab))
print(paste("Active tab name:", tabName))
})
addHandlerFocus(w, handler = function (h, ...) {
print("FOCUS...")
# Get active tab.
tab <- svalue(nb)
tabName <- names(nb)[tab]
print(paste("Active tab:", tab))
print(paste("Active tab name:", tabName))
})
# Show GUI and first tab.
svalue(nb) <- 1
visible(w) <- TRUE
focus(w)
message("Example loaded!")
}
如何在使用 gWidgets2tcltk 包时避免此错误,并保持与 gWidgets2RGtk2 的兼容性?
这是我的系统信息:
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
gWidgets2_1.0-7
gWidgets2RGtk2_1.0-7
RGtk2_2.20.35
gWidgets2tcltk_1.0-5
错误已修复 GitHub - 请参阅@jverzani 的评论