Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8565831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:31:07+00:00 2026-06-11T17:31:07+00:00

I am writing a GUI with the gwidgets package in R. I am implementing

  • 0

I am writing a GUI with the gwidgets package in R. I am implementing a tool that will allow the user to select a number of variables from one list, and drag them to an empty list for collection. The inspiration is the gui from SPSS, see link:

spss drag and drop

I was planning do this with two gtables, i.e. first create one gtable with the list of variables, and an empty gtable to collect the selected variables. Below is my sample code:

  portfolioBuilder <- function(h,...){
  ## globals
  widgets <- list()
  varNames <- c("var1","var2","var3","var4" )#with(.GlobalEnv, names(data))

  #window
  win <- gwindow("Test")

  #groups
  g <- ggroup(horizontal = FALSE, container = win, expand = TRUE)
  gg <- ggroup(horizontal = FALSE, container = win, expand = TRUE)

  #graphics container
  ggraphics(container = gg)

  #paned group
  pg <- gpanedgroup(container = g, expand = TRUE)
  nb <- gnotebook(container = pg)

  ## main group
  qpg <- ggroup(horizontal = FALSE, container = nb, label = "portfolio")
  parg <- ggroup(horizontal = FALSE, container = nb, label = "portfolio args")


  ## qplot group
  tbl <- glayout(container = qpg)

  #variable list
  tbl[1,1,anchor = c(1,0)] <- "Variables"
  tbl[2:10,2] <- (widgets[["table"]] <- gtable(varNames, multiple = TRUE, container = tbl, expand = TRUE))
  tbl[3,3, anchor = c(1,0)] <- "y"
  tbl[3,4] <- (widgets[["y"]] <- gedit("", container = tbl))
  tbl[4,3, anchor = c(1,0)] <- "x"
  tbl[4,4] <- (widgets[["x"]] <- gtable(c(""),container = tbl))

  ## make table visible and set tab
  visible(tbl) <- TRUE
  svalue(nb) <- 1

  ##################################end layout#################################

  }

However my sample code spits out an error because of the empty gtable widget. Does anyone know how to accomplish this with gwidgets?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T17:31:08+00:00Added an answer on June 11, 2026 at 5:31 pm

    You’ll want to work on the layout, but the key to this is addDropSource and addDropTarget:

    options(guiToolkit=”RGtk2″)
    library(gWidgets)

    w <- gwindow(visible=FALSE)
    g <- gpanedgroup(cont=w)
    
    tbl <- gtable(names(mtcars), cont=g)
    
    
    fl <- gframe("variables", horizontal=FALSE, cont=g)
    
    dep <- gedit(initial.msg="Dependent variable", label="Dependent", cont=fl)
    ind <- gedit(initial.msg="Independent variable(s)", label="Independent", cont=fl)
    
    addDropSource(tbl, handler=function(h,...) svalue(h$obj))
    
    addDropTarget(dep, handler=function(h,...) svalue(h$obj) <- h$dropdata)
    addDropTarget(ind, handler=function(h,...) {
      cur <- svalue(h$obj)
    
      new <- ifelse(nchar(cur) > 0, paste(cur, h$dropdata, sep=", "), h$dropdata)
      svalue(h$obj) <- new
    })
    
    
    
    visible(w) <- TRUE
    

    Drag and drop support in gWidgets is really variable. Of the 6 possibilities for this to work in: gWidgetsRGtk2, gWidgets2RGtk2, gWidgetstcltk, gWidgets2tcltk, gWidgetsQt and gWidgets2Qt this code only worked in gWidgetsRGtk2.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a GUI application that will have a user log in feature. Each
I'm writing a GUI tool using PowerShell that is able to do most AD
I'm writing a GUI application with PyQt4 (Python3). One my friend pointed out that
I am writing a gui program that allows a user to repeatedly send a
I've been writing a long GUI in Python using Tkinter. One thing that I
I'm writing a GUI application that regularly retrieves data through a web connection. Since
I am writing a GUI application using Django 1.1.1. This is the views.py: from
I'm writing a GUI app with wxwidgets in C++ for one of my programming
I am writing a GUI program. In one part of it I show an
Writing a sound control applet with GUI that communicates with a device via USB.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.