Schrift
[thread]10898[/thread]

Tk::Graphitems

Leser: 1


<< |< 1 2 3 >| >> 25 Einträge, 3 Seiten
Gast Gast
 2007-11-26 16:07
#103046 #103046
Hallo Leute,

ich wollte in einem Canvas widget mittels dem Modul Graphitems
eine neue TextBox erstellen.

Code: (dl )
1
2
3
...
my $can = $objects->Canvas(-relief => "raised", -borderwidth => 2, -width => 225, height => 150)->place(-x => 5, -y => 180);
...

erstellt mir hierbei das canvas...

mit

Code: (dl )
 my $node = Tk::GraphItems::TextBox->new(canvas => $can, text => 'test', x => 50, y => 50);


wollte ich anschließend eine TextBox erstellen, allerdings stürzt das Programm dann mit folgender Fehlermeldung ab:



Use of uninitialized value in concatenation (.) or string at c:/PROGRA~1/perl/si
te/lib/Tk/GraphItems/TextBox.pm line 123, <DATA> line 164.
something is wrong with this 'canvas':<> Can't call method "isa" on an undefined
value at c:/PROGRA~1/perl/site/lib/Tk/GraphItems/TextBox.pm line 122, <DATA> li
ne 164.
at c:/PROGRA~1/perl/site/lib/Tk/GraphItems.pm line 74
Drücken Sie eine beliebige Taste . . .
Spieler
 2007-11-26 18:28
#103073 #103073
User since
2007-09-24
70 Artikel
BenutzerIn
[default_avatar]
Hallo,

kannst du mir ein Beispielprogramm, mit dem das passiert schicken?
-Du kannst es natürlich auch hier posten.

Grüße, Christoph

ch.l.ngre@online.de
Spieler
 2007-11-26 20:53
#103078 #103078
User since
2007-09-24
70 Artikel
BenutzerIn
[default_avatar]
Hallo,
Kannst du das mal so probieren:
Code: (dl )
my $node = Tk::GraphItems->TextBox(canvas => $can, text => 'test', x => 50, y => 50);


Vielen Dank, das ist ein Bug.

Grüße, Christoph
Spieler
 2007-11-27 00:26
#103087 #103087
User since
2007-09-24
70 Artikel
BenutzerIn
[default_avatar]
Hallo,

weil das so ein interessantes Verhalten ist, auf das ich das erste Mal stoße, möchte ich es hier zur Diskussion stellen:
Tk::GraphItems macht aus Tk::GraphItems->TextBox(args) Tk::GraphItems::TextBox->new(args)
dient also nur der Bequemlichkeit...
Nun scheint es so zu sein, dass im Code eines Benutzers, allerdings nur wenn Tk::GraphItems per 'use' eingebunden wird, der Ausdruck
Code: (dl )
Tk::GraphItems::TextBox->new 
aufgelöst wird zu:
Code: (dl )
(Tk::GraphItems::TextBox())->new 

Wenn man das Modul dagegen 'require'-d , erhält man, (wie von mir eher erwartet)
Code: (dl )
'Tk::GraphItems::TextBox'->new 

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use strict;
use warnings;
use Tk;
use Tk::GraphItems;
#require Tk::GraphItems;
use Tk::GraphItems::TextBox;

my $mw = tkinit;
my $c = $mw->Canvas->pack;

my $tb = Tk::GraphItems::TextBox->new(canvas => $c,
x => 10,
y => 20,
text => 'test');
MainLoop;


Ein Fix ist auf Cpan. (Nie wieder groß geschriebene Methodennamen)
Grüße, Christoph
Gast Gast
 2007-11-27 10:48
#103094 #103094
Hier schon mal ein großer Teil dessen, was den Fehler erstellt...
ich bitte den schlechten Programmierstil zu entschuldigen...
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
my $mw = new MainWindow(-title => "Robot Control GUI", -height => 600, -width => 800);
my $objects = $leftframe->Frame(-relief => "raised", -borderwidth => 2,-height => 350, -width => 250)->grid(-row => 1, -sticky => "nw");
$objects->Label(-text => "OPTICAL OBJECT SETUP\n========================================")->place(-x => 0, -y => 0);

$objects->Label(-text => "select object file:")->place(-x => 5, -y => 40);
$selectobo = $objects->JComboBox(-choices => \@obolist)->place(-x => 120, -y => 40);
$selectobo->setSelectedIndex(0);
$objects->Button(-text => 'select for configuration', -command => sub {&config($selectobo)} )->place(-x => 67, -y => 70);
$objects->Label(-text => '----------------------------------------------------------------------------')->place(-x => 5, -y => 92);
$objects->Label(-text => "configuration for")->place(-x => 5, -y => 110);
$objects->Entry(-relief => 'flat', -textvariable => \$cursel, -state => 'disabled', -width => 20)->place(-x => 95, -y => 110);
$rb1 = $objects->Radiobutton(-text => ' active', -value => "active", -variable => \$obomode, -command => \&modeselect)->place(-x => 45, -y => 140);
$rb2 = $objects->Radiobutton(-text => ' passive', -value => "passive", -variable => \$obomode, -command => \&modeselect)->place(-x => 45, -y => 160);
$can = $objects->Canvas(-relief => "raised", -borderwidth => 2, -width => 225, height => 150)->place(-x => 5, -y => 180);
foreach (sort keys %{$oo})
{
my $node = Tk::GraphItems::TextBox->new(canvas => $can, text => 'test', x => 50, y => 50);
}



und genau bei der Erstellung von $node kommt die Fehlermeldung aus meinem ersten Post
renee
 2007-11-27 11:09
#103096 #103096
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Wie "Spieler" schon geschrieben hat, ist wohl schon ein Fix auf CPAN. Du solltest also die neue Version von CPAN:Tk::GraphItems installieren...
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/
Gast Gast
 2007-11-27 12:16
#103103 #103103
jupp.. hab grad die Version 0.08 installiert...

allerdings ändert das leider an meinem Fehler nichts.. der tritt nämlich nach wie vor auf... <(-.-)> und das findet der kleine Kirby nun auch nicht mehr lustig
renee
 2007-11-27 12:29
#103104 #103104
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Bekommst Du damit einen Fehler:
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/perl

use strict;
use warnings;
use Tk;
use Tk::GraphItems;

my $oo = { 1 => 'hallo', 2 => 'test', 3 => 'perl' };

my $mw = new MainWindow(-title => "Robot Control GUI", -height => 600, -width => 800);

  my $can = $mw->Canvas(-relief  => "raised", -borderwidth => 2, -width => 225, height => 150)->place(-x => 5, -y => 180); # ==
  foreach (sort keys %{$oo})
  {
     my $node = Tk::GraphItems::TextBox->new(canvas => $can, text => 'test', x => 50, y => 50);
  }

MainLoop;


Welche Version von Tk hast Du?
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/
Gast Gast
 2007-11-27 13:19
#103111 #103111
Hallo Renee,

danke schon mal für den Tip, habs grad ausprobiert, komme aber leider immer noch nicht weiter damit...

Der Fehler ist nach wie vor der gleiche wie bei meinem ersten Post..


Code: (dl )
1
2
3
4
while(1)
{
print "HILFE\n";
}



büdde büdde helfen
renee
 2007-11-27 13:24
#103112 #103112
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Auf meine Fragen musst Du aber schon antworten...
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/
<< |< 1 2 3 >| >> 25 Einträge, 3 Seiten



View all threads created 2007-11-26 16:07.