in reply to Re: Tk causes problems with file paths containing non-Latin-1 chars
in thread Tk causes problems with file paths containing non-Latin-1 chars

As a test, I rewrote my gui test program (see later post) to use Tkx. Surprisingly easy, though I can't find a scrolled text gadget which is a worry. The changed subroutines only below:
... use Tkx; ... sub init_gui { $win = Tkx::widget->new('.'); $win->g_wm_geometry('+500+200'); $win->g_wm_title('Tkx wrapper'); $win->g_wm_minsize(400, 200); $win->g_wm_protocol('WM_DELETE_WINDOW', sub { exit; }); $win->g_wm_resizable(0, 0); my $f1 = $win->new_frame(); my $f2 = $win->new_frame(); $t1 = $f1->new_text(); $t1->g_pack(-anchor=>'e', -fill=>'both'); my $b1 = $f2->new_button(-text=>'Browse...', -width=>10, -command=>\ +&select); $b1->g_pack(-anchor=>'e', -fill=>'both'); $f1->g_grid(-row=>0, -column=>0, -padx=>8, -pady=>4, -sticky=>'n'); $f2->g_grid(-row=>1, -column=>0, -padx=>8, -pady=>4, -sticky=>'n'); return; } ... sub select { my $filename = Tkx::tk___getOpenFile( -defaultextension => '', -initialdir => $path, -title => 'Select file', ); if ($filename) { test_file($filename); } return; } __END__

Result? No improvement. The sub "load" still finds all the files which test and open ok in sub "test_file". Files with extended chars in the path opened under Windows using the sub "select" linked to the button give a "Does not exist" on the -d test of sub "test_file". They open fine under Linux (and presumably OS-X too if I wasn't too lazy to pull the Mac out).

Probably shouldn't be a surprise as I suspect Tk::FBox->getOpenFile and Tkx::tk___getOpenFile are thin wrappers over Tcl which calls the native file dialog which is where I suspect the real encoding problem lies.

So, Tkx is NO CURE for the dreaded extended chars in the file path problem (and I've decided not to like Tkx ;-). Converting would mean more complexity to manage scroll bars manually and probably other things. Only positive is I'd be freed from AS perl 5.8.x which Tk support ties me to.

Update: I've found CPAN Tkx::Scrolled which seems to work fine installed with ActiveState cpan (no ppm). Some differences between Tk and Tkx re scrolling programatically, but I'm liking Tkx a bit better.

  • Comment on Re^2: Tk causes problems with file paths containing non-Latin-1 chars
  • Download Code

Replies are listed 'Best First'.
Re^3: Tk causes problems with file paths containing non-Latin-1 chars
by Anonymous Monk on May 04, 2011 at 02:20 UTC
      Just found Tkx::Scrolled. Installed with ActiveState's cpan under Linux just fine and does the job (docs a bit light on), but I'm having trouble under win32:
      Fetching with LWP: http://ppm.activestate.com/CPAN/modules/02packages.details.txt.gz Alert: While trying to 'parse' YAML file 'D:\Perl\cpan\FTPstats.yml' with 'YAML::XS' the following error was encountered: Usage: YAML::XS::LibYAML::Load(yaml_str) at D:\Perl\lib/YAML/XS.pm l +ine 70.

      Think I've had this before, thou can't recall the fix. If I can fix that, it allows me to recode very similar to Tk.

      use Tkx::Scrolled; ... $t1 = $f1->new_tkx_Scrolled('text', -scrollbars=>'oe', -wrap=>'wor +d', -height=>'12', -width=>100,); ... $t1->insert('end', $txt); $t1->yview('end'); ...
        Windows cpan problem fixed (no nmake on search path).

        Ok, scrolled gadget good in win32, Linux, and probably OS-x. I'm actively thinking of switching over to Tkx, though it still does not address my fundamental problem!