So, here's how I try to display stuff from the database:
package photos_unused; require Exporter; use DBI; use photos_globals; use Tk; use Tk::NoteBook; use Tk::Pane; use Tk::JPEG; use Tk::DragDrop; use Tk::DropSite; use Encode qw(encode decode); use strict; . . . # get the photo properties from the data base eval { ($credit, $caption, $extra_text, $out, $original_file_name, $direc +tory) = $dbh->selectrow_array( "SELECT credit, caption, extra_text, outx, original_file_name, + directory " . "FROM photos " . "WHERE photo_num = $photo_num " . "LIMIT 1"); }; #end of eval block; if ($@) { error_message("Database error: $@\n"); } else { $credit = decode('UTF-8', $credit); $caption = decode('UTF-8', $caption); $extra_text = decode('UTF-8', $extra_text); $out = decode('UTF-8', $out); $tl = $mw->Toplevel(); $tl->geometry('500x400'); $tl->title("Photo " . $photo_num . " Properties"); $tl->Label(-text=>"Original file name: " . $original_file_name . " + Directory: " . $directory)->pack(); $fr1 = $tl->Frame(-pady=>5, -padx=>3); $fr1->Label(-text=>"Credit")->pack(-anchor=>'w'); $txtCredit = $fr1->Text(-height=>5)->pack; $txtCredit->insert('end', $credit); $fr1->pack; $fr2 = $tl->Frame(-pady=>5, -padx=>3); $fr2->Label(-text=>"Caption")->pack(-anchor=>'w'); $txtCaption = $fr2->Text(-height=>5)->pack; $txtCaption->insert('end', $caption); $fr2->pack; $fr3 = $tl->Frame(-pady=>5, -padx=>3); $fr3->Label(-text=>"Extra text")->pack(-anchor=>'w'); $txtExtraText = $fr3->Text(-height=>5)->pack; $txtExtraText->insert('end', $extra_text); $fr3->pack; $fr4 = $tl->Frame(-pady=>5, -padx=>3); $btnCancel = $fr4->Button(-text => "Cancel", -command=> sub{$tl- +>destroy})->pack(-side=>'left', -anchor=>'e'); $btnOK = $fr4->Button(-text => "UPDATE", -command=> [\&update_ph +oto_properties, $tl, $photo_num])->pack(-side=>'right', -anchor=>'w') +; $fr4->pack(-fill=>'x'); }
I'm using Perl 5.8.8 and Perl/Tk 804.028 on Ubuntu.
Apologies for the large chunk of code, but I wanted to make sure that there was enough to show how I was going about this.
Thanks!
--- Marais
In reply to Perl/Tk: utf8 in Text widget? by Marais
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |