By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,773 Members | 1,724 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,773 IT Pros & Developers. It's quick & easy.

Refreshing the Mainwindow (Tk)

P: 62
Hi!

I read data from COM and I want them show in widgets of Mainwindow. From the
subrutin whereabouts I read , I go back to the Mainwindow . How can I fast and automatically go back to the read subrutin.(the repeat function is to slow->1ms). Presently I runnig 2 scripts paralell and push the data to Mainwindow with a PIPE, but I want this make with only 1 Srcipt. How can I do this?

Thanks!
Sep 21 '08 #1
Share this Question
Share on Google+
3 Replies


numberwhun
Expert Mod 2.5K+
P: 3,503
Wow! That was a heck of an explanation that was really confusing, sorry. Without your code and a much clearer explanation of your issue, we won't be able to help you.

Why not post your code (enclosed in code tags, that way we can take a look at it and try and help you.

Regards,

Jeff
Sep 21 '08 #2

P: 62
Thanks!

which code send I? The 2 what I run now or, it the 1what I want but I need yours help?
Sep 21 '08 #3

P: 62
Well, I try to demostrate the problem during the next simplidied example


Expand|Select|Wrap|Line Numbers
  1. use Win32::SerialPort 0.09;
  2. use Tk;    
  3.  
  4. $mw=MainWindow->new();    
  5.  
  6. $mw->maxsize(600,470);                                
  7. $mw->minsize(600,470);
  8.  
  9. ###########################  widgets #######################x
  10. $d1=0.000;
  11.     $e1=$mw->Entry(-width => 10,            
  12.                    -textvariable => \$d1);    #here iwant display the data from port        
  13.     $e1->place(-x =>100, -y =>100);    
  14.  
  15.  
  16. $g2 = $mw->Button(-text => "Start read",                    
  17.                   -command => sub{ &read}   #here i start the first read
  18.                                 );
  19. $g2->place(-x => 240, -y => 100);
  20. ######################### Port Object#########################
  21. unless ($soros_port = Win32::SerialPort->new ('com1')) {
  22.     printf "Nem tudtam megnyitni a soros portot!\n";
  23.     exit 1;
  24.  
  25. $soros_port->baudrate(9600)        || die "rossz BAUD";
  26. $soros_port->parity('even')        || die "rossz Parias";
  27. $soros_port->databits(8)        || die "rossz Adatbit";
  28. $soros_port->stopbits(1)        || die "rossz Stopbit";
  29. $soros_port->buffers(4096,4096)    || die "rossz Buffer";
  30. $soros_port->handshake("none")    || die "rossz Handshake";
  31. ##########################################################    
  32. MainLoop();
  33.  
  34. sub read  #the function go back whit the data  freshing the $e1 widgets
  35.     {
  36.         while(1)
  37.             {
  38.             ($count_in, $d1)    = $soros_port->read(1) or die "itten"; 
  39.                 if($count_in!=0) {last;}
  40.             }
  41.     }
  42. ###########################################################
  43.  
How can after the return of " sub read" (so refreshing the widget)
fast and automatically call the "sub read" again and again?->so can I continous displaying the data from port
Sep 21 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.