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

    How do I return / get the values from a dialogbox?

    Scheduled Pinned Locked Moved PYTHON Development
    4 Posts 0 Posters 382 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 15/11/2012 at 07:52, xxxxxxxx wrote:

      How do I return the values from a dialogbox.
      I tried to set the var globaly and edit it but no luck.

      thanks in advance
      kind regards mogh

      import c4d   
      from c4d import gui   
        
      variablebox = 0.4 # unnecessary ???   
            
      GROUP_ID1=1000   
      TEXTBOX=1001   
      BUTTON1=1002   
      BUTTON2=1003   
            
      class ExampleDlg(gui.GeDialog) :   
            
          def CreateLayout(self) :   
              #creat the layout of the dialog   
              self.GroupBegin(GROUP_ID1, c4d.BFH_SCALEFIT, 3, 1)   
              self.AddEditText(TEXTBOX, c4d.BFH_SCALEFIT)   
              self.AddButton(BUTTON1, c4d.BFH_SCALE, name="Start")   
              self.AddButton(BUTTON2, c4d.BFH_SCALE, name="Close")   
              self.GroupEnd()   
              return True   
                
          def InitValues(self) :   
              #initiate the gadgets with values   
              self.SetString(TEXTBOX, "0.1")   
              return True   
                
          def Command(self, id, msg) :   
             #handle user input   
              if id==BUTTON1:               
                  variablebox = self.GetString(TEXTBOX) #here is something wrong <-----   
                  self.Close()   
                     
              elif id==BUTTON2:   
                  self.Close()   
              return True   
            
      dlg = ExampleDlg()   
      dlg.Open(c4d.DLG_TYPE_MODAL, defaultw=500, defaulth=80)   
        
      def main(undo = True) :       
          print variablebox #here is something wrong <-----   
        
      main()
      
      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 15/11/2012 at 08:37, xxxxxxxx wrote:

        Hi,

        To get values from your dialog after it's closed you should declare them as member variables in your dialog's class. 
        Also, there's something inconsistent here: if you want to get a float value it's better to create a float field with AddEditNumberArrows() for example.

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

          Hm what are member variables? can you give an example how to implement them?
          I tried with "return variablebox" and setting the var in the class as a default which seems to work but i cant overwrite it. or returning the newly set variablebox ....

          thanks in advance
          mogh

          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 16/11/2012 at 03:32, xxxxxxxx wrote:

            self.variablebox = self.GetReal(TEXTBOX)
            

            was my mistake ... got it thanks

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