Thread GUI in Form von Windows Explorer erstellen (15 answers)
Opened by Mampfgnom at 2010-10-27 15:05

Gast Mampfgnom
 2010-11-01 09:44
#142385 #142385
Hallo und danke für die Antworten.

@pktm: Ich habe doch auch ein parent Frame verwendet ($frame_hintergrund), aber trotzdem hat er mir die anderen Frames ganz putzig angeordnet. Mittlerweile habe ich das Problem mit place umgangen. Gefällt mir zwar nicht ganz so gut die Lösung, aber es erfüllt seinen Zweck. Hier mal mein Aktueller Stand in gekürzter Fassung:

Code (perl): (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/perl

use Tk;
use Tk::LabEntry;
use Tk::DirTree;
use Tk::HList;
use Cwd;

my $mw = MainWindow->new(-title=>"PAM_ABA v1.8");                                                                               # MainWindow
my $width = $mw->screenwidth;
my $height = $mw->screenheight;
$mw->geometry($width.'x'.$height);

$mw->configure(-menu => my $menubar = $mw->Menu);                                                                               # Menüleiste
my $materialtyp = $menubar->cascade(-label => '~Materialtyp', -tearoff=>0);
$menubar->command(-command=>\&konvertieren, -label=>"~Konvertieren");
#$menubar->command(-command=>\&verzeichnis, -label=>"~Verzeichnis");
$menubar->command(-command=>sub{exit}, -label=>"~Beenden");

@typ = ("SHE 103", "SOL 24");                                                                                                                                   # Materialtypen
$i=0;
foreach $typ (@typ){
        $i++;
        $materialtyp->radiobutton(-label=>$typ, -variable=>\$rb, -value=>$i, -command=>\&label_anpassen);
}
$rb = 1;

$frame0 = $mw->Frame(-height=>30)->pack(-expand=>1, -fill=>'x', -anchor=>'n');
$cwd = getcwd;
$pfad_mat = getcwd();
$label_typ = $frame0->Label(-text=>"Typ: SHE 103")->place(-x=>0, -y=>0, -relheight=>1);
$entry = $frame0->Entry(-width=>120, -text=>"$pfad_mat")->place(-x=>200, -y=>0, -relwidth=>2/3, -relheight=>1);
$check = $frame0->Checkbutton(-text=>"Materialverzeichnis auswaehlen", -variable=>\$cb_value)->place(-x=>1300, -y=>0, -relheight=>1);
$cb_value = 1;

$frame_hintergrund = $mw->Frame->place(-x=>0, -y=>30, -relheight=>110/113, -relwidth=>1);
$frame1 = $frame_hintergrund->Frame(-width=>int($width/3), -bg=> 'red')
                                        ->place(-x=>0,-y=>0, -relwidth=>1/3, -relheight=>1);
$frame2 = $frame_hintergrund->Frame(-width=>int($width*2/3), -bg=> 'yellow')
                                        ->pack(-expand=>1, -fill=>'y', -side=>'right', -anchor=>'e');
                                        
$DIR_TREE = $frame1->Scrolled('DirTree', -scrollbars => "osoe", -width => 30,
                            -height => 25, -exportselection => 1, -browsecmd => sub {$pfad_mat = shift;&neues_verzeichnis($pfad_mat);},
                            -command   => \&callback)->place(-x=>0, -y=>0, -relwidth=>1, -relheight=>1);

my $hlist = $frame2->Scrolled('HList', -scrollbars=>'oe', -columns=>1,-itemtype   => 'text',-separator=>"/",
                                                                 -selectmode=>'extended', -header=>1, -command=>sub{&doppelklick;}
                                                                )->place(-x=>0, -y=>0, -relwidth=>1, -relheight=>1);
$hlist->header('create',0);
$hlist->header('configure',0,-text=>"PAM CRASH Materialkarte (*.mat) auswaehlen; Mehrfachauswahl moeglich");                                                            

&neues_verzeichnis($pfad_mat);

MainLoop;

sub konvertieren{
        print "\nBlubb" x10;
}

sub callback{
        $entry->configure(-textvariable=>$pfad_mat) if ($cb_value == 1);
}

sub doppelklick{
        my $path = join "\n", $hlist->infoSelection();
   my $pfad_mat = getcwd;
   chdir "$pfad_mat/$path";
   $pfad_mat = getcwd;
   &callback;
   &neues_verzeichnis($pfad_mat);
}

sub neues_verzeichnis{
        opendir(DIR, $_[0]);
        my @inhalt = readdir(DIR);
        closedir DIR;   
        $hlist->deleteAll;      
        foreach (sort(@inhalt)) {
                $hlist->add("$_", -text=>$_);
        }
}

sub label_anpassen{
        $label_typ->configure(-text=>"Typ: $typ[$rb-1]");
}


Könnt ihr ja mal ausprobieren und sagen, ob es bei euch funktioniert.

View full thread GUI in Form von Windows Explorer erstellen