Bug 16450 - ttkimage(): Invalid command name
Summary: ttkimage(): Invalid command name
Status: CLOSED FIXED
Alias: None
Product: R
Classification: Unclassified
Component: Language (show other bugs)
Version: R 3.2.1
Hardware: x86_64/x64/amd64 (64-bit) Windows 64-bit
: P5 normal
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2015-06-24 12:20 UTC by Thomas J. Leeper
Modified: 2015-08-03 15:02 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas J. Leeper 2015-06-24 12:20:07 UTC
The tcltk package includes a function called `ttkimage()`, the definition of which is (in Tk.R):

ttkimage <- function(parent, ...) tkwidget(parent, "ttk::image", ...)

Calling this function, however, produces a Tcl-level error:

> library("tcltk")
> tt <- tktoplevel()
> ttkimage(tt)
Error in structure(.External(.C_dotTclObjv, objv), class = "tclObj") : 
  [tcl] invalid command name "ttk::image".

My understanding is that there is no ttk-specific image command (see https://www.tcl.tk/man/tcl/TkCmd/contents.htm), so this R function should instead just be called `tkimage` (not `ttkimage`) and its definition should just be:

tkimage <- function(parent, ...) tkwidget(parent, "image", ...)

Note for example, that just using "image" works while "ttk::image" does not:

> .Tcl("ttk::image types")
Error in structure(.External(.C_dotTcl, ...), class = "tclObj") : 
  [tcl] invalid command name "ttk::image".
> .Tcl("image types")
<Tcl> photo bitmap
Comment 1 Peter Dalgaard 2015-06-24 13:28:51 UTC
Be careful not to confuse things here:

There is no ttk::image widget, so clearly ttkimage()  should not be there. There are 18 Ttk widgets currently, and 17 ttkfoo() functions (1 wrong), so apparently 2 (scale, spinbox) are not implemented, and probably should be.

However, ordinary Tk images are not widgets (they are just objects, with no parent), so implementation via tkwidget would be wrong. We already have tkimage.create() which just calls tcl("image", "create", ...) and we could add further subcommands along the same lines. 

(Incidentally, tkimage.configure() and tkimage.cget() appear to be misunderstandings as well.)
Comment 2 Thomas J. Leeper 2015-06-24 13:32:40 UTC
(In reply to Peter Dalgaard from comment #1)
> Be careful not to confuse things here:
> 
> There is no ttk::image widget, so clearly ttkimage()  should not be there.
> There are 18 Ttk widgets currently, and 17 ttkfoo() functions (1 wrong), so
> apparently 2 (scale, spinbox) are not implemented, and probably should be.
> 
> However, ordinary Tk images are not widgets (they are just objects, with no
> parent), so implementation via tkwidget would be wrong. We already have
> tkimage.create() which just calls tcl("image", "create", ...) and we could
> add further subcommands along the same lines. 
> 
> (Incidentally, tkimage.configure() and tkimage.cget() appear to be
> misunderstandings as well.)

Yes, you're right. It should not be a widget at all.
Comment 3 Peter Dalgaard 2015-08-03 15:02:10 UTC
Fixed in 3.2.1 Patched and R-devel