|< 1 2 >| | 20 Einträge, 2 Seiten |
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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
#!/usr/bin/perl -w use Tk; use strict; use warnings; use Tk::Pane; use Tk::Dialog; #use TK::Font; use IPC::SysV qw(IPC_PRIVATE IPC_RMID S_IRWXU); # Globalvariablen # my $top; my $labeltext = "Guten Morgen"; my ($max_width,$max_height); my $topscrollbar; my $status = 'Status AUS'; my $id=0; my $AnzahlVar; my $mpi; my $mpiadr; my $mpitext = 'MPI-Adresse'; my @format; my @istwert; my @mem; my $textblink=0; my $idafter; my $status_Button; #-------------------------------------------------------------------------------------------------------# $top = new MainWindow; $top->geometry("630x300+100+20"); $top->protocol('WM_DELETE_WINDOW', \&ExitApplication); $top->title ("Variableneditor"); my $menframe = $top->Frame()->pack(-side => "top", -fill => "y", -expand => 0,); $top->resizable(0,0); \$status ,-command => [\&status_ein_aus])-> pack(-side => 'left'); my $bezframe =$top->Frame(-borderwidth => 5)-> pack(-fill=> 'both', -anchor => 'nw'); my $frame = $top->Scrolled('Pane', -scrollbars => 'oe'); $frame->Frame(); $frame->pack(-side => 'top', -fill=> 'both', -expand => '1', -anchor => 'nw'); my $toplevel = $top->toplevel; # get $TOP's Toplevel widget reference my $menubar = $toplevel->Menu(-type => 'menubar'); $toplevel->configure(-menu => $menubar); my $f = $menubar->Cascade(qw/-label ~Datei -tearoff 0 -menuitems/ => [ [Button => 'oeffnen ...', -command => [\&oeffnen, 'oeffnen'],-image => $toplevel->Getimage("openfile"),-compound=> "left"], [Separator => ''], [Separator => ''], [Button => 'beenden', -command => [\&ExitApplication,'beenden']], ] ); MainLoop; # ---------------------------------------------------------------------------------------------------------------------------------------------------# sub oeffnen { my $filename; my $filetypes = [ ['template-Datei', ['template*'] ] ]; my @name; my @nummer; my $i=0; my $x=0; my $zeile=2; my @fileinhalt; my $uName; my $uNummer; my $uMem; my $uFormat; my $uIstwert; my @formatart = ('DEZIMAL','REAL', 'HEX', 'BIN', 'ASCII'); my @memart = ('DWORD','DINTEGER','WORD','INTEGER','BYTE'); my $bgcolor = 0; if ($status_Button == undef) { $status_Button = $menframe-> Button (-textvariable => \$status ,-command => [\&status_ein_aus])-> pack(-side => 'left'); $mpiadr = $menframe->Label(-textvariable => \$mpitext,-width=> 30, -font => $top->Font(-family => 'Verdana',-size => 16, -weight => 'bold', -underline => 0), )-> pack(-side => 'left'); } $filename = $toplevel->getOpenFile(-defaultextension => '',-filetypes => $filetypes,-title => 'oeffnen template-dateien...'); $_ = $filename; /_(\d{1,3})$/; $mpi = $1; open(DATEI, '<', $filename) or die "Datei kann nicht geoeffnet werden: $!\n"; @fileinhalt = <DATEI>; foreach (@fileinhalt) { chomp; if ($bgcolor eq 'white') { $bgcolor = 'lightgray'; } else { $bgcolor = 'white'; } $name[$i] = $frame->Label( -text => $_, -relief => 'sunken', -width => '12', -bg => $bgcolor, -borderwidth => '1', -anchor => 'e', -padx => '2', -pady => '2', -font => $top->Font(-family => 'Verdana',-size => 12, -weight => 'bold'), )->grid(-row=>$zeile, -column=>0, -padx => '2',); $nummer[$i] = $frame->Label(-text => $i, -relief => 'sunken', -width => '5', -bg => $bgcolor, -borderwidth => '1', -padx => '2', -pady => '2', -font => $top->Font(-family => 'Verdana',-size => 12, -weight => 'bold'), )->grid(-row=>$zeile, -column=>1, -padx => '2'); $mem[$i] = $frame->BrowseEntry(-relief => 'sunken', -command => [\&tausche_mem,$i], -width => '10', -bg => $bgcolor, -font => $top->Font(-family => 'Verdana',-size => 14,), )->grid(-row=>$zeile, -column=>2, -padx => '2'); $format[$i] = $frame->BrowseEntry(-relief => 'sunken', -command => [\&tausche_format,$i], -width => '9', -bg => $bgcolor, -font => $top->Font(-family => 'Verdana',-size => 14,), )->grid(-row=>$zeile, -column=>3, -padx => '2'); foreach (@memart) {$mem[$i]->insert('end', $_,);} $mem[$i]->{MY_VAR} = $memart[0]; $mem[$i]->configure(-variable => \$mem[$i]->{MY_VAR}); foreach (@formatart) {$format[$i]->insert('end', $_,);} $format[$i]->{MY_VAR} = $formatart[0]; $format[$i]->configure(-variable => \$format[$i]->{MY_VAR}); $istwert[$i] = $frame->Label(-text => '....', -relief => 'ridge', -borderwidth => '1', -width=> 20, -bg => $bgcolor, -anchor => 'w', -padx => '2', -pady => '2', -font => $top->Font(-family => 'Verdana',-size => 12, -weight => 'bold'), )->grid(-row=>$zeile, -column=>4, -padx => '2'); $zeile++; $i++; } $AnzahlVar = $i; $uName = $bezframe->Label(-text => 'Name', -width=> 4, -font => $top->Font(-family => 'Verdana',-size => 14, -weight => 'bold',-underline => 1), )->grid(-row=>1, -column=>0); $uNummer = $bezframe->Label(-text => 'Nr', -width=> 5, -font => $top->Font(-family => 'Verdana',-size => 14, -weight => 'bold',-underline => 1), )->grid(-row=>1, -column=>1); $uMem = $bezframe->Label(-text => 'Speicher', -width=> 10, -anchor => 'w', -font => $top->Font(-family => 'Verdana',-size => 14, -weight => 'bold',-underline => 1), )->grid(-row=>1, -column=>2); $uFormat = $bezframe->Label(-text => 'Format', -width=> 9, -anchor => 'w', -font => $top->Font(-family => 'Verdana',-size => 14, -weight => 'bold',-underline => 1), )->grid(-row=>1, -column=>3); $uIstwert = $bezframe->Label(-text => 'Istwert', -width=> 20, -anchor => 'w', -font => $top->Font(-family => 'Verdana',-size => 14, -weight => 'bold',-underline => 1), )->grid(-row=>1, -column=>4); $mpitext= 'MPI-Adresse: '.$mpi; $mpiadr-> update; }
ptk+2007-08-26 12:06:56--Kannst du den Code noch einmal einstellen, da die Zeile 42 kaputt ausschaut? Und nimm diesmal lieber die CODE- statt PERL-Tags, da das Forum leider noch immer Zeilennummern erzeugt und damit die Verwendung von Copy'n'Paste erschwert.
|< 1 2 >| | 20 Einträge, 2 Seiten |