如何在 Perl/Tk 中将参数传递给子例程?
我设计了一份注册表单,在获得所有必要的值后,我将在该表单中单击“提交”按钮。
单击提交按钮时,我想调用一个函数,并将参数传递给该函数。
我已经为此目的编写了代码,但在获取详细信息之前首先调用该函数。(即)在注册表单中获取详细信息后,我需要将这些值传递给一个函数,并且需要验证这些值。
但发生的事情是,在获取详细信息之前,函数被调用。
I have designed one sign-up form,in this form after getting all necessary values I will click submit button.
And while clicking that submit button I want to call one function and I want to pass the arguments to that function.
I have written code for this purpose,but the function is called first before getting the details.(i.e)after getting the details in sign-up form I need to pass these values to one function and I need to validate those values.
But what happened was,before getting the details the function get called.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
卡洛斯的建议是一种方法。另一种方法是在按钮上放置一个命令回调,该按钮从表单中读取值并调用您的函数,也许像这样。
我假设您已将表单的字段绑定到变量
$var1
和$var2
;当然要根据自己的情况进行修改。Carlos's suggestion is one way. Another is to put a command callback on the button that reads the values out of the form and calls your function, perhaps like this.
I'm assuming you've bound the fields of the form to the variables
$var1
and$var2
here; modify to fit your own situation of course.在指定绑定到小部件的代码引用和参数时,您有许多选项:
请参阅 Tk::callbacks POD 了解更多信息。
You have a number of options when specifying a code ref and arguments to a bind to a widget:
See the Tk::callbacks POD for more info.
听起来像是 vwait 问题。检查 Perl/Tk 文档:
通过这种方式,您可以确定您的代码仅在修改等待变量时执行(即单击“提交”按钮时)
希望它有所帮助。
Sounds like a vwait problem. Check in the Perl/Tk documentation for:
In this way you are sure your code is only executed when the wait variable is modified (that's when you click the "submit" button)
Hope it helps.