簡體   English   中英

Perl Tkx示例或教程

[英]Perl Tkx examples or tutorials

我一直在嘗試使用Tkx創建Perl GUI,但我遇到了一些問題。

我一直在看這些網站:

http://rainbow.ldeo.columbia.edu/documentation/tkperl/

http://docs.activestate.com/activetcl/8.5/tcl/tk_contents.htm

http://www.tkdocs.com/tutorial/onepage.html

但問題是這些例子似乎對我不起作用。

我想盡可能多地使用面向對象的方法,但是不使用駝鹿(現在),所以我可以了解Perl中對象的工作方式。

編輯: 鏈接到一個很好的oo教程

所以我已經可以創建一個窗口:

sub main
{
    my $mainWindow = Tkx::widget->new(".");
    $mainWindow->g_wm_title("FixViewer");
    $mainWindow->g_wm_minsize(400,500);

    Tkx::MainLoop();
}

如何創建一個框架並在其上放置一個Gridlayout?

有人能夠告訴我如何,或鏈接我一個很好的教程。

謝謝

更新:

use strict;
use warnings;
use Tkx;

sub main
{
    my $mainWindow = Tkx::widget->new(".");
    $mainWindow->g_wm_title("FixViewer");
    $mainWindow->g_wm_minsize(100,100);

    my $contentFrame = $mainWindow->new_ttk__frame(-padding => "3 3 12 12");
    $contentFrame->g_grid(-column => 0, -row => 0, -sticky => "nwes");
    $mainWindow->g_grid_columnconfigure(0, -weight => 1);
    $mainWindow->g_grid_rowconfigure(0, -weight => 1);

    my $input;
    my $output;

    #create a textbox where user can enter input
    my $inputbox = $contentFrame->new_ttk__entry(-width => 7, -textvariable => \$input);
    $inputbox->g_grid(-column => 1, -row => 1, -sticky => "we");

    #create a lable which shows whatever is input in the input box
    my $inputlabel = $contentFrame->new_ttk__label(-textvariable => \$output);
    $inputlabel->g_grid(-column => 1, -row => 2, -sticky => "we");

    #create a button and bind a sub to it
    my $button = $contentFrame->new_ttk__button(-text=> "Click me",-command=> sub {dostuff(\$output,\$input);} );
    $button->g_grid(-column => 1, -row => 3, -sticky => "w");

    #bind return key to method, so method will get called when key is hit
    $mainWindow->g_bind("<Return>",sub {dostuff(\$output,\$input);});

    Tkx::MainLoop;
}

sub dostuff
{
    my $output = shift;
    my $input = shift;
    $$output = $$input;
}

#############
# Call main #
&main();
#############

我設法找出了一些東西。 更多示例或教程鏈接仍然非常受歡迎

 my $contentFrame = $mainWindow->new_ttk__frame(-padding => "3 3 12 12");
    $contentFrame->g_grid(-column => 0, -row => 0, -sticky => "nwes");
    $mainWindow->g_grid_columnconfigure(0, -weight => 1);
    $mainWindow->g_grid_rowconfigure(0, -weight => 1);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM