How to get entry text in glade3 in Ruby? - ruby

Its first my first time in stackoverflow to get help.
Im making a Ruby GUI with glade3, but i dont really now how to get texts from an entry box?
It should read the text from entry box and write it in an excel sheet.
I hope you can help me :)

See example here: https://xrob.wordpress.com/2007/04/20/creating-a-gui-application-using-glade-and-ruby/
We want to change something in the application so we will need to assign a variable to the widget that we want to alter. We want to alter “label1” and so we insert this code in the button1_clicked function.
#myEntryBox = #glade.get_widget(“myEntryBox”)
# You can now access properties like '#myEntryBox.text'
# Refer to documentation for exact name of the attribute

Related

Using Ruby Selenium to input data from csv file to complete actions until list is complete

I am fairly new to selenium ruby/rspec scripting and I have come across a use case that requires data to be pulled from a csv or xlsx file in the test. Any help or suggestions on how to approach this would be greatly appreciated.
The test would pull from the csv file and input data from each row to complete the same actions against. This particular file contains a single column of "id's" and the same action would need to be repeated until all values from the column have been used. Here is the basic steps...
User logs in
User pulls first value (id) from file to search in text field
User completes action against this id
User returns to text field and pulls value from second row of same file
User completes action against this id
This would repeat until all rows are completed
Is this possible to complete the same method repeatedly but filtering through data from the file?
How would you pull the csv file into the script and specifically grab the first value (and subsequent values) throughout?
I know this is pretty vague but I have not seen any examples such as this in SO and researching online. Any suggestions or examples would very much appreciated.
I'm not sure I fully understand your question but I can try to point you in the right direction.
Ruby has a csv parser built in which you can read about here: CVS class
One of the first examples would seem to provide you with the functinoality you are looking for. I think in your example you would want to do something like:
CSV.foreach("path/to/file.csv") do |row|
#I'm assuming ID is the first element in each row
id = row.first
method_that_does_stuff(id)
# assert that stuff has happened ...
end
does that help get you started?

Writing to text file in app inventor

After continuous search on google, I still can't seem to figure out this problem with app inventor 2.
My question is how can I write to text file as initial value without user input. For example I want to store '6' as the initial value in a text file, there are ways to do it by clicking on button but is there a way to store the initial value without getting the user to enter a value? Also would this value be available each time the app is run? or would I need to set the initial value each time?
Many Thanks in advace
is there a way to store the initial value without getting the user to
enter a value?
Normally you would use a variable to store an initial value. You do not have to store that in a file! But if you like to use a file, you can use the Screen.Initialize event
see also the documentation of the File component
Also would this value be available each time the app is run?
yes, but only if the user did not delete the file manually...
or would I need to set the initial value each time?
Please first do the tutorials to lean the basics of App Inventor!

How do I set up label/value when using JuiceUI's AutoComplete control from codebehind?

The JuiceUI AutoComplete control accepts a string[] for the Source property, yet in documentation it says you can use label/value pairs. I'm not very familiar with the jQuery autocomplete stuff to begin with, and after searching for a while I can't seem to find the correct syntax to make this work. Can anyone help me out? I'm looking for something like this:
UserAutoComplete.Source = users.Select(u => new { label = u.Id, value = u.Name});
Nice catch. Please file this as an issue here: https://github.com/appendto/juiceui/issues and we'll get a fix in there for the next release.
In the mean time, I'd use a separate map to map labels to actual values. It's a bit hackey, but it'll get you by until we update, and it'll be an easy transition with the updated code.

How to change value in a QTP data table?

Could anyone help me figure out how to enter a value into a QTP data table using VBScript? I'm trying the following line, but it doesn't seem to work:
datatable.Value(D,"sheetName")="A"
What is wrong? I am used to other languages and just cannot see any problem here.
What is the D you're using? Is it a variable holding the column name? If not and you mean to use the D column then you have to quote it so that QTP (VBScript actually) knows you mean the string "D".
datatable.Value("D","sheetName")="A"
I know zilch about QTP tool. However, your syntax looks correct based on this example. (see heading Adding Value to you a local sheet
Based on the information given, I would take a stab that you may have not referenced the QTP DLL, you have ON ERROR RESUME NEXT in your code AND you do not have OPTION EXPLICIT set at the top of your module.
Start by making sure you have the correct DLL referenced and adding this line to the top of the code:
OPTION EXPLICIT
If you've done that, then add more information that could help one deduce the problem (e.g. full code sample).
The way that you get data from datatable in QTP is, first import the Excel sheet into your datatable (Either Global or Local), then try to get data from datatable using following Syntax
Datatable(columnName,dtGlobalSheet) if imported in Global sheet
Datatable(columnName,dtLocalSheet) if imported in Local sheet
Importing Data
myFile = "C:\datasheet\excelone.xls"
datatable.Importsheet myFile,1,Global
Enter Value
DataTable("Coumn1Data", dtGlobalSheet)
This way you can get data from Excel sheet.
Thanks,
Karthik

Pass variable and its contents from workspace to GUI function in MATLAB

I have a variable in the MATLAB workspace and I want to pass the variable name and its contents to a function in my GUI.
How do I achieve this task?
I'm not totally sure what you mean when you say "pass the variable name and its contents", but here's one possible solution. After you pass a set of data to a function like so:
some_function(data); %# Pass the variable "data" to a function
You can get the variable name of the input argument from inside the function using INPUTNAME:
function some_function(inputArgument)
name = inputname(1); %# Will return "data" as the name of the input variable
end
EDIT: As pointed out in a comment by High Performance Mark, the variable inputArgument inside the function will contain the values stored in the variable data in the workspace of the caller.
If this question is related to your other most recent question, then why not build the operation into your GUI? You can use guide to create a pushbutton, and place the code under the callback function.
I am assuming that you have created the figure with GUI using the GUIDE, and that you know the 'Tag' names of the GUI objects.
((1)) Open the figure using the GUIDE, ((2)) Open the Property Inspector for the figure (select the background, the light-gray gridded area of the figure, and double-click over it, to make the Property Inspector for the figure to pop-up), ((3)) Turn the 'HandleVisibility' 'on' (by default, it may be set as 'callback'), ((4)) Save the figure and close the GUIDE, and finally ((5)) set the GUI property values from the MATLAB Console (or "Command Window") using some parameters that are currently available on your workspace.
I hope this helps.
Best,
Y.T.

Resources