jverzani / gWidgets2

Rewrite of gWidgets
35 stars 9 forks source link

vertical gtoolbar #79

Closed davidgohel closed 9 years ago

davidgohel commented 9 years ago

Dear John Verzani,

Thanks for your very useful package.

I am trying to design an app containing a vertical gtoolbar.

I tried with argument fill set to "y" (and "x") but it has no effect. Is it possible? Below the code I am using:

options(guiToolkit="RGtk2")
main_win = gwindow( title = "test", height = 600, width = 800, visible = TRUE, name="main" )

dummy_act <- list(open=gaction("Open", icon="open", handler=function(...) svalue(sb) <- "open", parent = main_win),
    save=gaction("save", icon="save", handler=function(...) svalue(sb) <- "save", parent = main_win),
    quit=gaction("quit", icon="quit", handler=function(...) dispose(main_win), parent = main_win)
)
mb <- gtoolbar(dummy_act, cont = main_win )

And my sessionInfo()

sessionInfo()
#R version 3.1.0 (2014-04-10)
#Platform: x86_64-w64-mingw32/x64 (64-bit)
#
#locale:
#[1] LC_COLLATE=French_France.1252  LC_CTYPE=French_France.1252    LC_MONETARY=French_France.1252 LC_NUMERIC=C                  
#[5] LC_TIME=French_France.1252    
#
#attached base packages:
#[1] stats     graphics  grDevices utils     datasets  methods   base     
#
#other attached packages:
#[1] gWidgets2RGtk2_1.0-2 RGtk2_2.20.31        memoise_0.1          gWidgets2_1.0-6      digest_0.6.4        
#
#loaded via a namespace (and not attached):
#[1] tools_3.1.0

Any suggestion is welcome. David

jverzani commented 9 years ago

There isn't really such an option in the underlying toolkit the way there is in Qt. Using a vertical group with expand=FALSE gives a place to pack in buttons. The call btn=gbutton(action=a, cont=tb) will make a button from an action. The call btn$remove_border() will make each one look more like a toolbar button, than a button. It isn't perfect, but not bad. The following pattern allows you to adjust the position of the image, though using it with action items requires a bit more work:

b = gbutton("", cont=tb)
b$widget["image-position"] = GtkPositionType["top"]
svalue(b) <- "open"
b$remove_border()

(For some reason the image doesn't show without the extra call to svalue, though that might be just my setup.)

davidgohel commented 9 years ago

Thanks for the suggestion.

I did get something satisfying.

Thanks again