Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Building a Dynamic GUI

by jonficke (Initiate)
on Jul 18, 2007 at 01:23 UTC ( [id://627171]=perlquestion: print w/replies, xml ) Need Help??

jonficke has asked for the wisdom of the Perl Monks concerning the following question:

Someone please help me. I’m trying to figure out what software / server packages to use to achieve the following goal. I’m trying to create a web page that allows the user to enter some numerical values such as coefficients for a function, and then plot the function real time on the same web page. What programming packages will allow me to make interactive graphics such as mentioned above. Note: I can easily to this in VB.net, but do not know who to make it a web based application. At the moment I’ve been doing VB script, but haven’t been able to figure out how to do the graphical interface portion. Any help that you can provide is appreciated. Jonathan

Replies are listed 'Best First'.
Re: Building a Dynamic GUI
by chanio (Priest) on Jul 18, 2007 at 03:59 UTC
    Hi,

    You shouldn't start thinking in the html transcription...

    Just do it at the command line and then try to pass the output to a file. Then the problem is displaying the content of the file, ok?

    The simplest way is by using the iframe html command. Just mention the file with the output in any html page and you'll have it inside the html page.

    If you want to add a graphics done with any application that does graphics (google it), you need to have a .gif or .png or .jpg output of it done. Then you must have an html page pre-made (template) with the desired size of the image (html image) predefined and pre-placed in it where you want it. Say, you have a blanc gif file and insert it in the html page. If you have named the html image as graphic.gif then you should rename the output graphic as graphic.gif (copy it over the blank image) and redisplay your html page.

    Then for handling all this authomatically you should need to make system calls from a cgi module (CGI.pm) that should do the outputs.

    For more interactive pages you should need to add some AJAX programming inside the html page (search CPAN). But before reaching such interactiveness, I guess that you are going to come very frequently to ask more punctual questions about all this.

    Recomended: Perlmonk's Tutorials articles to read and try.Good luck!

Re: Building a Dynamic GUI
by cool (Scribe) on Jul 18, 2007 at 09:24 UTC
    In my case, I have used GD and GD::Graph to create dynamic image generation. These provide lots of flexibility to the job. And gives you benefit to remain in domain of Perl also. As you are here so I assume you enjoy that too :)
    cheers
Re: Building a Dynamic GUI
by moritz (Cardinal) on Jul 18, 2007 at 07:11 UTC
    You can do that on the client side as well with javascript, javascript function plot will surely help you.

    Though of course that will fail if javascript is disabled or not available, so a server side solution would be better.

Re: Building a Dynamic GUI
by leocharre (Priest) on Jul 18, 2007 at 12:42 UTC

    Sounds to me like you know your stuff. And that your stuff is indeed not web stuff :-)

    Separate the part where you take the input, generate the output, and present it to the end user.

    What is the longest that this can take to process?

    Limit the input, that is, check it. Test out what happens when you are feed bogus info.

    If your program is cpu intensive (likely, with graphics, possibly multiple users) what happens if each run takes 60 seconds, and 4 users keep hitting refresh on their browsers? Will it crash your server?

    If the operation is intensive, and could take up to a minute, consider using sessions, and storing something like 'has user queued a call to genereate output yet?' and 'how old is that call to generate output?'

    Maybe if the user refreshes, the session should be checked to see if a call no older then x is present from this user.

    I would personally separate all this into something that works without any web interface- first. Once you test that out to see that it doesn't grind the server to a halt- you can worry about the interface.

    I would use CGI::Application. But this *may* be overkill. If you all you are doing is

    • initiate session (CGI::Session)
    • show input form
    • accept input, match against session to know they are not hitting refresh a million times
    • pass the parameters to maybe another script or using fork(), record in session this user has queued a call for output
    • and perhaps every page reload, check if a user call for output is ready.

    Then again maybe it's not overkill. If you do use CGI::Application, make *sure* you look over the plugins, for example, CGI::Session has a CGI::Application::Plugin::Session counterpart which is candy to use.

    Maybe you could even email the results to them instead. So your system would have a queue whith entries are identified by email address.

    I think you should really see this as two problems- a) what your program does (generate a graph)- b) and balancing load and requests from blowing up everything.

Re: Building a Dynamic GUI
by Anonymous Monk on Jul 18, 2007 at 11:38 UTC
    Have you looked at gnuplot?
    it's command line only, so its great for the web.
    I wrote a perl interface to gnuplot for a project but i am seriously thinking about GD:graph.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://627171]
Approved by jesuashok
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-03-29 10:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found