Hi Monks, I have currently developed a perl file to convert Celsius to Fahrenheit. The code looks like this

#!/usr/local/bin/perl use Tk; my $mw = new MainWindow; # Main Window my $VARIABLE; my $frm_name = $mw -> Frame() -> pack(); my $lab = $frm_name -> Label(-text=>"Enter Celsius Value:") -> pack(); my $ent = $frm_name -> Entry(-textvariable=>\$VARIABLE) -> pack(); my $but = $mw -> Button(-text=>"Push Me", -command =>\&push_button) -> + pack(); #Text Area my $frm_name2 = $mw -> Frame() -> pack(); my $lab2 = $frm_name2 -> Label(-text=>"Farienhiet:") -> pack(); my $txt = $mw -> Text(-width=>40, -height=>10) -> pack(); MainLoop; #This function will be executed when the button is pushed sub push_button { $txt->delete("1.0", 'end'); my $celsius = $ent -> get(); my $farienhiet = ($celsius*9/5)+32; $txt -> insert('end', "Farienhiet is $farienhiet degrees."); }

I want the user to enter the number of values for which he wants to do Celsius to Fahrenheit. Assume he wants to convert 1 celcius value to fareinhiet, my code works. If he wants to convert 4 or 5 or 6, my code will not be able to do that. I want to let the user decide the number of values of celcius he wants to enter. Is this possible.

I was thinking of implementing a scale, like

my $scl = $mw -> Scale(-label=>"No of Celcius Values to convert :", -orient=>'v', -digit=>1, -from=>1, -to=>10, -variable=>\$celcius, -tickinterval=>2);

where the user can select any number of values from 1-10. If he selects 1, the grid can have one text location to enter and one text output, if he selects 2, then the grid will have 2 locations to enter text and 2 locations to show the fareinheit value and so on. Is this possible? Your help is greatly appreciated.


In reply to perl TK: Dynamically changing number of inputs at run time. by Ganesh Bharadwaj1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.