I understand you. In fact, it's a question so open. What I really
wnated is something about good practices. If we desire to code
something, for example, in WxPython, sources collected in Internet
would show some tendences. Controls usually are created in the
constructor of class and the callbacks are usually in the methods.
Each dialog is represented by a class. Using ";", it's not natural to
use this structure.
The sense of my question is something like that. In the example
folder, we have several examples, but they are so small that it's not
possible to think in an structure.
You told me about the passage of parameters inside the constructor of
IUP elements. It's an intersting idea. Probably, I won't think it
alone. Looking up code made by others, we are able to build a style.
In my case, I came in the Lua's world only to use IUP. So I haven't
assimilated a Lua style.
If someone has more larger example code, I would like to receive it. I
recognise my question is not simple. Let me development something and
put it here for comments.


2012/6/6, Antonio Scuri <[email protected]>:
>   Hi Luciano,
>
>   Sorry, but I don't know how to answer that question. I guess it depends a
> lot on each developer style and needs.
>
>   I've seen so different structures around here that I cannot say which one
> is the most common. :)
>
>   And in fact that remotes to "what's the most common structure for a Lua
> application?"
>
> Best,
> Scuri
>
>> -----Original Message-----
>> From: luciano de souza [mailto:[email protected]]
>> Sent: terça-feira, 5 de junho de 2012 17:13
>> To: [email protected]
>> Subject: Re: [Iup-users] Attaching an action to a button without a closure
>>
>> Antônio,
>>
>> I add a question. I tried to avoid closures, but what  is I tried to avoid
>> precisely
>> the recommended procedure? If I use button1:action, then I can imagine
>> only
>> two situations: or I use closure or IUP controls were declared as a public
>> variables.
>> For this reason, I redo my question: what's the best structure for a IUP
>> program? If it's not possible to say what's the best, then, what's the
>> most
>> common structure for a IUP program?
>>
>>
>> 2012/6/5, luciano de souza <[email protected]>:
>> > Hello all,
>> >
>> > When attatching a function to a button event, I can use
>> > button1:action(). However, in certain circunstances, it's not  good to
>> > do it. See the code bellow:
>> >
>> > require('iuplua')
>> >
>> > function main(title)
>> > local button1, vbox
>> >
>> > button1 = iup.button{title = 'Botão 1'} vbox = iup.vbox{button1}
>> > return iup.dialog{vbox; title = title} end
>> >
>> > function button1_action()
>> > iup.Message('Aviso', 'O botão 1 foi pressionado') end
>> >
>> > dlg = main('Teste')
>> > dlg:show()
>> > iup.MainLoop()
>> >
>> > If I use button1:action, it was necessary to place it inside main
>> > whereas I want to place it outside.
>> >
>> > How to link button1 to the button1_action(?
>> >
>> > One hypothesis could be:
>> >
>> > button1 = iup.button{title = 'Botão 1', action = function () return
>> > button1_action()  end}
>> >
>> > It works, but this choice is low readable. I tried:
>> >
>> > function main(title)
>> > local button1, vbox
>> >
>> > button1 = iup.button{title = 'Botão 1'} iup.SetAttribute(button1,
>> > 'ACTION', 'button1_action') vbox = iup.vbox{button1} return
>> > iup.dialog{vbox; title = title} end Actually, I want to use
>> > iup.SetAttribute to link events. I could place my callback without
>> > closures and without action = function()..
>> >
>> > Why didn't iup.SetAttribute work?
>> >
>> > Regards,
>> >
>> > Luciano
>> >
>>
>> ------------------------------------------------------------------------------
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and threat
>> landscape has changed and how IT managers can respond. Discussions will
>> include endpoint security, mobile security and the latest in malware
>> threats.
>> http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>> _______________________________________________
>> Iup-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/iup-users
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Iup-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/iup-users
>

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Iup-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/iup-users

Reply via email to