How to rotate Lable. 
Posted: 07 March 2010 11:25 PM   [ Ignore ]
Avatar
Rank
Joined  2010-02-19
Total Posts:  14
New Member

Does anyone has an idea on how to rotate objects such as MTInnerWindow and Lables in pymt using code? I want to rotate object 180 degree and then adding them to the MTWindows. I was lookng at API documentation for PyMT but I couldn’t find anything. Thanks in advance.

 Signature 

The problem with troubleshooting is that trouble shoots back

Profile
 
 
Posted: 08 March 2010 03:20 AM   [ Ignore ]   [ # 1 ]
Avatar
RankRank
Joined  2009-06-09
Total Posts:  231
Jr. Member

From what I recall:
http://paste.pocoo.org/show/186921/

Something like that.

 Signature 

My Blog
PyMT—Create Multitouch Software easily!
Movid—New cross-platform tracker, work in progress!

Profile
 
 
Posted: 10 March 2010 02:30 PM   [ Ignore ]   [ # 2 ]
Avatar
Rank
Joined  2010-02-19
Total Posts:  14
New Member

that idea work just fine. but it seems that same concept to rotate and translate other widget does not work. here is a small example. Is it a bug in the pymt widget? how it is something that I’m doing wrong

from pymt import *

class 
MTContainer(MTScatterWidget):
#class ChartPlotArea(MTRectangularWidget):
    
def __init__(selfwinbgcolor=(.4,.9,.9.8),**kwargs):
        
super(MTContainerself).__init__(**kwargs)
        
#kwargs.setdefault('pos', (0,0))
        
self.rotation 45
        self
.object MTSquare()
        
self.add_widget(self.object)
        
self.20
    def draw
(self):
        for 
j in range(self.i):
            
self.object.draw()
            
self.rotation += (j*2)
            
self.rotation += (j*2)
            
self.translation = (j*3,j*3)
            
self.pos = (j*4j*4)
        
#self.updateView()
        
        #drawRectangle(pos=self.pos, size=self.size)
        
    
def on_draw(self):
        
self.draw()
#

class MTSquare(MTWidget):
        
def __init__(self, **kwargs):
            
super(MTSquareself).__init__(**kwargs)
            
#self.size = self.get_parent_window()
            
self.color = (1.01.01.00.5)
            
        
def draw(self):                                    
            
drawLine((40408040), width=1.0)                    
            
drawLine((80408080), width=1.0)
            
drawLine((80804080), width=1.0)
            
drawLine((40804040), width=1.0)
            
        
def on_draw(self):
            
self.draw()
        

def pymt_plugin_activate(rootctx):
       
    
ctx.MTKinetic()
    
container MTContainer(ctx.c
    
rotation 45.0
    
translation = (0,0), 
    
scale 1.0
    
do_rotation True
    
do_translation True
    
do_scale True,
    
auto_bring_to_front True,
    
scale_min 0.01,
    
pos=(50,50))
    
    
ctx.c.add_widget(container)
    
root.add_widget(ctx.c)

def pymt_plugin_deactivate(rootctx):
    
root.remove_widget(ctx.ui)

if 
__name__ == '__main__':
    
MTWindow()
    
ctx MTContext()
    
pymt_plugin_activate(wctx)
    
runTouchApp()
    
pymt_plugin_deactivate(wctx)

what do you think??? Thanks in advance.

 Signature 

The problem with troubleshooting is that trouble shoots back

Profile
 
 
Posted: 10 March 2010 10:17 PM   [ Ignore ]   [ # 3 ]
Avatar
Rank
Joined  2010-02-19
Total Posts:  14
New Member

This is interesting, when I use MTScatterWidget with rotation, translation, other parameters (e.g

MTScatterWidgetpos=(0,0), sizeroot.sizerotation45translation = (100,100))

, it applied it and you can see the result on the screen. however, I create my widget based on MTScatterWidget it don’t apply it even in the widget creation time. Has anyone been to this situation?

 Signature 

The problem with troubleshooting is that trouble shoots back

Profile
 
 
Posted: 11 March 2010 04:29 AM   [ Ignore ]   [ # 4 ]
Avatar
RankRank
Joined  2008-12-27
Total Posts:  174
Jr. Member

I’ll do a fast reply:

1. if you check documentation http://pymt.txzone.net/docs/api-trunk/api-pymt.ui.widgets.scatter.html, no translation attribute on the object, only rotation / scale.
2.Test this :

from pymt import *
from OpenGL.GL import GL_LINE_LOOP

class MTContainer(MTScatterWidget):
    
def __init__(selfobjbgcolor=(.4,.9,.9.8),**kwargs):
        
super(MTContainerself).__init__(**kwargs)
        
self.obj obj
        self
.add_widget(self.obj)

    
def collide_point(selfxy):
        return 
self.obj.collide_point(*self.to_local(xy))

class 
MTSquare(MTWidget):
        
def __init__(self, **kwargs):
            
super(MTSquareself).__init__(**kwargs)
            
self.color = (1.01.01.00.5)

        
def draw(self):
            
set_color(*self.color)
            
drawRectangle(size=self.sizestyle=GL_LINE_LOOP)


def pymt_plugin_activate(rootctx):
    
ctx.MTKinetic()
    
container MTContainer(obj=MTSquare(), rotation 45.0pos=(50,50))
    
ctx.c.add_widget(container)
    
root.add_widget(ctx.c)

def pymt_plugin_deactivate(rootctx):
    
root.remove_widget(ctx.ui)

if 
__name__ == '__main__':
    
MTWindow()
    
ctx MTContext()
    
pymt_plugin_activate(wctx)
    
runTouchApp()
    
pymt_plugin_deactivate(wctx)

 Signature 

PyMT | Movid

Profile
 
 
Posted: 12 March 2010 05:44 PM   [ Ignore ]   [ # 5 ]
Avatar
Rank
Joined  2010-02-19
Total Posts:  14
New Member

Thanks a lot for your replies. Well, things are clear to me now. I’m acttully working on a show case and I will upload it as soon as I finished. At least, I contribute to this great pymt community. Thanks.

 Signature 

The problem with troubleshooting is that trouble shoots back

Profile