Slider to control changes,debug help

MakeHuman python API, python plugins, etc

Moderator: joepal

Slider to control changes,debug help

Postby shuang0120 » Wed Sep 23, 2015 1:36 am

Now I have run the code for a period of time, but I still have some questions that I can't figure them out. I am new to Python, so I want to get some help from the forum. Thank you in advance!

How and where should I start the debug process about the dragging the slider to control the morphing? I have no idea so I start the process of debug from the makehuman.py. When run the app/human.py, I find some code related with core/events3d.py.

Code: Select all
 gender = min(max(gender, 0.0), 1.0)
        if self.gender == gender:
            return
        self.gender = gender
        self._setGenderVals()
        self.callEvent('onChanging', events3d.HumanEvent(self, 'gender'))


Code: Select all
class HumanEvent(Event):
    def __init__(self, human, change):
        self.human = human
        self.change = change

    def __repr__(self):
        return 'event: %s, %s' % (self.human, self.change)


But I don't understand the link between the two pieces of code. What should I do to track the human.py code to HumanEvent code? Thanks in advance!
shuang0120
 
Posts: 5
Joined: Sun Aug 30, 2015 12:59 am

Re: Slider to control changes,debug help

Postby duststorm » Tue Oct 06, 2015 10:49 am

callEvent() is defined for class EventHandler in core/events3d.py
All event handling gui objects inherit from the EventHandler class (the Widget class inherits from EventHandler)

The mhEvent method, defined on EventHandler is called using a decorator to attach event handling methods to your objects ad-hoc.
This event handler method is then called using callEvent(methodName)
This is the relevant part that calls the method (simplified for readability):
Code: Select all
def callEvent(self, eventType, event):
    method = getattr(self, eventType)
    method(event)
MakeHuman™ developer
User avatar
duststorm
 
Posts: 2569
Joined: Fri Jan 27, 2012 11:57 am
Location: Belgium


Return to Python scripts

Who is online

Users browsing this forum: No registered users and 1 guest