Check out this code:
from pymel.core import * def buttonpress(item, isPressed): print "isPressed value is %s and its type is %s" % (isPressed, type(isPressed)) window = window(h=300, w=300) layout = columnLayout( rowSpacing=5) control = treeView( parent = layout, w=300, h=300, numberOfButtons = 2, pressCommand=(1, buttonpress) ) showWindow( window ) treeView( control, e=True, addItem = ("layer 1", "")) treeView( control, e=True, buttonStyle=("layer 1", 1, "2StateButton"))
The isPressed argument i get from the pressCommand-argument is logically a bool value and indicates, wether that button is pressed or released. While all other UI-arguments deliver the integer-values 0 or 1, this one pressCommand actually gives me the bool as a string “0” or “1”:
isPressed value is 1 and its type is <type 'unicode'>
This is more than bizarre, right? I mean this is obviously a bug (in mel, mayapython or pymel)…? Because the documentation states:
Second argument specifies the callback function to be executed the callback function should take as parameters: - a string for the clicked button’s item - an int for the clicked button’s state
This is quite unhandy (not to say “un-pythonesque”), as you can’t go like:
“1” and “0” are not empty strings, so this is true for both. Has anyone experienced this before?