This was really helpful. I was also thinking of using hash for storing and re-positioning the text items upon clicking on up and down button. I proceeded as below but a bit stuck. Let us assume I have put your code in a subroutine called build_layout()
my $dynamic_hash = {0 => "job",1=> "state",2 =>"dependencies",3=>"resu
+lt"};
&build_layout($init_hash);
sub build_layout
{
## samething what u have sent
foreach my $itemkey (sort keys %$dynamic_hash)
{
my $btn=$text->Checkbutton(%attr_item,'-activebackground'=>'#ff7f7
+f'
);
my $up=$text->Button(-text=>'Up',%attr_btn, -command => [\&moveup,
+${$dynamic_hash}{$itemkey} );
my $down=$text->Button(-text=>'Down',%attr_btn,)-command => [\&mov
+edown,${$dynamic_hash}{$itemkey};
.....
.....
$text->insert('1.0',sprintf('%-'.$item_width.'s',${$dynamic_hash}{
+$itemkey}));
}
sub moveup
{
my $text = shift
### not able to proceed here
}
sub movedown
{
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|