LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-02-2011, 06:08 PM   #1
michaelinux
Member
 
Registered: Apr 2009
Location: El Salvador
Distribution: Slackware -current
Posts: 166

Rep: Reputation: 17
Get input from entry using Gtk?


I'm trying to make a program to simulate a parabolic movement, so i've added 2 entries, one for the initial velocity and other for the angle, anyway you probably don't care about that xD
what i want is to take the number entered in the entry and put it in a variable to do the math, and then show everything in a dialog or something.
how do i do that?
 
Old 05-02-2011, 08:25 PM   #2
Hidden Windshield
Member
 
Registered: Jul 2010
Distribution: Fedora
Posts: 68

Rep: Reputation: 27
Depends on what language you're using. In C or C++ you can use the atof or sscanf functions to convert the string to a double value. Most scripting languages (Perl, Python) will automatically convert it for you. Other languages have other methods.
 
Old 05-02-2011, 09:53 PM   #3
michaelinux
Member
 
Registered: Apr 2009
Location: El Salvador
Distribution: Slackware -current
Posts: 166

Original Poster
Rep: Reputation: 17
Quote:
Originally Posted by Hidden Windshield View Post
Depends on what language you're using. In C or C++ you can use the atof or sscanf functions to convert the string to a double value. Most scripting languages (Perl, Python) will automatically convert it for you. Other languages have other methods.
OH! sorry i forgot that, the language is actually C#. I really dont like c# that much (micro$oft) but thats my assignment so...
 
Old 05-12-2011, 02:16 PM   #4
Hidden Windshield
Member
 
Registered: Jul 2010
Distribution: Fedora
Posts: 68

Rep: Reputation: 27
In that case, you should be able to just call GetText() on one entry to get what the user typed as a string, then use whatever conversion function C# provides to convert it to an int/double/whatever (sorry, not a C# programmer). Repeat with the other entry, and you have your two numbers to do the math with.

Showing the result is similar. If you just want distance traveled (for instance), just add a label to the dialog, and set its Text property to the answer. If you're trying to make a graph, that's a little harder. You'll have to use a DrawingArea for that.
 
  


Reply

Tags
entries, gtk, input



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Simlate keyborad input in C/GTK+ stny Linux - Software 2 06-21-2006 08:13 PM
Problem with frames in GTK+ - no spacing between frame and text entry Nylex Programming 8 03-01-2006 01:01 PM
GTK & keyboard input joakim12 Programming 1 07-17-2005 07:13 AM
GTK input and timeout joakim12 Programming 1 07-15-2005 03:44 PM
GTK entry nAvi Programming 2 08-16-2003 10:59 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration