chrstphrchvz / perl-tcl-ptk Goto Github PK
View Code? Open in Web Editor NEWTcl::pTk - Interface to Tcl/Tk with Perl/Tk compatible syntax
Home Page: https://metacpan.org/pod/Tcl::pTk
License: Other
Tcl::pTk - Interface to Tcl/Tk with Perl/Tk compatible syntax
Home Page: https://metacpan.org/pod/Tcl::pTk
License: Other
Tk Aqua issue 3ceb6b0f65 means that the approach of using a timer event to automatically end the test no longer works on Aqua at least since 8.6.12 (likely since 8.6.11).
Consider finding some other way to programmatically dismiss the message box (and also avoid relying on exit()
due to #14).
Tcl::pTk::widgets is identical to Tk::widgets except for the path used:
perl-tcl-ptk/lib/Tcl/pTk/widgets.pm
Line 40 in 5935188
But there are various widgets which Perl/Tk has .pm files for whereas Tcl::pTk does not, e.g. Label:
use Tcl::pTk::widgets qw/Label/;
↓
Can't locate Tcl/pTk/Label.pm in @INC (you may need to install the Tcl::pTk::Label module)
What should Tcl::pTk do about this?
Posted also here https://core.tcl-lang.org/tk/tktview?name=234ee4f83b since I thought it was a pure Tcl/Tk issue. More experimenting seems to point now to a tcl::pTk issue (but still unsure). I am using 6.9.11 compiled as Frameworks.
The application crashes with Segmentation fault: 11 on macOS (tested on Mojave and bigSur) when pasting text with special characters from any different application (example: La réalisation d’une ouverture). This does not happen if typed directly or copied and pasted from the same Tk application.
In Perl, it can reproduced with the following:
use Tcl::pTk;
$mw = MainWindow->new();
my $int = $mw->interp;
$mw->Scrolled('Text', -width => 40, -height => 10, -wrap => 'char', -bd => '1', -scrollbars => 'e')->pack(-expand => 1, -fill => 'both', -pady => 2, -padx => [2,0]);
$int->MainLoop;
I can not reproduce it a simple Text widget in Wish.
grid [text .myText -background red -foreground white -relief ridge -borderwidth 8 -padx 10
-pady 10 -font {Helvetica -18 bold} -width 20 -height 5]
The incriminated character is this special apostrophe ’
Is it possible to configure the style of the treeview from within Tcl::pTk? In particular, I am trying to configure the header. Since I am missing any syntax example for that, I just started with configuring the entire widget. In the example below, I simply try to change the background of the entire treeview, but it seems that ttkStyleConfigure (documented in Tcl::pTk::Tile) does not produce any effect.
use Tcl::pTk;
my $mw = MainWindow->new();
my $int = $mw->interp;
my $tree = $mw->Scrolled('ttkTreeview',-columns => [qw/ id token/], -show => 'headings', -scrollbars => 'se' )->pack(-fill => 'both', -expand => 1);
$tree -> tagConfigure('title', -background=>'red');
$tree -> tagConfigure('oddrow', -background=>'white');
$tree -> tagConfigure('evenrow', -background=>'yellow');
my $style = $tree->cget(-style);
my $font = $tree->ttkStyleLookup( $style, -font);
$tree->ttkStyleConfigure($style, -background=>'gray'); #trying to mimic Tcl 'ttk::style configure Treeview -background red' Here must lay my problem in TCL->Tcl::pTk conversion...
## Code to insert the data nicely
foreach my $col (qw/ id token/){
my $name = uc($col);
$tree->heading($col, -command => [\&SortBy, $tree->Subwidget('scrolled'), $col, 0], -text => $name);
my $len = $tree->fontMeasure($font, $name);
$tree->column($col, -width, $len+110);
}
$tree->insert('', 'end', -values => ['1234', '5678'], -tags => 'oddrow');
$tree->insert('', 'end', -values => ['abcd', 'efgh'], -tags => 'evenrow');
my $but = $mw->ttkButton(
-text => "Close",
-command => sub {
$mw->destroy;
}
)->pack();
$int->MainLoop;
sub SortBy{
}
1;
Also any idea on how to configure the header?
Various issues (errors, crashes, segmentation faults) are encountered when Perl exit
is called before destroying the main/root window. Examples include:
exit
in callbacks (see https://rt.cpan.org/Ticket/Display.html?id=128654)exit
at the end of a script, as was often done in test scripts which never called MainLoop
(see https://rt.cpan.org/Ticket/Display.html?id=128804)Tcl::Tk appears to be affected by this as well (https://www.perlmonks.org/?node_id=1191134). I do not know whether wrappers can/should support exit
usage, so for now I recommend always destroying the root toplevel before Perl exits (either by entering MainLoop
and waiting for the user to close it, or programmatically using the destroy
method).
(Migrated from https://rt.cpan.org/Ticket/Display.html?id=125390.)
If a program uses Exists
(and possibly other symbols) instead of Tk::Exists
, an error results:
Can't locate object method "Exists" via package "MyPackage" at MyPackage.pm line nnn.
One workaround is to replace Exists
with Tk::Exists
.
I'm not yet sure what causes this. Tcl/pTk.pm does have @EXPORT (@perlTk, …);
where my @perlTk = qw(… Exists …);
, and TkHijack.pm redefines Tk::Exists
to Tcl::pTk::Exists
. And most other bare symbols like MainLoop
seem to work fine.
Is the widget ttk::labelframe (as in https://www.tcl.tk/man/tcl/TkCmd/ttk_labelframe.html) supported by this framework? I can have the LabFrame widget working but not the ttk variant. Thanks
What I do now is a cumbersome way through TCL:
my $int = $mw->interp;
my $labelFramePATH = $int->widget($FrameSettingsView);
my $Widgetname = $labelFramePATH . '.lf01';
$int->Eval("
ttk::labelframe $Widgetname -text INTERFACE -relief ridge -height 100 -width 100
pack $Widgetname -expand true -fill x
");
my $labelFrame = $int->widget($Widgetname);
$ptk_w_names
is only set or appended to. Is it still needed? Something inherited from Tcl::Tk?
http://www.cpantesters.org/cpan/report/12f44dd8-2d60-11ee-aa15-9515f1a78c53, http://www.cpantesters.org/cpan/report/761513dc-2de9-11ee-8cd4-a490f3a78c53,
http://www.cpantesters.org/cpan/report/76bbf0d8-3534-11ee-9d0c-f934c9c02e84 (Perl 5.39.1)
Attempt to call undefined import method with arguments via package "Tk::widgets" (Perhaps you forgot to load the package?) at t/tkFacelift_mega1.t line 19.
BEGIN failed--compilation aborted at t/tkFacelift_mega1.t line 19.
t/tkFacelift_mega1.t ..........
Dubious, test returned 255 (wstat 65280, 0xff00)
No subtests run
…
Attempt to call undefined import method with arguments via package "Tk::widgets" (Perhaps you forgot to load the package?) at t/tkHijack_mega1.t line 19.
BEGIN failed--compilation aborted at t/tkHijack_mega1.t line 19.
t/tkHijack_mega1.t ............
Dubious, test returned 255 (wstat 65280, 0xff00)
No subtests run
…
Test Summary Report
-------------------
…
t/tkFacelift_mega1.t (Wstat: 65280 (exited 255) Tests: 0 Failed: 0)
Non-zero exit status: 255
Parse errors: No plan found in TAP output
t/tkHijack_mega1.t (Wstat: 65280 (exited 255) Tests: 0 Failed: 0)
Non-zero exit status: 255
Parse errors: No plan found in TAP output
…
Result: FAIL
Failed 2/133 test programs. 0/581 subtests failed.
Hi Christoph,
this is a question, not an issue. What are the table widgets that are available through Tcl::pTk besides the old TkTable? I could not find any examples.
Thank you
ROText in Tcl::pTk is erroneously not read-only (https://rt.cpan.org/Ticket/Display.html?id=125420) and is missing bindings which are documented for Perl/Tk's ROText (https://rt.cpan.org/Ticket/Display.html?id=129754).
I have considered replacing the ROText implementation with one resembling that in Tcl::Tk (i.e. using snit from tcllib). But I find myself unable to concentrate or stay motivated long enough to attempt this successfully.
http://www.cpantesters.org/cpan/report/96da1cbf-84f2-1014-a815-814e06f7812f
All tests fail with couldn't connect to display "" at /home/solimanod/.cpan/build/Tcl-pTk-1.11-0/blib/lib/Tcl/pTk.pm line 1206.
If I had to guess what caused this, it could be that Tcl::pTk’s test-for-tk.tcl detected a Tcl/Tk installation which is neither the one used by Tcl.pm (something #19 would avoid) nor encounters the couldn't connect to display
error.
http://www.cpantesters.org/cpan/report/739ee28a-72ed-1014-8029-8b7a14c79095
# Test 1 got: <UNDEF> (t/dndlocal.t at line 104)
# Expected: "Label2" (Unexpected value for dest label)
# t/dndlocal.t line 104 is: ok($destItem, 'Label2', "Unexpected value for dest label");
t/dndlocal.t ..................
Failed 1/1 subtests
I am not aware of how this could happen or what should be done about it.
…which runs before all other tests. Knowing the patchlevel is important in case an issue due to upstream Tcl/Tk is encountered during testing.
https://rt.cpan.org/Ticket/Display.html?id=127772#txn-1821064
Using aqua Tk 8.6.9.1 on macOS 10.14.1, the dropdown list/popup for
BrowseEntry
widgets appears behind the window rather than in front of it. (I don't remember ever trying this on Tk 8.6.8 or earlier.) See attached screenshot.Some workarounds would be to use
ComboBox
orttkBrowseEntry
instead, although I am not completely aware of how they differ fromBrowseEntry
. Without having investigated this much, I'm not sureBrowseEntry
can be completely replaced by either of those in a Perl/Tk compatible manner. For example, existing code might depend onBrowseEntry
's discrete listbox or button widgets. It would be simpler ifBrowseEntry
wasn't something to separately maintain, though.
(Migrated from https://rt.cpan.org/Ticket/Display.html?id=129902)
As used here:
perl-tcl-ptk/lib/Tcl/pTk/Menu/Item.pm
Line 136 in 0e30af8
Not aware of issues due to it missing from Tcl::pTk. Maybe it needs to be copied from Perl/Tk.
The TkDefaultFont is set on Windows in a different (and to me obscure) way in Tcl::pTk. If I run a pure Tcl/Tk application against my Tcl/Tk installation (or I simply start the Wish console), the standard font of the menu is different to the one used by Tcl::pTk (and in my opinion far better).
There is a background problem in widget running on macOS Big Sur. In the following:
use Tcl::pTk;
use Tcl::pTk::ttkTixNoteBook;
my $mw = MainWindow;
my $int = $mw->interp;
my $nb_widget = $mw->ttkTixNoteBook()->pack(-expand=>1, -fill=>'both');
my $nb_page_01= $nb_widget->add("page1", -label=>'PAGE 1',);
my $nb_page_02=$nb_widget->add("page2", -label=>'PAGE 2', );
$int->MainLoop;
the label background of the active tab remains white (instead of blue) and since the label font is white too, the text can not be read. Note that the same issue does NOT occur both in the Dark mode as well in pure Tcl/Tk.
Screenshot: https://ibb.co/sHFCZ8d
Not an issue. More a question. The widgetTclpTk has a ttkTreview example. Where is the info for accessing the functionalities of this widget from Tcl::pTk? For example, how do I get the values of the highlighted row?
Thx
(Migrated from https://rt.cpan.org/Ticket/Display.html?id=131091)
The new focusMethods.t test in Tcl::pTk 1.02 failed completely for most CPAN testers and the Travis CI builder:
http://matrix.cpantesters.org/?dist=Tcl-pTk%201.02
https://travis-ci.com/chrstphrchvz/perl-tcl-ptk/jobs/260772857#L711
However I had not observed/cannot reproduce this failure on any of my own systems, so I will mark this test as TODO in the meantime.
Test output:
t/focusMethods.t .............. 1/7 # Test 1 got: <UNDEF> (t/focusMethods.t at line 26)
# Expected: ".ent02" (initial focus on entry1 failed)
# t/focusMethods.t line 26 is: ok($mw->focusCurrent, $entry1, 'initial focus on entry1 failed');
# Test 2 got: <UNDEF> (t/focusMethods.t at line 30)
# Expected: ".ent03" (focusNext from entry1 to entry2 failed)
# t/focusMethods.t line 30 is: ok($mw->focusCurrent, $entry2, 'focusNext from entry1 to entry2 failed');
# Test 3 got: <UNDEF> (t/focusMethods.t at line 34)
# Expected: ".ent04" (focusNext from entry2 to entry3 failed)
# t/focusMethods.t line 34 is: ok($mw->focusCurrent, $entry3, 'focusNext from entry2 to entry3 failed');
# Test 4 got: <UNDEF> (t/focusMethods.t at line 38)
# Expected: ".ent03" (focusPrev from entry3 to entry2 failed)
# t/focusMethods.t line 38 is: ok($mw->focusCurrent, $entry2, 'focusPrev from entry3 to entry2 failed');
# Test 5 got: <UNDEF> (t/focusMethods.t at line 42)
# Expected: ".ent02" (focusPrev from entry2 to entry1 failed)
# t/focusMethods.t line 42 is: ok($mw->focusCurrent, $entry1, 'focusPrev from entry2 to entry1 failed');
# Test 6 got: <UNDEF> (t/focusMethods.t at line 46)
# Expected: ".ent02" (before focusFollowsMouse: failed to keep focus on entry1 while entering entry3)
# t/focusMethods.t line 46 is: ok(
# Test 7 got: <UNDEF> (t/focusMethods.t at line 56)
# Expected: ".ent04" (after focusFollowsMouse: failed to focus on entry3 by entering)
# t/focusMethods.t line 56 is: ok($mw->focusCurrent, $entry3,
t/focusMethods.t .............. Failed 7/7 subtests
I spot this in the code:
Line 1527 in d0fc699
Should this instead be checking for Tcl::pTk::Widget
? Is this causing any observable issues?
I don't think this was something copied over from Tcl::Tk.
Installation fails with this error:
PERL_DL_NONLAZY=1 "/Users/tk/perl5/perlbrew/perls/perl-5.38.2/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/after.t ..................... ok
t/afterDestroy.t .............. ok
t/afterIdle.t ................. ok
t/balloon.t ................... ok
Balloon should appear over 'Balloon Text' button
t/balloon2.t .................. ok
t/bgerror1.t .................. ok
t/bgerror2.t .................. ok
Error Dialog Should Show. This is expected
t/bgerror3.t .................. ok
t/bind.t ...................... ok
t/bindBreak.t ................. ok
t/bitmapSubClass.t ............ ok
t/browseEntry.t ............... ok
t/browseEntry2.t .............. ok
t/busy.t ...................... ok
t/callback.t .................. ok
t/callbackSet.t ............... ok
t/canFind.t ................... ok
t/canIndex.t .................. ok
t/canScale.t .................. ok
t/canvasFocusBusy.t ........... ok
t/checkradio.t ................ ok
t/cleanupCrashTest.t .......... ok
t/command.t ................... ok
t/configureReturn.t ........... ok
t/dialog.t .................... ok
t/dialogBox.t ................. ok
t/dialogBoxGeom.t ............. ok
t/dirtree.t ................... skipped: Tix Tcl package not available
t/dndlocal.t .................. ok
t/emptyMenuButtonSubclass.t ... ok
t/emptyMenuSubclass.t ......... ok
t/emptySubclass.t ............. ok
t/entry.t ..................... ok
t/entryPaste.t ................ ok
t/entryValidate.t ............. ok
t/fileevent.t ................. ok
t/fileevent2.t ................ ok
t/focusMethods.t .............. ok
t/font.t ...................... ok
t/font2.t ..................... ok
t/fontAttr.t .................. ok
t/frameForeground.t ........... ok
t/geomgr.t .................... ok
t/hlist.t ..................... skipped: Tix Tcl package not available
t/iconimage.t ................. ok
t/imageLoad.t ................. skipped: Tix Tcl package not available
t/itemStyle.t ................. skipped: Tix Tcl package not available
t/labEntry.t .................. ok
t/labEntryFacelift.t .......... ok
t/labEntryParentChild.t ....... ok
t/libLoad.t ................... skipped: Tix Tcl package not available
t/listbox.t ................... ok
objc[82272]: Invalid or prematurely-freed autorelease pool 0x7fe4b70298e0.
t/mainloopMult.t ..............
All 1 subtests passed
t/menub-cascade.t ............. ok
t/menub_newMenu.t ............. ok
t/menubarpath.t ............... ok
t/menuitems.t ................. ok
t/messageBox.t ................ ok
t/moveResizeWindow.t .......... ok
t/moveToplevelWindow.t ........ ok
objc[82280]: Invalid or prematurely-freed autorelease pool 0x7fd7bca117c8.
t/multMainWindow1.t ...........
Failed 2/2 subtests
objc[82281]: Invalid or prematurely-freed autorelease pool 0x7fa60c0ef7c8.
t/multMainWindow2.t ...........
Failed 2/2 subtests
t/notebook.t .................. skipped: Tix Tcl package not available
t/notebook2.t ................. skipped: Tix Tcl package not available
t/onDestroy.t ................. ok
t/optmenu.t ................... ok
t/palette.t ................... ok
t/pane.t ...................... ok
t/patchTk.t ................... skipped: Version of Tk present is not affected
t/photoGetImage.t ............. ok
t/photoImg.t .................. ok
t/photoSubClass.t ............. ok
t/photoTk.t ................... ok
t/progBar.t ................... ok
t/protocol.t .................. ok
t/ptk-compat.t ................ ok
t/ptk-compat2.t ............... ok
t/repeat.t .................... ok
t/repeatSubReuse.t ............ ok
t/rt125058.t .................. ok
t/scrolled.t .................. ok
t/scrolledOptional.t .......... ok
t/selection.t ................. ok
t/slideMegaWidget.t ........... ok
t/slideMegaWidget2.t .......... ok
t/spreadsheetHideRows.t ....... ok
t/table.t ..................... ok
t/tableFacelift.t ............. ok
t/tableMatrixCallbacks.t ...... ok
t/tableMatrixCleanup.t ........ ok
t/tableMatrixDebug.t .......... ok
t/tableMatrixSpreadsheet.t .... ok
t/tclVersion.t ................ ok
t/text.t ...................... ok
t/text2-old.t ................. ok
t/text2.t ..................... ok
t/text3.t ..................... ok
t/textEdit.t .................. ok
t/textRO.t .................... ok
t/textSubwidget.t ............. ok
t/textUndo.t .................. ok
t/tileLabelFont.t ............. ok
t/tileTree.t .................. ok
t/tileWidget.t ................ ok
t/tixTree.t ................... skipped: Tix Tcl package not available
t/tk-mw.t ..................... ok
t/tkFacelift_BEsubclass.t ..... ok
t/tkFacelift_browseEntry.t .... ok
t/tkFacelift_frameSubclass.t .. ok
t/tkFacelift_mega1.t .......... ok
t/tkFacelift_notebook.t ....... ok
t/tkFacelift_simple.t ......... skipped: Tix Tcl package not available
t/tkHijack_BEsubclass.t ....... ok
t/tkHijack_bgerror1.t ......... ok
t/tkHijack_bgerror2.t ......... ok
t/tkHijack_bgerror3.t ......... ok
t/tkHijack_mega1.t ............ ok
t/tkHijack_simple.t ........... skipped: Tix Tcl package not available
t/tkHijack_spreadsheet.t ...... ok
t/trace.t ..................... ok
t/tree.t ...................... skipped: Tix Tcl package not available
t/ttkBrowseEntry.t ............ ok
t/ttkEntryValidate.t .......... ok
t/ttkTixNoteBook.t ............ ok
t/unicode.t ................... ok
t/usewidgets.t ................ ok
t/virtualEv.t ................. ok
t/widgetDelete.t .............. ok
t/widgetMethod.t .............. ok
t/widgetName.t ................ ok
t/wmForget.t .................. ok
t/wmStackorder.t .............. ok
t/xevent.t .................... ok
t/zzPhoto.t ................... ok
Test Summary Report
-------------------
t/focusMethods.t (Wstat: 0 Tests: 7 Failed: 0)
TODO passed: 1-7
t/font.t (Wstat: 0 Tests: 13 Failed: 0)
TODO passed: 11
t/fontAttr.t (Wstat: 0 Tests: 8 Failed: 0)
TODO passed: 1-8
t/mainloopMult.t (Wstat: 6 (Signal: ABRT) Tests: 1 Failed: 0)
Non-zero wait status: 6
t/multMainWindow1.t (Wstat: 6 (Signal: ABRT) Tests: 0 Failed: 0)
Non-zero wait status: 6
Parse errors: Bad plan. You planned 2 tests but ran 0.
t/multMainWindow2.t (Wstat: 6 (Signal: ABRT) Tests: 0 Failed: 0)
Non-zero wait status: 6
Parse errors: Bad plan. You planned 2 tests but ran 0.
t/wmStackorder.t (Wstat: 0 Tests: 10 Failed: 0)
TODO passed: 1-10
Files=134, Tests=618, 220 wallclock secs ( 0.46 usr 0.35 sys + 41.54 cusr 13.86 csys = 56.21 CPU)
Result: FAIL
Failed 3/134 test programs. 0/618 subtests failed.
make: *** [test_dynamic] Error 255
-> FAIL Installing Tcl::pTk failed.
https://rt.cpan.org/Ticket/Display.html?id=129947#txn-1854150
…i.e. the inverse of
PathName
.Is this really not already present? Although I'm not sure how common it is in Perl/Tk programs, there's multiple places internally where
…->Widget($path)
might be more useful instead of duplicating several lines each time to look up something from the widgets hash.
From https://rt.cpan.org/Ticket/Display.html?id=128677:
I noticed that the floor plan canvas demo (floor.pl) is partially broken: typing a valid room number does not cause the room to light up. Hovering over rooms still causes the entry to change though.
I tried experimenting with entry.t and trace.t, and compared behaviors under Perl/Tk and Tcl::pTk to see what might be missing. In Perl/Tk, if the text in an entry widget with a traced textvariable changes (due to the user typing, or programmatically changing it e.g. via
$e1->insert()
), the trace callback is entered and is responsible for updating the textvariable (by returning a value). But in Tcl::pTk, any changes made by the widget from Tcl code or user interaction will directly update the textvariable without entering the callback; the callback is only entered when the textvariable is read or written from Perl code.
A TODO test was added to t/trace.t in 1.08_02 for this issue: 838f409
I am still not sure how this can be addressed. I would think Tcl's trace add variable …
is needed, but also that this approach would require rewriting Tcl::pTk::Trace and Tcl::pTk::Tie::Watch (which seem copied as-is from Perl/Tk).
As previously observed in the menus.pl/menus2.pl demos (see https://rt.cpan.org/Ticket/Display.html?id=125826).
A workaround is to assign an empty string instead (which I think also shows the intention more clearly).
This warning is not emitted under Perl/Tk. I don't know whether Perl/Tk should emit the warning as well (it currently makes almost no use of the warnings pragma), or if Tcl::pTk should not be emitting it (i.e. it should treat assigning undef
the same as assigning an empty string).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.