class gui():

    def selCon(self):
        print selection

    def create(self):
        inst=gui()
        cmds.button(l="Connect to Selected",command='inst.selCon()')

I keep getting error saying name 'inst' is not defined # dont understand when method is in the same class and when I am making a call clicking the button i get this error message

What kind of button is this? Usually commands are functions, not strings.

following top link i gave you above i did this

cmds.button(l="Connect to Selected",command=self.selCon)

and then I got error saying selCon accepts no 1 argument (2 given) #

so in the selCOn function i made this change

        def selCon(*args):
            print args[0], args[1]

hitting the button gives following
Render.gui object at 0x13EC1910> False

so now it works , I printed args values to see what is passed , I did understood what the first one is but from where does the second one(False)comes from ..

Try
cmds.button(l="Connect to Selected",command='self.selCon')

I wouldn't use l it looks to much like a number 1

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.