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

    Can't Close Modal Dialogs

    Scheduled Pinned Locked Moved PYTHON Development
    10 Posts 0 Posters 1.1k 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 21/07/2011 at 08:59, xxxxxxxx wrote:

      Hi,

      I recently heard from a Mac user that they don't get an X in their dialog window. So they can't close a modal dialog executed from a script.
      Because of that. I tried to add a close button for them. But it appears that Close() is not supported in modal dialogs(in any language).
      And the built-in buttons:self.AddDlgGroup() appear to not be supported in Python.

      Here's a simple example:

      import c4d  
      from c4d import gui  
        
      GROUP1 = 2000  
      BUTTON1= 1002  
        
      class MyDlg(gui.GeDialog) :   
        
        def CreateLayout(self) :  
            
          self.SetTitle("Modal Dialog")  
            
          self.GroupBegin(GROUP1, c4d.BFH_SCALEFIT, 1, 1)   
          self.GroupBorderNoTitle(c4d.BORDER_GROUP_OUT)  
          self.GroupBorderSpace(left = 2, top=2, right=2, bottom=2)  
          self.AddButton(BUTTON1, c4d.BFH_SCALE, name="Close")  
          self.AddDlgGroup(c4d.DR_DLGGROUP_OK) #Error: 'MyDlg' object has no attribute 'AddDlgGroup'   
          self.AddDlgGroup(c4d.DLG_OK)         #Error: 'MyDlg' object has no attribute 'AddDlgGroup'    
          self.GroupEnd()        
          return True  
        
        def Command(self, id, msg) :   
        
        if id==BUTTON1: c4d.Close()  #Error: module object has no attribute 'Close'      
        
      dlg = MyDlg()  
      dlg.Open(c4d.DLG_TYPE_MODAL, defaultw=200, defaulth=100)
      

      Question#1 : Why is there no X in Mac user's modal dialog window?
      Question#2:  How can I close a modal dialog with a button?

      -ScottA

      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 21/07/2011 at 09:21, xxxxxxxx wrote:

            def Command(self, id, msg) :   
            
            
                    if id==BUTTON1: **self**.Close()
        
         You want to close the dialog, not c4d.  
          
        Why do you expect an attribute "AddDlgGroup" ?  
          
        Cheers,  
        
        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 21/07/2011 at 10:20, xxxxxxxx wrote:

          Close() does not close C4D.
          It's a built in function in the GeModalDialog class.

          Here the same example. But using Coffee:

          var GROUP1 = 2000;  
          var BUTTON1=1002;  
            
          class MyDlg:GeModalDialog   
          {  
          public:  
            CreateLayout();  
            Command(id,msg);  
          };  
            
          MyDlg::CreateLayout()  
          {  
          AddGroupBeginV(GROUP1, BFH_SCALEFIT, 1,"", 1);  
          AddDlgGroup(DR_DLGGROUP_OK);  
          AddGroupEnd();        
          }  
            
          MyDlg::Command(id,msg)  
          {  
            if(id==BUTTON1) Close();  
          }  
          main(doc,op)  
          {  
            var d = new(MyDlg);                    
            d->Open(-1,-1);  
            var result = d->GetResult();  
            if(result==FALSE) return;  
          }
          

          Clicking the button closes the dialog just fine and dandy with Coffee.
          But since AddDlgGroup() is apparently not supported by Python(did Sebastian miss it?) There's no way that I can find to close a modal dialog with a button.
          And since Mac users don't get that X in their dialog menu(Why is that?) the only way for them to close a modal dialog is to press the escape key(ouch!).

          -ScottA

          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 21/07/2011 at 10:26, xxxxxxxx wrote:

            Close() does not close C4D.
            It's a built in function in the GeModalDialog class.

            Yea, I know. But you called c4d.Close() and I wanted to make a tiny joke of it because it look like you wanted to close C4d.
            Anyway, you must call the Dialogs Close() method. The c4d module does not have a Close() attribute, and if there was one, it wouldn't make sense if it would close a dialog, and not c4d.
            See my above codesnippet for the correct use.

            I can't help you with your other questions here, I'm on a PC and I did not write the C++ API Wrapper for Python. Tongue

            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 21/07/2011 at 10:46, xxxxxxxx wrote:

              Oh. Sorry about that.
              I didn't notice the way you used "self" in your example.

              That works.👍
              I'm still trying to wrap my head around the whole "self" thing. I'm not used to using that. And in Python it's used a LOT. It's something I have to get a better grip on.

              Thanks for the help.🍺

              -ScottA

              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 21/07/2011 at 11:03, xxxxxxxx wrote:

                Np. 🙂
                It's not hard. You know the this keyword in C++, right ? self is in this case exactly the same. But in Pyhton you *have* to call methods & attributes using "this".

                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 21/07/2011 at 12:55, xxxxxxxx wrote:

                  I have the same trouble with the "this" keyword in C++.
                  I know what they do. But because I don't use them very often I sometimes goof them up.
                  I just need to use them more often to get a better handle on them.

                  It seems that AddDLGGroup() is missing from Python.
                  It should either be added. Or they should make a note that it's not supported in the SDK. So nobody else goes through the same problem trying to get it to work.

                  -ScottA

                  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 29/02/2012 at 10:56, xxxxxxxx wrote:

                    Hi all just been going thro the code above it works ok for me till i click the close button then get the error message below any ideal why the bool is giveing none.
                     
                    def Command(self, id, msg) :#<------------error bool is exspected not none.
                     
                     
                    cheers Ray.

                    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 29/02/2012 at 12:09, xxxxxxxx wrote:

                      Hello Ray,

                      well.. returning a boolean value would be the solution then, wouldn't it? I'd recommend you to read a bit about Python.

                      def Command(self, id, msg) :  
                        # ...  
                        return True
                      

                      As the documentation say, returning False would notify Cinema 4D that something did not go the correct way. (However, I haven't noticed that will change any behaviour, yet ..)

                      -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 29/02/2012 at 13:59, xxxxxxxx wrote:

                        Ok ive stoped the error message ive put a 
                             return True   
                        statment after the 
                            if id==BUTTON1: c4d.Close()    
                        statement thanks Niklas.
                         
                         Cheers.  Ray.

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