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

I know how to fix this, but I'm not about to start hacking Tk as a past-time.

If not you, then who? :)

If any Monk can point me at something that helps, or suggest a different forum where Perl Tk is might get better coverage, I'd sure appreciate it.

See rt://Tk, https://github.com/eserte/perl-tk, http://perltk.org/, https://groups.google.com/group/comp.lang.perl.tk/topics

FWIW, there is a reason ActiveState ditched Tk for Tkx. There is even Tcl::pTk

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

Replies are listed 'Best First'.
Re^2: Tk causes problems with file paths containing non-Latin-1 chars
by ron7 (Beadle) on May 04, 2011 at 01:54 UTC
    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.

        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'); ...
Re^2: Tk causes problems with file paths containing non-Latin-1 chars
by ron7 (Beadle) on May 03, 2011 at 22:36 UTC
    Yes, I know about ActiveState's recommendation to use Tkx in place of Tk (which pins me to 5.8.x forever). AS is still maintaining Tk, recently issuing an update to fix a startup problem on OS-X which required that libraries be installed, even for "compiled" executables.

    I sorta ignored their recommendation because I didn't feel like learning another GUI, plus the fact that my app is 12,504 LOC, spread across 19 modules (only 5 of which use Tk, so maybe it won't be that awful). If you have an opinion of the Tkx learning curve, documentation, and Tk->Tkx migration, I'm all ears...