Giter Site home page Giter Site logo

chrstphrchvz / perl-tcl-ptk Goto Github PK

View Code? Open in Web Editor NEW
8.0 6.0 2.0 1.95 MB

Tcl::pTk - Interface to Tcl/Tk with Perl/Tk compatible syntax

Home Page: https://metacpan.org/pod/Tcl::pTk

License: Other

Perl 99.96% Roff 0.02% Tcl 0.02%
perl tcl-tk tcltk tk

perl-tcl-ptk's People

Contributors

chrstphrchvz avatar drprofesq avatar manwar avatar mohawk2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

manwar vadrer

perl-tcl-ptk's Issues

background color Entry widget 8.6.11

With the latest Tcl/Tk 8.6.11 on macOS (tested Mojave and bigSur) the background color of a Entry widget without focus has a wrong color (gray instead of white). Tcl/Tk code in Wish does not present this issue (see screenshot)

PS: this does not happen with 8.6.10

Screenshot 2021-02-20 at 18 52 26

macOS segmentation fault by pasting "d’une" in Text widget

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 ’

ttk::treeview ttkStyleConfigure

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?

Issues using Perl exit

Various issues (errors, crashes, segmentation faults) are encountered when Perl exit is called before destroying the main/root window. Examples include:

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).

bare `Exists` not working under TkHijack

(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.

Request about support of ttk::labelframe

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);

`Attempt to call undefined import method with arguments via package "Tk::widgets"`

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.

Table widgets accessible with Tcl::pTk

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

macOS aqua: BrowseEntry dropdown appears behind window

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 or ttkBrowseEntry instead, although I am not completely aware of how they differ from BrowseEntry. Without having investigated this much, I'm not sure BrowseEntry can be completely replaced by either of those in a Perl/Tk compatible manner. For example, existing code might depend on BrowseEntry's discrete listbox or button widgets. It would be simpler if BrowseEntry wasn't something to separately maintain, though.

image

TkDefaultFont not set properly (i.e. like Tcl/Tk does)

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).

Tcl::pTk 1

Tcl/Tk 2

wrong label background in ttkTixNoteBook on macOS Big Sur

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

Accessing ttkTreeview

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

focusMethods.t fails

(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 

Test fail on macOS Monterey and Perl 5.38.2

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. 

trace callback not entered when variable accessed from Tcl

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).

warning when setting textvariable to undef

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).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.