I'm trying to create a custom dialog using pythoncard.

My main program looks like this (I'm only testing!):

import wx
from PythonCard import dialog, model
import MyDialog

class MyApp(model.Background):
    def on_initialize(self, event):

The simple Pythoncard dialog looks like this:

from PythonCard import model

class MyDialog(model.CustomDialog):
    def __init__(self, parent, txt=''):
        model.CustomDialog.__init__(self, parent)
        # if some special setup is necessary, do it here 
        # example from samples/dialogs/minimalDialog.py
        # self.components.field1.text = txt

#def myDialog(parent, txt):
def myDialog(parent):
    dlg = MyDialog(parent, txt)
    result = dlg.showModal()
    # stick your results into the result dictionary here
    # example from samples/dialogs/minimalDialog.py
    # result.text = dlg.components.field1.text
    return result

With this resource file:

    'title':'Dialog Template',
    'position':(66, 66),
    'size':(300, 100),
    'components': [

    'position':(10, 35), 

    'position':(100, 35), 

] # end components
} # end CustomDialog

I just don't seem to be able to get past: MyApp object has no attribute 'MyDialog'
I clearly still have not grasped how classes work! Please help.

I do not see connection of your code with other codes you posted, it says in class defination for example

class MyDialog(model.CustomDialog):

Which you are not using, even you mention custom dialog in your title

I have imported MyDialog in the first piece of code and called it. What do I have to do to make it recognised?

What kind of module MyDialog is, you are not using it in your code?

MyDialog is the second and third bits of code. My home-made dialog...

If you have your second box of code saved as module I do not recommend to break the naming rules for good Python style, but name it in lowercase mydialog.

Then you can import it:

import mydialog

and refer the MyDialog class ans mydialog.MyDialog or do

from mydialog import MyDialog

I do not recommend to have function named almost same in module, use descriptive name, usually good idea is to use verb for example build_dialog.

Pythoncard called my custom dialog dialogTemplate so I have amended my first piece of code to change the name back to the original it looks like this:

import wx
from PythonCard import dialog, model
import dialogTemplate

class MyApp(model.Background):
    def on_initialize(self, event):

Everything else is just as Pythoncard created it. The second piece of code is called dialogTemplate.py. Why can I not start MyDialog from MyApp?
MyApp object has no attribute 'MyDialog'

You are telling that MyDialog, which by starting with capital letter hints that is a Class, is defined insided class MyApp, but it is not there in your code. You would not also have no access to instance after creating it as you are not saving the instance in on_initialize method.

OK. I'm lost could you please give code examples?

read the pythoncard doc on child windows, that should work