热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

了解POE-Tk中的名称空间-UnderstandingnamespacesinPOE-Tk

IpostedHowtoundersandthePOE-Tkuseofdestroy?inanattempttoreducethebuginmyproduc

I posted "How to undersand the POE-Tk use of destroy?" in an attempt to reduce the bug in my production code to a test case. But it seems that the solution to the test case is not working in the full program.

我发布了“如何低估POE-Tk使用destroy?”试图将我的生产代码中的错误减少到测试用例。但似乎测试用例的解决方案并不适用于整个程序。

The program is 800+ lines long so I am hesitant to post it in full. I realize that the snippets I provide here may be too short to be of any use, but I hope to get some direction in either where to look for a solution or what additional information I can provide.

该计划长达800多行,所以我犹豫是否完整发布。我意识到我在这里提供的片段可能太短而无法使用,但我希望在寻找解决方案的地方或我可以提供的其他信息方面找到一些方向。

Here is the Session::Create section of my POE-Tk app.

这是我的POE-Tk应用程序的Session :: Create部分。


POE::Session->create(
    inline_states => {
        _start      => \&ui_start,
        get_zOne=> \&get_zone,
        ping        => \&ping,
        mk_disable  => \&mk_disable,
        mk_active   => \&mk_active,
        pop_up_add => \&pop_up_add,
        add_button_press => sub {
            my ($kernel, $session, $heap) = @_[KERNEL, SESSION, HEAP];
            print "\nadd button pressed\n\n";
            &validate;
        },
        ih_button_1_press => sub {
            my ($kernel, $session, $heap) = @_[KERNEL, SESSION, HEAP];
            print "\nih_button_1 pressed\n\n";
            if( Tk::Exists($heap->{ih_mw}) ) {
                print "\n\nih_mw exists in ih_button_1_press\n\n";
            } else {
                print "\n\nih_mw does not exist in ih_button_1_press\n\n";
            }
            1;
            $heap->{ih_mw}->destroy if Tk::Exists($heap->{ih_mw});
            &auth;
        },
        pop_up_del => \&pop_up_del,
        auth        => \&auth,
#       validate    => \&validate,
        auth_routine => \&auth_routine,
        raise_widget    => \&raise_widget,
        del_action  => \&del_action,
        over        => sub { exit; }
    }
);

add_button_press is called here;

这里调用add_button_press;


sub pop_up_add {
    ...
    my $add_but_2 = $add_frm_2->Button( 
        -text => "Add Record",
        -command => $session->postback("add_button_press"),
        -fOnt=> "{Arial} 12 {bold}") -> pack(
            -anchor => 'c',
            -pady => 6,
        );
    ...
}

validate creates the Toplevel widget $heap->{ih_mw};

validate创建Toplevel小部件$ heap - > {ih_mw};


