jverzani / gwidgets2 Goto Github PK
View Code? Open in Web Editor NEWRewrite of gWidgets
Rewrite of gWidgets
Please add example in ?gexpandgroup
:
if(interactive()) {
w <- gwindow("Box containers")
g <- gvbox(cont=w) # ggroup(horizonta=FALSE, ...)
nb <- gnotebook(cont=g); gbutton("one", label="one", cont=nb)
gframe("Frame", cont=g)
pg <- gpanedgroup(cont=g); gbutton("one", cont=pg); gbutton("two", cont=pg)
eg <- gexpandgroup(cont=g, horizontal=FALSE); glabel("Click above to hide", cont=eg); gbutton("one", cont=eg); gbutton("two", cont=eg)
}
I notice in ?gdf
:
"need example of do.subset
feature using visible<-
"
I am now looking for exactly such an example, as I would like to hide/show certain rows in an existing gdf() instance. Could you provide one?
This issue is motivated by the sometimes missing documentation for expand
, fill
(and perhaps other) arguments.
For example gtext(cont=dlgg, expand=TRUE)
is clearly a valid construct with a very specific outcome (different from gtext(cont=dlgg)
), but ?gtext
says absolutely nothing about expand
.
Sometimes it's hard to figure out which widget supports which arguments.
When you add item, gfilter() now automatically selects the first variable (which is useful). However the 'edit by' options are disabled. I think it should be easy to fix this.
The second issue is rather minor: If you try to increase the width of the window, the gedit() widget doesn't follow. I think it would be nice if it mirrored width changes in the gwindow().
https://github.com/landroni/gWidgets2-filter
I get many warning messages in checkboxgroup search:
warnings()
Warning messages:
1: In grepl(val, u, ignore.case = TRUE) :
input string 1 is invalid in this locale
Is this related to my data?
Currently doing insert(gtext_obj, "asdf")
will invariably prepend/append the text to existing text already in the widget. It would be useful to be able to replace existing text via an append=FALSE
argument. Alternatively you could make the where=
argument to take the values c("end", "beginning", "at.cursor", "replace")
.
Moreover, after a text is being inserted the window is scrolled to the end of the widget. Sometimes it would be better if the cursor ended up actually at the beginning of the widget. So how about adding a cursor.pos=c("default", "end", "beginning")
? With "default" being the current behaviour, "end" placing the cursor and scrolling the window to the end of the text widget, and "beginning" placing the cursor and scrolling the window to the beginning of the text widget.
gWidgets2 v1.0-5 from CRAN with:
gWidgets2RGtk2 v1.0-2 from CRAN: stock icons are show only in toolbar.
gWidgets2RGtk2 from GitHub: stock icons are shown in toolbar, buttons, images, but are not shown in menu.
In gfilter(), disable the 'Include NA' checkbox when no NA
values are present in the variable. Now it's always activated even when it has no function.
When searching for some "non-matched-string" in gcheckboxgroup() and the filtered list of checkboxes should be empty, a non-functional checkbox is instead presented to the user. This is on big deal, but it would be better to avoid displaying this. If possible, it would be nice to display a "No match found" message in such cases.
https://github.com/landroni/gWidgets2-filter/blob/master/gWidgets2-filter.R
require(MASS)
Xa <- Cars93 ## this will be in a function... replace with your won
dffilter(Xa)
Now Add item, Manufacturer, Multiple selection. Hit Clear button to select none. And proceed as follows:
To my understanding what happens is that past selections get cleared when filtering the gcheckboxgroup items, and this is unexpected in many cases. If the user wants to clear past selection, she should simply use the Clear button. Moreover, this filtering system should allow the user to easily check disparate items: Audi and Saab. Now filtering for 'Audi' and checking then filtering for 'Saab' and checking would result only in Saab being checked, which is unhelpful.
Could this be fixed?
As per http://stackoverflow.com/questions/24706434/how-to-assign-icons-to-gnotebook-tabs/24741832#24741832 , I was wondering if there should be gnotebook()
argument or method to assign icons to tabs.
The following function can do this:
add_stock_icon <- function(nb, nm, page, left=TRUE){
child <- nb$widget$getNthPage(page-1)
box <- nb$widget$getTabLabel(child)
icon <- gimage(stock.id=nm)
box$packStart(icon$widget$parent)
if(left) box$reorderChild(icon$widget$parent, 0)
}
Should there be something similar included in gWidgets2?
https://github.com/landroni/gWidgets2-filter/blob/master/gWidgets2-filter.R
require(MASS)
Xa <- Cars93 ## this will be in a function... replace with your won
dffilter(Xa)
Add item, then try to resize the width of the dialogue. Notice that the input box doesn't expand. This should be fixed to handle cases where the variable names are long (~20chars).
require(MASS)
data_set <- Cars93 ## this will be in a function... replace with your won
then using gfilter() select variable Model and option 'range' and hit OK. The window will refuse to close, among other buggy elements.
Using Gtk2
Hi John @jverzani ,
I am wondering there is any replacement function for id() in gWidgets2?
Thanks
Best regards,
JunJie
https://github.com/landroni/gWidgets2-filter/blob/master/gWidgets2-filter.R
I always get this message. No idea if this is important:
(R:11669): Gtk-CRITICAL **: gtk_tree_view_unref_tree_helper: assertion `node != NULL' failed
gcombobox() doesn't return the correct index if the user types the value into the input box. This was originally discussed in #39, but I'm moving it to a separate ticket.
Here's a reproducible example of the issue:
w <- gwindow("Range widget", visible=T)
g <- ggroup(cont=w, horizontal=F)
sl <- gcombobox(1:10, cont=g, editable=T, use_completion=T)
Use the combo to select 5
and then:
svalue(sl); svalue(sl, index=T) ##OK
[1] "5"
[1] 5
Erase 5
, and type 4
, then:
svalue(sl); svalue(sl, index=T) ##Incorrect index
[1] "4"
[1] 0
So when typing in the value (whether 4
or 5
or 9
), svalue(sl, index=T)
always returns 0
, which seems to be a bug.
Source https://github.com/landroni/gWidgets2-filter/blob/master/gWidgets2-filter.R
Then 'Add item' and select Manufacturer. Notice that you have 'Chrylser' twice in the list, although I suspect it should be displayed only once.
nchar(as.character(Cars93[ grepl('Chry', Cars93$Manufacturer), 1]))
[1] 8 8 8
But maybe something is fishy with the databse as the following yields only two hits:
nchar(as.character(Cars93[ Cars93$Manufacturer=='Chrysler', 1]))
[1] 8 8
Could we have the same Gtk2 search mechanism in the 'add item' variable combobox ? It would be handy when the data frame has >100 variables.
and document (cf. #51)
Today I'm unable to install gWidgets2 from GIT:
require(devtools)
Loading required package: devtools
install_github("gWidgets2", "jverzani")
Installing github repo(s) gWidgets2/master from jverzani
Installing gWidgets2.zip from https://api.github.com/repos/jverzani/gWidgets2/zipball/master
Error: client error: (403) Forbidden
Any ideas why this is happening? Is it an issue with github, or something local? Internet is working fine here.
In some instances (say, when using a gslider() ) it would be useful to be able to delay the triggering of addHandlerChanged() by a small amount of time, say 0.25sec, to avoid unnecessary UI slowness. (For example, when the user scrolls a slider which automatically triggers a relatively CPU intensive operation, then the scrolling of the slider becomes jerky. In these cases a small delay between the change and the triggering of the handler can be useful.)
Can this be done in gWidgets2?
In gfilter, could we trigger search immediately after changing an option (say, change to Ignore Case)? Now after changing an option the user needs to re-run manually the search.
I'm wondering if this is expected behaviour.
w <- gwindow("gtext example", visible=FALSE)
g <- gvbox(cont=w)
t2 <- gtext("monospace", font.attr=list(family="monospace"), container=g)
visible(w) <- TRUE
Now if you do svalue(t2) <- "monospace"
, you will notice that the widget font is no longer Monospace. I would have expected that the attributes of a gtext()
object were not dropped unless specifically requested.
Try this in RStudio:
w <- gwindow("notebook example")
nb <- gnotebook(container=w)
Now in the RStudio Environment pane hit the "refresh" button and notice that the refresh happens as expected. Then close the w
window and re-try the "refresh" button in RStudio. You should get:
Error in class(obj) <- "rs.scalar" : attempt to set an attribute on NULL
Error in class(obj) <- "rs.scalar" : attempt to set an attribute on NULL
To get rid of these messages you need to rm(w); rm(nb)
.
Is this an RStudio issue?
https://github.com/landroni/gWidgets2-filter/blob/master/gWidgets2-filter.R
Then add item, Manufacturer, Select range. This shouldn't happen as Manufacturer is a factor.
@jverzani
the addHandlerUnrealize() closes the window regardless of what the handler returns. Compare the tests in
https://github.com/jverzani/gWidgets2/blob/master/inst/tests/window.R
which show this behaviour
Without an X display RGtk2 realizes that there is no display, but gWidgets2 crashes R nonetheless. To replicate on Linux:
DISPLAY=:1.1 R
source("gWidgets2-filter.R")
dffilter(iris)
Can gWidgets2 detect this and avoid crashing R?
*** caught segfault ***
address 0x18, cause 'memory not mapped'
Traceback:
1: .Call(name, ..., PACKAGE = PACKAGE)
2: .RGtkCall("S_gtk_container_add", object, widget, PACKAGE = "RGtk2")
3: method(obj, ...)
4: block$add(widget)
5: .Object$initialize(...)
6: initialize(value, ...)
7: initialize(value, ...)
8: methods::new(def, ...)
9: GText$new(toolkit, text = text, width = width, height = height, font.attr = font.attr, wrap = wrap, handler = handler, action = action, container = container, ...)
10: .gtext.guiWidgetsToolkitRGtk2(toolkit, text = text, width = width, height = height, font.attr = font.attr, wrap = wrap, handler = handler, action = action, container = container, ...)
11: .gtext(toolkit, text = text, width = width, height = height, font.attr = font.attr, wrap = wrap, handler = handler, action = action, container = container, ...)
12: gtext(cont = dlgg2, font.attr = list(family = "monospace"), width = 300, height = 25 * 6, expand = T, fill = T)
13: dffilter(iris)
Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection: 1
aborting ...
Sometimes I get in trouble by async evaluation of commands. Is it possible to run some commands in !async mode?
https://github.com/landroni/gWidgets2-filter/blob/master/gWidgets2-filter.R
Try this:
Xa <- mtcars[, 1:5]
Xb <- mtcars[, 1:2]
Xc <- cbind(Xa, Xb)
View(Xc)
dffilter(Xc, T) ##edit smth and try to Merge..
Error in[<-.data.frame
(*tmp*
, idxs, cnms, value = list(mpg = c(21, :
duplicate subscripts for columns
Can dffilter() work around such cases? Or at least display a nice informative pop-up?
Now the search options pops up a selection or "radio" choices. Would it be possible to have checkboxes instead? As it is in the case of grepl()?
See #29 for some background. I feel a bit limited by the gslider()
interface with regard to permitted steps. Would it be possible to allow an items=
argument, as in gcombobox()
, to allow the developer to use a pre-existing list of allowed steps (as from seq_sane())?
Hi John @jverzani ,
There is a doubtful point in my gWidgets2 design.
I want to add gradio inside the glayout.
Suppose I have a glabel at the 4th row, a small layout in the 6th row.
I defined a radio group in 5th row but it actually go the bottom of the layout, the 13rd row.. The layout I have defined had totally 14 rows...
More interesting is, if I set the radio group inside 15, it still be 13...if I set it inside 16,17,18,19,20, it is still 13rd. It always goes to the last second row..
Thank you.
Just checked and I think I still have trouble with this case. If you
https://github.com/landroni/gWidgets2-filter/blob/master/gWidgets2-filter.R
Xa$Man.trans.avail1 <- as.logical(Xa$Man.trans.avail)
dffilter(Xa, TRUE)
Then display Man.trans.avail1 column. You will notice that the column
class is 'logical', that checked checkboxes are displayed, and that
you cannot modify these checkboxes. I think that if a variable
contains only NAs, then we should display just that: NA. Inserting a
string or a number or a logical in any of the cells should
automatically switch the column class to 'character' or 'numeric' or
'logical'. What do you think?
- As for all NA values, the odd thing is R will think this is a logical
vector unless you do assignment with NA_real_ which of course no one does.
I'll have to hack gtable to look at this case, but haven't done so yet.
Recent commits seem to have broken 'single' choice item in gfilter. When I try to add such item I get:
Error in use_completion() : object 'e' not found
This is sitting rather high on my TODO list ( https://github.com/landroni/gWidgets2-filter/blob/master/TODO ), but I have trouble deciding how best to integrate it into gfilter().
I was thinking of providing a "preset" filtering item that could be 'Add'ed as other row filters, but instead of focusing on any given variable, it would present a generic interface for head(), tail() and car::some(). The funs are extremely useful when inspecting a data frame, for example when checking that some operation on a DF went as expected.
This thingy could take the form of a gfilterpreset() fun modeled on gfilter(), that when called via 'Add preset' would add a widget that has three radio choices c('head', 'tail', 'some'), with 'some' being disabled if package 'car' is not available and below either a scrollbar with 1:nrow(df) or a spinner with same range. I think it should be possible to checkbox negative for the range, as head and tail allow, but not some.
Is this feasible?
https://github.com/landroni/gWidgets2-filter
When viewing a data frame and adding some filter to display only a subset of the data frame, sometimes it would be useful to be able to display only unique rows. Could this be done with gdf()? Maybe via some context-menu item? And some visual feedback that the 'unique' checkbox is currently checked?
Thanks!
Would it be possible to have multiple selection mode for gcheckboxes? It should be possible to click on a checkbox and press shift and click on a different checkbox: all intermediary items should get checked, too.
There appears to be a problem with the display of a togglebutton (in gcheckbox) within a glayout: neither the button nor the label appears. This worked fine with gWidgets. See example below:
library(gWidgets2)
options("guiToolkit"="RGtk2")
w1=gwindow()
w2=glayout(container=w1)
w2[1,1]=gcheckbox("test",use.togglebutton=TRUE)
Please document in ?gradio
that the argument items
"can be a character vector or a named character vector". Perhaps amending the example to show off how it works would be useful, too. Say add:
gradio(c('a'='Letter A', 'b'='Letter B', 'c'='Letter C'), selected=1, horizontal=TRUE, cont=fl, label="gradio")
Moreover, the examples use the label
argument, but it doesn't seem documented. This holds for ?gradio
, ?gcheckbox
, etc. Is this an omission?
Now in gdf() column names are frozen when scrolling vertically. It would be nice if the same effect for row names: when scrolling horizontally, freeze row names. Could this be done?
Now gdf() displays Date variables in as.numeric(obj$Date_var) format. I think this is a bug.
I have recently installed gWidgets2 and gWidgets2Rgtk2 on my Mac. A simple test fails with an error in malloc. Before failing, it does show a window with an Ok and Cancel button.
Here is what I am doing, running right after starting R:
require(gWidgets2)
Loading required package: gWidgets2
Loading required package: digest
w <- gbasicdialog(title="Hello, World")
Loading required package: gWidgets2RGtk2
Loading required package: memoise
Loading required package: RGtk2
visible(w, set=TRUE)
R(14313,0x7fff7e9fd960) malloc: *** error for object 0x4024000000000000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6
I am running:
I would appreciate any help in solving this.
Barbara
I am now experimenting with edit factor levels in gdf(), and I must admit I'm a bit confused by the interface. First, I see no way to re-order factor levels. Maybe an interface to relevel() would be useful?
Second, the message on the right is long and convoluted. I'm not sure how to proceed, and what it will achieve. If I select a level (as the message suggests), nothing happens. If I double-click (what the message should probably indicate), then I get into the input box on the right. But then: if I put in a new name and enter nothing happens; if I select an existing level, I don't see anything happening either.
And last, I think it should be possible to add new levels (in addition to existing ones). Or is it a bad idea?
Please allow for gtext() widget to be read-only. I would like for the user to be able to see a cursor and move the cursor (as it is), but simply be unable to perform any modifications via the keyboard (the current feature request). This can be useful when you want to output in the GUI, say,
> describe(iris[ , 3:5])
iris[, 3:5]
3 Variables 150 Observations
----------------------------------------------------------------------------------------------
Petal.Length
n missing unique Mean .05 .10 .25 .50 .75 .90 .95
150 0 43 3.758 1.30 1.40 1.60 4.35 5.10 5.80 6.10
lowest : 1.0 1.1 1.2 1.3 1.4, highest: 6.3 6.4 6.6 6.7 6.9
----------------------------------------------------------------------------------------------
Petal.Width
n missing unique Mean .05 .10 .25 .50 .75 .90 .95
150 0 22 1.199 0.2 0.2 0.3 1.3 1.8 2.2 2.3
lowest : 0.1 0.2 0.3 0.4 0.5, highest: 2.1 2.2 2.3 2.4 2.5
----------------------------------------------------------------------------------------------
Species
n missing unique
150 0 3
setosa (50, 33%), versicolor (50, 33%), virginica (50, 33%)
----------------------------------------------------------------------------------------------
You would want the user to easily select and copy the text, but NOT inadvertently modify it.
https://github.com/landroni/gWidgets2-filter/blob/master/gWidgets2-filter.R
Hit Add item and without selecting a variable
hit OK. I think OK should be disabled too if no selection was made.
It would be nice if we could do that.
https://github.com/landroni/gWidgets2-filter/blob/master/gWidgets2-filter.R
Recent gWidgets commits seem to have broken something. When I try to hit 'Display' I get this:
Error in set_frame(items) : could not find function "nms"
Error in obj$remove_child(child) : attempt to apply non-function
Any idea what's wrong?
Is it possible to assign, for example, R's icon to the window() instances of gWidgets? If not, could this be implemented? Currently on Xfce you simply get a missing app icon for gWidgets instances.
This works fine using the original gWidgets package (with RGtk2), but with gWidgets2 I get an error.
For example (where "newpng.png" was added using addStockIcons):
gimage("newpng",dirname = "stock",container=g)
File stock/newpng is not found
Error in .Object$initialize(...) :
Is this a minor bug or is there a workaround for this?
Many thanks,
Patrick
gcombobox with Gtk2 will not work for item strings less than 3 characters (not the case when using tcltk or the originial gWidgets packages with Gtk2). See 3 examples below where I increment the length of the strings to be presented in the gcombobox:
w=gwindow()
gcombobox(c("a","b"),container=w)
Error in[[.GObject
(x, member, where = ) :
Cannot find 'setWidthRequest' for classes GtkComboBox, GtkBin, GtkContainer, GtkWidget, GtkObject, GInitiallyUnowned, GObject, RGtkObjectgcombobox(c("aa","bb"),container=w)
Error in[[.GObject
(x, member, where = ) :
Cannot find 'setWidthRequest' for classes GtkComboBox, GtkBin, GtkContainer, GtkWidget, GtkObject, GInitiallyUnowned, GObject, RGtkObjectgcombobox(c("aaa","bbb"),container=w)
Object of class GComboBoxNoEntry
thanks
Pat
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.