首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Perl Tkx示例或教程

Perl Tkx示例或教程
EN

Stack Overflow用户
提问于 2013-05-31 16:34:21
回答 1查看 3.6K关注 0票数 3

我一直在尝试使用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中是如何工作的。

编辑:link to a good oo tutorial

所以我已经可以创建一个窗口了:

代码语言:javascript
复制
sub main
{
    my $mainWindow = Tkx::widget->new(".");
    $mainWindow->g_wm_title("FixViewer");
    $mainWindow->g_wm_minsize(400,500);

    Tkx::MainLoop();
}

如何创建框架并在其上放置Gridlayout?

有没有人能告诉我怎么做,或者把我链接到一个好的教程。

谢谢

更新:

代码语言:javascript
复制
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();
#############

我想办法弄明白了一些事情。更多示例或教程链接仍然非常受欢迎

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-06-04 21:17:39

代码语言:javascript
复制
 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);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16853122

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档