Hello,
I wanted to add something else to this but for some reason it didn't work.
Here is what I did: In the MainClass I created a picture and a text then I
used MakeStat on the tag. The result looks like this:
Img={QTk.newImage photo(url:'picb.gif')}
Img2={QTk.newImage photo(url:'newpicb.gif')} % the new picture to replace
the old one
{self.canvas create(image x y image:Img tags:Tag)}
{self.canvas create(text x y text:'Mytext' tags:Tag)}

After passing the StatTag and Img2 to the PicClass I made the picture move
using "move" on the tag.
Here is where it doesn't work, I wanted to change the picture and the text
from within the PicClass using the following:
{self.tag set(image:self.newImg)} % tag contains the StatTag and newImg
contains Img2
{self.tag set(text:'NewText')}

This did not work and neither the picture nor the text changed. When I tried
removing the line "{self.tag set(text:'NewText')}" the picture changed and
obviously the text didn't. How can I make it work?

Thanks


2010/8/27 Khadija EL MAHRSI <[email protected]>

> Hello,
> I adapted the code you gave me to the one I had and it worked like a charm
> (just like you said without MakeStat move doesn't work but when added
> everything works perfectly).
> Thanks a lot I couldn't have done it without your help.
>
> 2010/8/25 Wolfgang Meyer <[email protected]>
>
>> Hi,
>>
>>
>> On Aug 25, 2010 6:13pm, Khadija EL MAHRSI <[email protected]>
>> wrote:
>> > Hello,
>> > do you think that if I create the image in the MainClass and pass its
>> tag to the PicClass as parameter I will be able to use "move"
>> > on this tag and have it move on my main GUI?
>>
>> No, this will not work (I just did a small test.)
>> However, if you wrap the tag as a stationary object, it does work (see
>> attached example).
>>
>> Does the PicClass have a reference back to the MainClass? If yes, you
>> could alternatively create a method in MainClass:
>>
>> meth moveTag(Tag X Y)
>>  {Tag setCoords(X Y)}
>> end
>>
>> This would work because MainClass is stationary object. In this way
>> you could keep all QTk code in MainClass which would be a cleaner
>> design.
>>
>> Cheers,
>>  Wolfgang
>>
>>
>> _________________________________________________________________________________
>> mozart-users mailing list
>> [email protected]
>> http://www.mozart-oz.org/mailman/listinfo/mozart-users
>>
>
>
_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to