Tk.jl icon indicating copy to clipboard operation
Tk.jl copied to clipboard

Packing Canvas Throws MethodError

Open rteehas opened this issue 5 years ago • 2 comments

I attempted to run the sketch_window() function in sketch.jl but when it evaluates the line that packs the canvas it throws the following: ERROR: MethodError: pack(::Canvas) is ambiguous. Candidates: pack(c::Canvas, args...) in Tk at C:\Users\rteehan\.julia\packages\Tk\c8ZUf\src\tkwidget.jl:411 pack(widget::Union{AbstractString, Canvas, Tk.TkWidget, Tk_Widget}; kwargs...) in Tk at C:\Users\rteehan\.julia\packages\Tk\c8ZUf\src\containers.jl:117 Possible fix, define pack(::Canvas)

It seems like the example is failing because of an ambiguous overloaded function definition.

rteehas avatar Aug 18 '20 20:08 rteehas

Seems like a bug. I'll take a look.

aviks avatar Aug 20 '20 12:08 aviks

I'm sorry suddenly. I haven't seen all the code, but I think the following changes will fix it. Erase the following part, https://github.com/JuliaGraphics/Tk.jl/blob/5d704d285ccffd4eb82ba783ec181d75f5d69b28/src/tkwidget.jl#L411-L413 and here https://github.com/JuliaGraphics/Tk.jl/blob/5d704d285ccffd4eb82ba783ec181d75f5d69b28/src/containers.jl#L117 How about changing it like this?

function pack(widget::Widget, kwargs...)
    if typeof(widget) == Canvas
        widget = widget.c
    end
    tcl("pack", widget; kwargs...)
end

MommaWatasu avatar Apr 18 '21 11:04 MommaWatasu

pack(canvas.c) is a workaround.

LilithHafner avatar Jul 20 '24 13:07 LilithHafner