Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

display failure #13

Open
JeffBezanson opened this Issue · 21 comments

5 participants

@JeffBezanson

This happens on linux (ubuntu 12.04) with tcl/tk 8.5:

julia> imgc, imsl = ImageView.display(img)
ERROR: getgc: Canvas is not drawable
 in wait_initialized at /home/jeff/.julia/Tk/src/tkwidget.jl:416
 in getgc at /home/jeff/.julia/Tk/src/tkwidget.jl:422
 in set_coords at /home/jeff/.julia/ImageView/src/display.jl:528
 in resize at /home/jeff/.julia/ImageView/src/display.jl:438
 in display at /home/jeff/.julia/ImageView/src/display.jl:283

I can get past this error with the following change, which I assume is not really correct:

--- a/src/display.jl
+++ b/src/display.jl
@@ -235,7 +235,7 @@ function display{A<:AbstractArray}(img::A; proplist...)
     grid(framec, 1, 1, sticky="nsew")
     grid_rowconfigure(win, 1, weight=1) # scale this cell when the window resiz
     grid_columnconfigure(win, 1, weight=1)
-    c = Canvas(framec, ww, wh)
+    c = Canvas(win, ww, wh)
     imgc.c = c
     # Place the canvas and set its resize properties
     grid(c, 1, 1, sticky="nsew")        # fill the edges of its cell on all 4 s

I get the same error for other GUIs that ImageView opens.

Winston and other julia Tk code works for me on this system.

@timholy
Owner

Hmm, works for me on basically the same OS, (k)ubuntu 12.04 with tcl/tk 8.5.

What happens if you increase the Tk timeout counter to something like 10^6? I'm wondering if you have a faster system than my laptop, and that we have a race condition?

@timholy
Owner

Two others: can you try from the REPL?

julia> win = Toplevel("Testing",300,200)
Tk widget of type Tk_Toplevel

julia> framec = Frame(win)
Tk widget of type Tk_Frame

julia> grid(framec, 1, 1, sticky="nsew")
""

julia> c = Canvas(framec, 300, 200)
Canvas(TkWidget,#undef,#undef,MouseHandler((anonymous function),(anonymous function),(anonymous function),(anonymous function),(anonymous function),(anonymous function),(anonymous function),(anonymous function)),(anonymous function),(anonymous function),false)

julia> grid(c, 1, 1, sticky="nsew")
""

julia> ctx = getgc(c)
CairoContext(Ptr{Void} @0x00000000055a92d0,CairoSurface(Ptr{Void} @0x000000000357abe0,300.0,200.0,#undef),Ptr{Void} @0x00000000055a6450)

If this is problematic, what happens if you replace grid with pack? I think Winston uses pack.

@JeffBezanson

Thanks. I found I can get ImageView working if I add calls to tcl_doevent before each Canvas is created. Not sure what that means the general solution is.

@timholy
Owner

That's very odd, but at least it works. Perhaps we should insert a tcl_doevent() into the Canvas constructor?

@timholy
Owner

Just one call, or do you do a loop?

@JeffBezanson

One call does it.

@timholy
Owner

That's really weird, since getgc calls it in a loop. It seems that doing it before canvas creation fixes something that doesn't get fixed if you call it after Canvas construction.

OK, so I propose we insert it into the Canvas constructor, with a # this magically fixes ImageView #13. Reasonable?

@timholy
Owner

Fixed in JuliaLang/Tk.jl@f933493. Obviously I can test that this doesn't break anything, but I can't check that it truly fixes your issue myself.

@timholy timholy closed this
@timholy
Owner

Arg, I was too hasty in declaring that this didn't break anything; I only tested the "tile.jl" test, and for me "test4d.jl" is now broken. I'm reverting that Tk patch, because with 15 minutes of experimenting I didn't find the incantation that gets ImageView working again with that Tk patch.

Since I can't replicate your bug, I might have to ask you to be mostly in charge of seeing what changes fix it for you, and then I can test here.

It's times like these where my admiration for Tk is less than 100%.

@timholy timholy reopened this
@timholy
Owner

I've never figured out how to fix this in a reliable way. (It's one of quite a few reasons for my having begun to experiment with Gtk.) Is this still an issue for you?

@lightcatcher

I'm having the same error described in the initial filing of the issue. Running Julia 0.2 on Ubuntu 12.04 LTS, with tcl 8.5.

@lightcatcher

As with @JeffBezanson , I was able to get the code working with adding "tcl_doevent()" directly before "c = Canvas(framec, ww, wh)". I know nothing about tcl/tk, but perhaps you just want to merge that change in?

@malmaud

I'm getting the same error.

@timholy
Owner

Try the gtk branch, and let me know if that fixes it for you. I can't figure out how to resolve this with Tk; what works for you breaks it for me.

@malmaud

The gtk branch does work.

@timholy
Owner

Great, glad to hear it. Once Gtk gets packaged up for all platforms, I'll merge it into master.

@philtomson

I started getting this error recently as well (not sure how it started, at some point everything was working fine):

ERROR: getgc: Canvas is not drawable
in wait_initialized at /home/phil/.julia/v0.3/Tk/src/tkwidget.jl:438
in set_coords at /home/phil/.julia/v0.3/ImageView/src/display.jl:626
in resize at /home/phil/.julia/v0.3/ImageView/src/display.jl:519
in view at /home/phil/.julia/v0.3/ImageView/src/display.jl:319
in view_featuremaps at /home/phil/work/WASP_TD/algorithm_dev/processing/depth_engine/src/learn_grad_whole.jl:28
in include at ./boot.jl:245
in include_from_node1 at ./loading.jl:128
while loading /home/phil/work/WASP_TD/algorithm_dev/processing/depth_engine/src/learn_grad_whole.jl, in expression starting on line 226

Julia 0.3.5 on Ubuntu 12.04

As suggested above, I checked out the gtk branch, but then I see:

ERROR: Gtk not found
in require at loading.jl:47
in include at ./boot.jl:245
in include_from_node1 at ./loading.jl:128
in reload_path at loading.jl:152
in _require at loading.jl:67
in require at loading.jl:51
in include at ./boot.jl:245
in include_from_node1 at ./loading.jl:128
while loading /home/phil/.julia/v0.3/ImageView/src/ImageView.jl, in expression starting on line 6

I've got libgtk2.0 and libgtk2.0-dev installed.

EDIT: Ah, of course, it means a Gtk julia package. Pkg.add("Gtk") worked.

Any idea when the Gtk branch will be merged into master?

@timholy
Owner

I've been seeing it too. I'm utterly swamped with other commitments right now, but you could do a git bisect to figure out which change introduced the problem and then check out the version before the breakage.

@timholy
Owner

(Let me know what you find, it will help me fix the problem when I get to it.)

@philtomson

@timholy: you had added a tcl_doevent() into the TK/src/tkwidget.jl into the Canvas constructor (first line of the constructor it looks like from here: JuliaLang/Tk.jl@f933493

...but that addition is now gone. I haven't sifted through git to figure out when it went away, but there seem to have been some significant changes in tkwidget.jl since you added the tcl_doevent() call. I've added it back into my version of tkwidget.jl (at the beginning Canvas constructor) and that seems to be working fine. (had to do that since it appears the gtk branch of ImageView is broken at this point - I've filed another separate issue on that)

@timholy
Owner

It was because some other shady character :smile: reverted that patch: JuliaLang/Tk.jl@287b99f

It seems to fix problems for some people and break them for others.

This is part of why Gtk is better, but haven't had time to do the rewrite. I have quite a lot of goals for the rewrite, and that's an impediment to getting started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.