sub validate {
    ...
    if( ! $valid ) {
        print "\n! valid entered\n\n";
        $heap->{label_text} .= "Add record anyway?";
        my $lt_ref = \$heap->{label_text};
    ...
        my $heap->{ih_mw} = $heap->{add_mw}->Toplevel( -title => "ih_mw");
    ... 
        if( Tk::Exists($heap->{ih_mw}) ) {
            print "\n\nih_mw exists in validate\n\n";
        } else {
            print "\n\nih_mw does not exist in validate\n\n";
        }
    ...
        my $ih_but1 = $heap->{ih_mw}->Button( -text => "Add",
            -fOnt=> 'vfont',
            -command => $session->postback("ih_button_1_press"),
            )->pack( -pady => 5 );
    ...
}

Pressing $ih_but1 results in this;

按$ ih_but1会导致此结果;

C:\scripts\alias\resource>alias_poe_V-3_0_par.pl

add button pressed

添加按钮按下

sub validate called

子验证叫

! valid entered

!有效输入

ih_mw exists in validate

ih_mw存在于验证中

ih_button_1 pressed

ih_mw does not exist in ih_button_1_press

在ih_button_1_press中不存在ih_mw

So the $heap->{ih_mw} widget seems to be unkown to the ih_button_1_press anonymous subroutine even with the inclusion of "($kernel, $session, $heap) = @_[KERNEL, SESSION, HEAP];"

因此,即使包含“($ kernel,$ session,$ heap)= @_ [KERNEL,SESSION,HEAP]”,$ heap - > {ih_mw}小部件似乎也不知道ih_button_1_press匿名子例程;“

1 个解决方案

#1


Where does $heap in &validate come from? You don't pass it as a parameter. Could $heap in &validate and $heap in &in_button_1_press not be the same thing? Have you tried printing the stringy form of $heap to see if the addresses are the same in the two functions?

$ heap in&validate来自哪里?您不将其作为参数传递。 $ heap in&validate和$ heap in&in_button_1_press可能不是一回事吗?您是否尝试打印$ heap的字符串形式以查看两个函数中的地址是否相同?


推荐阅读
  • 拥抱Android Design Support Library新变化(导航视图、悬浮ActionBar)
    转载请注明明桑AndroidAndroid5.0Loollipop作为Android最重要的版本之一,为我们带来了全新的界面风格和设计语言。看起来很受欢迎࿰ ... [详细]
  • android listview OnItemClickListener失效原因
    最近在做listview时发现OnItemClickListener失效的问题,经过查找发现是因为button的原因。不仅listitem中存在button会影响OnItemClickListener事件的失效,还会导致单击后listview每个item的背景改变,使得item中的所有有关焦点的事件都失效。本文给出了一个范例来说明这种情况,并提供了解决方法。 ... [详细]
  • JavaScript和HTML之间的交互是经由过程事宜完成的。事宜:文档或浏览器窗口中发作的一些特定的交互霎时。能够运用侦听器(或处置惩罚递次来预订事宜),以便事宜发作时实行相应的 ... [详细]
  • 本文由编程笔记#小编为大家整理,主要介绍了logistic回归(线性和非线性)相关的知识,包括线性logistic回归的代码和数据集的分布情况。希望对你有一定的参考价值。 ... [详细]
  • 生成式对抗网络模型综述摘要生成式对抗网络模型(GAN)是基于深度学习的一种强大的生成模型,可以应用于计算机视觉、自然语言处理、半监督学习等重要领域。生成式对抗网络 ... [详细]
  • 在Android开发中,使用Picasso库可以实现对网络图片的等比例缩放。本文介绍了使用Picasso库进行图片缩放的方法,并提供了具体的代码实现。通过获取图片的宽高,计算目标宽度和高度,并创建新图实现等比例缩放。 ... [详细]
  • Linux重启网络命令实例及关机和重启示例教程
    本文介绍了Linux系统中重启网络命令的实例,以及使用不同方式关机和重启系统的示例教程。包括使用图形界面和控制台访问系统的方法,以及使用shutdown命令进行系统关机和重启的句法和用法。 ... [详细]
  • 开发笔记:加密&json&StringIO模块&BytesIO模块
    篇首语:本文由编程笔记#小编为大家整理,主要介绍了加密&json&StringIO模块&BytesIO模块相关的知识,希望对你有一定的参考价值。一、加密加密 ... [详细]
  • 目录实现效果:实现环境实现方法一:基本思路主要代码JavaScript代码总结方法二主要代码总结方法三基本思路主要代码JavaScriptHTML总结实 ... [详细]
  • CSS3选择器的使用方法详解,提高Web开发效率和精准度
    本文详细介绍了CSS3新增的选择器方法,包括属性选择器的使用。通过CSS3选择器,可以提高Web开发的效率和精准度,使得查找元素更加方便和快捷。同时,本文还对属性选择器的各种用法进行了详细解释,并给出了相应的代码示例。通过学习本文,读者可以更好地掌握CSS3选择器的使用方法,提升自己的Web开发能力。 ... [详细]
  • 1.点击查看隐藏当前按钮和这个内容,显示另一个内容能。 ... [详细]
  • Voicewo在线语音识别转换jQuery插件的特点和示例
    本文介绍了一款名为Voicewo的在线语音识别转换jQuery插件,该插件具有快速、架构、风格、扩展和兼容等特点,适合在互联网应用中使用。同时还提供了一个快速示例供开发人员参考。 ... [详细]
  • 在Xamarin XAML语言中如何在页面级别构建ControlTemplate控件模板
    本文介绍了在Xamarin XAML语言中如何在页面级别构建ControlTemplate控件模板的方法和步骤,包括将ResourceDictionary添加到页面中以及在ResourceDictionary中实现模板的构建。通过本文的阅读,读者可以了解到在Xamarin XAML语言中构建控件模板的具体操作步骤和语法形式。 ... [详细]
  • FineReport平台数据分析图表显示部分系列接口的应用场景和实现思路
    本文介绍了FineReport平台数据分析图表显示部分系列接口的应用场景和实现思路。当图表系列较多时,用户希望可以自己设置哪些系列显示,哪些系列不显示。通过调用FR.Chart.WebUtils.getChart("chartID").getChartWithIndex(chartIndex).setSeriesVisible()接口,可以获取需要显示的系列图表对象,并在表单中显示这些系列。本文以决策报表为例,详细介绍了实现方法,并给出了示例。 ... [详细]
  • JS实现一键分享功能
    本文介绍了如何使用JS实现一键分享功能,并提供了2019独角兽企业招聘Python工程师的标准。同时,给出了分享到QQ空间、新浪微博和人人网的链接。 ... [详细]
author-avatar
so-sweet天地
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有