how to create a Pop up dialog and link the property to an object I am still really new to Python and I am working through some new things. I would like to create a Pop up dialog box that the user can input some text. I would like to then use that Text for something else, for example changing the Name of the default cube. 

I have read through some posts and I see that creating the pop up dialog box is pretty simple but I am not sure how I can then use the user's defined text for the object name.

Here is what I have so far (which is just the pop up dialog box which works fine) I need to know how I can then use the text that the user inputs into that Dialog box and use it to change the name of the cube.

import bpy

class WM_OT_myop(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "wm.myop"
    bl_label = "Simple Object Operator"

    text = bpy.props.StringProperty(name="Name", default="")

    def execute(self, context):
        bpy.data.objects['Cube'].name = #rename cube to User Input?

        return {'FINISHED'}

    def invoke(self, context, event):
        wm = context.window_manager
        return wm.invoke_props_dialog(self)

def register():
    bpy.utils.register_class(WM_OT_myop)
    bpy.ops.wm.myop('INVOKE_DEFAULT')

def unregister():
    bpy.utils.unregister_class(WM_OT_myop)

if __name__ == "__main__":
    register()


Edit, Thanks to @Matt's explanation I made an addition:

text = self.text


here is the full script: 

import bpy

class WM_OT_myop(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "wm.myop"
    bl_label = "Simple Object Operator"

    text = bpy.props.StringProperty(name="Name", default="")

    def execute(self, context):
        text = self.text
        bpy.data.objects[0].name = text

        return {'FINISHED'}

    def invoke(self, context, event):
        wm = context.window_manager
        return wm.invoke_props_dialog(self)

def register():
    bpy.utils.register_class(WM_OT_myop)    

def unregister():
    bpy.utils.unregister_class(WM_OT_myop)

if __name__ == "__main__":
    register()   
    # test call
    bpy.ops.wm.myop('INVOKE_DEFAULT')
There are a few things to know, some of which are Python specific.

Firstly, text probably won't exist anymore by the time you call execute() because text is merely a local variable, not a class member. To make it a class member, simply declare it as self.text = bpy.props.StringProperty(name="Name", default=""). If you're familiar with C++ or C#, self is almost exactly the same as this.

Secondly, you probably want that declaration in a constructor for that class. The Python constructor is __init__(self) (it has two underscores before 'init' and two underscores after) which you declare the same as any other class method. Put code there that you want to run when an instance of the class is created, just like any other constructor.

Thirdly, I'm assuming that when you call bpy.props.StringProperty(name="Name", default="") it returns the text that gets typed into the dialog. If so, it should be as simple as bpy.data.objects['Cube'].name = self.text