Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Py4d beginner

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 271 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 19/03/2012 at 12:37, xxxxxxxx wrote:

      I started learning Python about 1 year ago, I'm fimiliar with Pythonsyntax and meanwhile with OOP structures as well.
      Now I'm trying to get deeper into Py4d so these are my first steps.

      I have a very basic problem:

      from c4d import gui

      gui.QuestionDialog("Do you think I am a dialog?")
      if True:
        print ("You are right.\n I am a dialog")
           
      else:
        print ("You are wrong.\n I really am a dialog.")
           
      Basicly this works but its buggy.
      The documentation says the gui.QuestionDialog() pops up a dialog with a "yes" and "no" button and returns ****True if the user answered Yes, otherwise False.
      But in my case I get True either way, at least I get the print from the True value either way. No matter if click "yes" or "no".

      Why? ****

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 19/03/2012 at 12:49, xxxxxxxx wrote:

        Hi kornyclown,

        You need to assign the return-value of the function to a variable and test that variable in the
        if-clause. Checking for if True: will always succeed because True actually is True.

        from c4d import gui  
          
        answer = gui.QuestionDialog("Do you think I am a dialog?")  
        if answer:  
          print ("You are right.\n I am a dialog")    
        else:  
          print ("You are wrong.\n I really am a dialog.")
        

        -Niklas

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 19/03/2012 at 13:31, xxxxxxxx wrote:

          Ah, ok that makes sense, I didn't consider that True is always True. I was thingking a bit too "human".

          Works fine, thanks a lot.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post