Closed davidcsterratt closed 9 years ago
Welcome back :) (I really do appreciate your reports, they are very nicely presented.) This one is actually somewhat by design. The container you are packing it into (the frame) is a horizontal box container, so the child widgets, by default, expand in the vertical (but not horizontal) direction. You have some options, one simple one for this case is to pass horizontal=FALSE
to gframe
, but that may not work with your actual use case. You could also pass expand=TRUE
to the gcombobox
.
Thanks - I try hard to find minimal examples. Unfortunately, I've not managed to get things working with various combinations of horizontal=TRUE/FALSE
to the gframe
and expand=TRUE/FALSE
to the gcombobox
. The somewhat longer example below hopefully demonstrates this:
# library(gWidgets) # Works - gcomboboxes expand horizontally to fit their text
library(gWidgets2) # Doesn't work; text in gcomboboxes is elided
options(guiToolkit="RGtk2")
h <- function(h, ...) {}
g.win <- gwindow("Elided text in gcomboboxes")
g.rows <- ggroup(horizontal=FALSE, container=g.win)
g.body <- ggroup(container=g.rows)
## "Edit" and "View" tabs
g.nb <- gnotebook(container=g.body)
## Edit tab
g.editor <- ggroup(horizontal = FALSE, container=g.nb, label="Edit")
g.data.frame <- gframe("Data", container=g.editor, horizontal=FALSE)
g.data <- gcheckboxgroup(c("Flip DV"), handler=h, container=g.data.frame)
## View Tab
g.view <- ggroup(horizontal=FALSE, container=g.nb, label="View")
g.show <- gcheckboxgroup(c("Count contours"),
checked=c(TRUE),
handler=h, container=g.view)
## Dropdowns
g.frame <- gframe("horizontal FALSE, expand FALSE",
container=g.view, horizontal=FALSE)
g <- gcombobox(c("Option 1", "This text is elided when dropped down"),
selected=1, handler=h, editable=FALSE,
expand=FALSE,
action=NULL, container=g.frame)
g.expand.frame <- gframe("Horizontal FALSE, expand TRUE ",
container=g.view, horizontal=FALSE)
g.expand <- gcombobox(c("Exapnd TRUE", "This text is elided when dropped down"),
selected=1, handler=h, editable=FALSE,
expand=TRUE,
action=NULL, container=g.expand.frame)
g.horizontal.frame <- gframe("Horizontal TRUE, expand FALSE",
container=g.view, horizontal=TRUE)
g.horizontal <- gcombobox("This text is compressed and elided",
selected = 1, handler = h, editable=FALSE,
expand=FALSE,
action = NULL, container = g.horizontal.frame)
g.horizontal.expand.frame <- gframe("Horizontal TRUE, expand TRUE",
container=g.view, horizontal=TRUE)
g.horizontal.expand <- gcombobox("This text is compressed and elided",
selected = 1, handler = h, editable=FALSE,
expand=TRUE,
action = NULL, container = g.horizontal.expand.frame)
## Graphs at right
g.f1 <- ggroup(horizontal=FALSE, container=g.body)
g.fd1 <- ggraphics(expand=TRUE, width=500, height=500, ps=11, container=g.f1)
Okay, I see the issue with eliding. I think the answer should be handled with the following (assuming cb
is the combobox)
cr <- cb$widget[[1]]$getCellRenderers()[[1]]
cr["ellipsize"] = PangoEllipsizeMode["none"]
But, that doesn't work. This ellipsize mode gives me an error. If you edit the code to comment out line https://github.com/jverzani/gWidgets2RGtk2/blob/master/R/gcombobox.R#L77 then the ellipsize mode defaults to the choice of "none".
This isn't really what you want perhaps. The combobox will take up more space. I would guess you want the widget to have a modest size, but the popup area to not elide the text so it would be wider. It seems like it should be possible, but I couldn't find the magic incantation. (There seem to be some options in the newer Gtk versions.)
Hmm... when I put
cr <- g.horizontal.expand$widget[[1]]$getCellRenderers()[[1]] cr["ellipsize"] = PangoEllipsizeMode["none"]
directly after the creation of g.horizontal.expand
in the original script, it does do what I want (i.e. display the unelided text, taking as much space as is required to do so), with no error. This works both on an old Redhat/Scientific Linux 5.6 box and one running Ubunut 14.04. If I put it at the very end of the script (i.e. after the two ggroup
s, it doesn't work - the text is elided as before.
I actually do want the comboxbox to take up more space and display the unelided text.
Okay, I checked in a change to gWidgetsRGtk2 that allows you to pass in a hidden argument for the ellipsize attribute. THe default is "middle", pass ellipsize="none"
to get the behaviour you want. Please let me know if it doesn't work as expected.
Many thanks - this does the trick.
Do you now regard gWidgets2 as stable? It now works for my retistruct package, and I was wondering whether when I next release I should use my gWidgets2 branch. (I would also depend on the fixes you've made in response to my reports being released to CRAN.)
I can wrap up a package for CRAN if you think you are done finding my bugs :) I think the code is mostly stable. I don't have any plans to expand the API so at this point there is likely to only be bug fixes. Though, there are still a few lurking, I'm sure...
No need to wrap up a package for CRAN just now, but perhaps I'll get back to you when I know that I'd like to release.
Me again! The code below seems to work differently between gWidgets and gWidgets2: