#i removed the comments
# sho code should work with
# 'advanced' copy/paste methods
# now as far as it works.
# my mail client seemed to
# wrap some lines
# around , so it looked odd to
# me and mailed it
# again, sry for the mess
# ps. the shared keyword wasn't very
# helpful, caused another kind of
# exception. tried to unreference
# and share too , still no effort

use strict;
use Tk;
use threads;
use threads::shared;
$|=1;

my $mw = new MainWindow('title'=>"Tiitel");

print "calling thread to alter title \n";
threads->create("alter_title",$mw);

MainLoop;

sub alter_title {
        print "altering title \n";
        my $win = pop @_;
        $win->configure('title'=>'another title');
}

#$%>-----Original Message-----
#$%>From: Martin Roos [mailto:[EMAIL PROTECTED]]
#$%>Sent: Sunday, September 22, 2002 9:43 PM
#$%>To: Perl-Ithreads
#$%>Subject: ithreads & Tk -- Any help ???
#$%>
#$%>
#$%> I wanted to start off with ithreads by implementing a clock with the tk
#$%>lib,
#$%>the bad case is that it doesn't seem to support the ithreads :(.
#$%>
#$%> Anyway this is what i do , i create a new Window and try to alter it's
#$%>title in another thread :
#$%>
#$%># ==> program starts here
#$%>use strict;
#$%>use Tk;
#$%>use threads;
#$%>use threads::shared;
#$%># for debugging
#$%>$|=1;
#$%>
#$%># constructing a new window
#$%>my $mw = new MainWindow('title'=>"Tiitel");
#$%>
#$%>#starting the other thread
#$%># which should change our title
#$%>print "calling thread to alter title \n";
#$%>threads->create("alter_title",$mw);
#$%>
#$%># this loops the tk events and refreshes the window inner things like
#$%>buttons etc.
#$%># it blocks until the window is closed
#$%>MainLoop;
#$%>
#$%>sub alter_title {
#$%>    print "altering title \n";
#$%>    my $win = pop @_;
#$%>    $win->configure('title'=>'another title');
#$%>}
#$%># ==> program endz here
#$%>
#$%>i get an error like this :
#$%> "Free to wrong pool 15d3f78 not 1da0280 at C:/Perl/site/lib/Tk.pm line
#$%>340."
#$%>
#$%>i assume that another thread is getting a bit messed up with
#$%>the allocated
#$%>mem it self
#$%>hasn't allocated ?
#$%>
#$%> anyway, is there any hope to get this working ?
#$%> i need an external thread to update the main window from time to time.
#$%> but it seems a bit hard to do when i can't access the window
#$%>that has been
#$%>created :(
#$%> maybe some kind of a back hand reference thingy could/may work ?
#$%> i already played around with some references and stuff but
#$%>didn't work that
#$%>easily :(
#$%>
#$%> Martin [ps. if the code seems a bit odd, don't mind, i haven't
#$%>programmed
#$%>in perl for 3 years ... so much is lost]
#$%>
#$%>
#$%>

Reply via email to