0

I have created a GUI using gWidgets and RGtk2. A part of the GUI is a glayout with a set of gcomboboxes. These boxes are initially empty and gets populated once a file is imported.

On mac with Gtk+ running through X11 the width of the comboboxes gets resized to fit the longest textstring in the combobox. On windows this doesn't happen and the comboboxes gets scrollbars to accomodate the long text strings (see pictures).

Combobox on Windows

Combobox on Mac

I have tried turning visibility off and on to force a redraw but the size stay fixed.

Is there anyway to force the resizing on windows machines?

The code for the container holding the relevant widgets are:

optionsBox <- ggroup(cont=controlGroup)
addSpring(optionsBox)
options <- glayout(cont=optionsBox, spacing=5, fill='y')
optList <- list()
options[1, 1, anchor=c(1,0)] <- 'Category:'
options[1, 2, anchor=c(-1,0)] <- optList$category <- gcombobox(category, cont=options)
options[2, 1, anchor=c(1,0)] <- 'Order:'
options[2, 2, anchor=c(-1,0)] <- optList$order <- gcombobox(order, cont=options)
options[2, 3, anchor=c(1,0)] <- optList$numeric <- gcheckbox('numeric', checked=TRUE)
options[3, 1, anchor=c(1,0)] <- 'Plottype:'
options[3, 2, anchor=c(-1,0)] <- optList$plottype <- gcombobox(c('Bar', 'Line'), cont=options)
addSpring(optionsBox)

best wishes

Thomas

ThomasP85
  • 1,624
  • 2
  • 15
  • 26

1 Answers1

2

I can't test this easily on windows, but a few things should help out. First, make sure the parent container for the glayout object isn't constraining the initial size. (In the example below try setting do_expand=FALSE to see what happens.) Unless you set the size of the widget with the size<- method (not the best usage, but sometimes all you can do) the initial size will come from satisfying the size requests of your widgets.

library(gWidgets)
options(guiToolkit="RGtk2")
w <- gwindow()
g <- ggroup(cont=w)
do_expand=TRUE
options <- glayout(cont=g, spacing=5, expand=do_expand)
items <- ""

options[1,1] = "vanilla"
options[1,2] <- gcombobox(items, cont=options)

options[2,1] = "expand"
options[2,2, expand=TRUE] <- gcombobox(items, cont=options)

options[3,1] = "expand, fill"
options[3,2, expand=TRUE, fill="y"] <- gcombobox(items, cont=options)

options[4,1] = "size"
options[4,2] <- (cb <- gcombobox(items, cont=options))
size(cb) <- c(250, -1)

## populate comboboxes 
items <- state.name 
sapply(options[,2], function(i) i[] <- items)
jverzani
  • 5,600
  • 2
  • 21
  • 17
  • Unfortunatly this doesn't work, in the sense that the comboboxes are not resized to fit content - some of the solutions of course initially gives a width that accomodates the new data. Guess I'll have to manually set the size to be fairly adequate then... – ThomasP85 Oct 16 '12 at 07:40
  • You might try forcing a resize of the children, though I haven't tested: `library(RGtk2); getToolkitWidget(options)$resizeChildren()` – jverzani Oct 16 '12 at 12:35