Search code examples
juliagtkgtk.jl

How to add scrolling to the list using Gtk.jl (Julia)?


I'm trying to create a list of some data and need scrolling. I've tryed:

MainWindow1 = GtkScrolledWindow("ECG database", 900, 450)

These don't work: enter image description here


Solution

  • The GtkScrolledWindow should create its scrollbars automatically when it has content within it that is larger than will fit within its assigned size to show. Have you tried putting things in the scrolled window yet? For example, try adding a GtkTextView containing a GtkTextBuffer with lots of text in it.

    Example, the scroll bar is on the right and is very narrow on my system:

    using Gtk
    
    const win = GtkWindow("Scroller", 100, 400)
    
    const logwindow = GtkScrolledWindow()
    const logtxt = GtkTextBuffer()
    logtxt.text[String] = "Random text."
    const tview = GtkTextView(logtxt)
    push!(logwindow, tview)
    push!(win, logwindow)
    
    const txt = String(rand(['a', 'b', 'c', 'd', ' ', '\n'], 1000))
    
    set_gtk_property!(logtxt, :text, get_gtk_property(logtxt, :text, String) * "\n" * txt)
    
    showall(win)