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

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()

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.

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

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