Tk (Cairo) Canvas not scrollable?

226 views
Skip to first unread message

Dömötör Gulyás

unread,
Sep 1, 2015, 2:17:18 PM9/1/15
to julia-users
I'm trying to build a scrollable Cario canvas in a Tk GUI, but I keep getting "TclError("unknown option -xscrollcommand")" trying to add the scrollbars, apparently the canvas is a frame ("winfo class" returns "Frame"), which is not scrollable.

Is there a way to add scrollbars to a Cairo canvas, or can something be done to make it the proper widget class?. I've tried changing the constructor from c = TkWidget(parent, "ttk::frame") to c = TkWidget(parent, "ttk::canvas"), but that doesnt seem to help, and I see no other obvious place to change.

Anyone have any idea how to go about this? I've also tried to build the GUI in Gtk, but that hasn't worked out for other reasons.

j verzani

unread,
Sep 1, 2015, 6:57:34 PM9/1/15
to julia-users
Maybe add a sized Canvas into a TkCanvas and add scroll bars to the latter?

Andreas Lobinger

unread,
Sep 2, 2015, 3:51:25 AM9/2/15
to julia-users
Hello colleague,


On Tuesday, September 1, 2015 at 8:17:18 PM UTC+2, Dömötör Gulyás wrote:
I'm trying to build a scrollable Cario canvas in a Tk GUI, but I keep getting "TclError("unknown option -xscrollcommand")" trying to add the scrollbars, apparently the canvas is a frame ("winfo class" returns "Frame"), which is not scrollable.

somebody with more know how about Tk.jl should comment on this, but i think you are right. The Tk.jl Cairo Canvas is using a 'plain' window/widget to provide a cairo surface and context and doesn't fully replace the original tk Canvas who has drawing methods of it's own - not cairo based.
 
Is there a way to add scrollbars to a Cairo canvas, or can something be done to make it the proper widget class?. I've tried changing the constructor from c = TkWidget(parent, "ttk::frame") to c = TkWidget(parent, "ttk::canvas"), but that doesnt seem to help, and I see no other obvious place to change.

Anyone have any idea how to go about this? I've also tried to build the GUI in Gtk, but that hasn't worked out for other reasons. 

I'd be interested in the Gtk example - even if it's not working. I'd assume that add_view_viewport is the issue.
 

Andreas Lobinger

unread,
Sep 2, 2015, 9:12:51 AM9/2/15
to julia-users
Hello colleagues,

i was actually a little bit surprised that this
        using Gtk
        w = Gtk.@GtkWindow("a1",400,300)
        c = Gtk.@GtkCanvas(2300,2800);
        w2 = Gtk.@GtkScrolledWindow(c);
        push!(w,w2)
        show(w)
        show(c)
        show(w2)
        using Cairo
        move_to(c.backcc,10,10)
        line_to(c.backcc,1200,1300)
        stroke(c.backcc)
        reveal(c)

worked out-of-the-box. Opens a small window, puts Scrolled window with a large canvas inside. Shows up on desktop as window with scroll bars and drawing to the canvas just work and the scrolling works also.

This was done on a 0.4dev installation in ubuntu 15.04 from julia nightlies.

Jameson Nash

unread,
Sep 2, 2015, 12:04:04 PM9/2/15
to julia...@googlegroups.com
The Canvas object is not a proper Tk object since Tk doesn't support Cairo-based rendering and isn't very friendly to being extended. Switching to a more flexible framework like Gtk should help here.
Reply all
Reply to author
Forward
0 new messages