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 8575969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:49:01+00:00 2026-06-11T19:49:01+00:00

I’m building my first GUI and I want it to take basic numerical input

  • 0

I’m building my first GUI and I want it to take basic numerical input from Spin Buttons and text boxes and populate a dataframe with these values, then plug them in to some function at the push of a button at the very end. I’m having trouble figuring out the Connection part of it however. I’ve got the window to look exactly how I want it to and I have all of my Spin Buttons calibrated to have the desirable default value and increase by the right number of increments, but then I’m having trouble passing it to my model. I have pre-allocated a dataframe and then I want to assign specific values to each element in the dataframe and name the columns using the input from a text box. I’ve tried simply assigning them with no success so far. I’ve also tried making them global variables and then putting them into a dataframe at the end, but no luck there either. I’m certain that I’m missing something in the gSignalConnect() command, but I can’t figure it out. The code for one text box and one Spin Button is given below, as well as the code for my “Calculate” button (I have substituted in colMeans() for my function for the sake of space).

df <- data.frame(matrix(nrow=8,ncol=5))
library(RGtk2)
window <- gtkWindow()
window["title"]<- "My First GUI"

# Add a frame
frame <- gtkFrameNew("Input")
window$add(frame)

# Create vertical container for file name entry
vbox<- gtkVBoxNew(FALSE, 9)
frame$add(vbox)

# Add horizontal container for every widget line
hbox<-gtkHBoxNew(FALSE, 4)
vbox$packStart(hbox, FALSE, TRUE)
label <- gtkLabelNewWithMnemonic("Dataframe Column 1          ")
hbox$packStart(label,FALSE,TRUE)

# Add a text box that allows the user to name Dataframe Column1
col1nameLAB<-gtkLabel('Name: ')
col1name<-gtkEntryNew()
col1name$setWidthChars(20)
hbox$PackStart(col1nameLAB)
hbox$PackStart(col1name,FALSE,TRUE)
gSignalConnect (col1name,"value-changed",function (entry) {
names(df)[1] <- (entry$getText()}))

# Add a spin button for a numerical value that will eventually be the first value in Column 1 of the dataframe
col1valLAB <- gtkLabel("Integer Value: ")
col1valADJ <- gtkAdjustment(30,1,100,1)
col1valSB <- gtkSpinButton(col1valADJ,1,0)
gtkSpinButtonSetValue(col1valSB, 30)
hbox$PackStart(col1valLAB)
hbox$PackStart(col1valSB)
gSignalConnect (col1valSB,"value-changed",function (entry) {
df[1,1]<-entry$getValue()})

# Add a button to recalculate the model
hbox = gtkHBoxNew(FALSE,1)
vbox$packStart(hbox, FALSE, FALSE, 0)
button <- gtkButtonNew ( )
button$setLabel ( "Calculate" )
hbox$ packStart ( button )

# Now specify what happens when button is clicked:
gSignalConnect (button, "clicked",
f<-function( widget) {
  colmeans(df)
} )
  • 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-11T19:49:02+00:00Added an answer on June 11, 2026 at 7:49 pm

    This works, not sure what isn’t working for you:

    library(RGtk2)
    
    df <- data.frame(a=1)
    
    w <- gtkWindow()
    
    col1valADJ <- gtkAdjustment(30,1,100,1)
    col1valSB <- gtkSpinButton(col1valADJ,1,0)
    w$add(col1valSB)
    
    gSignalConnect(col1valSB, "value-changed", function(entry, ...) {
      val <- entry$getValue()
      message("Change to ", val)
      names(df)[1] <<- val
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
We're building an app, our first using Rails 3, and we're having to build
I have a text area in my form which accepts all possible characters from
I have a bunch of posts stored in text files formatted in yaml/textile (from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.