Thread Aktualisierung von Canvas (3 answers)
Opened by Gast at 2008-01-15 14:05

Gast Gast
 2008-01-15 14:05
#104734 #104734
Hallo,


ich würde gerne die Position zweier Elemente in einem Canvas anzeigen.
Das funktioniert auch so weit ganz gut. Sobald sich die Position der Elemente aber ändert (was durch eine sub routine ausgeführt wird) werden die aktuellen Positionen nicht aktualisiert.

Erst wenn Aktualisierung abgeschlossen ist, wird die Endposition angezeigt. Ich hätte aber auch gern, dass die Zwischenschritte ausgegeben werden.

Probiert habe ich schon mit
Code: (dl )
$canvas->update; 

bzw.
Code: (dl )
$mainWindow->update;


das Canvas zu "überreden" mir nach jedem Schleifendurchlauf die neuen Positionen anzuzeigen.. hier ein Auszug aus dem Code... nicht wichtige Passage habe ich sinngemäß gekürzt:

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
sub showPosData
{
control::geti2caddress($i2c);
my $robot = shift;
my $target = shift;
my $dist;
$posshow->delete('all'); #Canvas das die Positionen anzeigen soll(te)
{
foreach (sort keys %$oo)
{
if ($oo->{$_}{pos}{x} > 0 and $oo->{$_}{pos}{y} > 0)
{
my $color = 'blue';
$color = 'red' if ($oo->{$_}{mode} eq 'active');
pos::createText($posshow, $oo->{$_}, $_, $color); #erstellt die Texte fürs canvas
}
else
{
control::stopmotor();
}
}
my $targetangle = pos::calcDirection($oo, $currentactive, $currentpassive);
my ($x, $y) = pos::createAngle($targetangle);

$posshow->createLine($oo->{$robot}{pos}{x}, $oo->{$robot}{pos}{y}, $oo->{$robot}{pos}{x} + $x, $oo->{$robot}{pos}{y} + $y, -fill => 'red', -arrow => 'last');

[ ... ]

$posshow->update; #Canvas aktualisieren... geht aber nicht :((((
}
}

View full thread Aktualisierung von Canvas