Hello i have extend wxPanel to create a template like this

import wx

class Age(wx.Panel):
    """ Template per gestione Anagrafiche"""
    def __init__(self, parent, id,content,content,size = wx.DefaultSize):
        wx.Panel.__init__(self, parent, id, wx.Point(0, 0), size, wx.SUNKEN_BORDER)
        ## Create the vertical sizer for the toolbar and Panel
        self.box = wx.BoxSizer(wx.VERTICAL)
        tb = _NavigationTool(self)
        self.box.Add(tb,0,wx.ALL | wx.ALIGN_LEFT | wx.EXPAND,4)
        
        self.addcontent(content)

        self.box.Fit(self)
        self.SetAutoLayout(True)
        self.SetSizer(self.box)

    def addcontent(self,content):
        self.box.Add(content,1,wx.EXPAND)
        

class _NavigationTool(wx.ToolBar):
    def __init__(self, parent, *args, **kwargs):
        wx.ToolBar.__init__(self, parent, *args, **kwargs)
        
        #add other code here
        tsize = (16,16)
        self.SetToolBitmapSize(tsize)
        new_bmp =  wx.ArtProvider.GetBitmap(wx.ART_NEW, wx.ART_TOOLBAR, tsize)
        open_bmp = wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN, wx.ART_TOOLBAR, tsize)
        copy_bmp = wx.ArtProvider.GetBitmap(wx.ART_COPY, wx.ART_TOOLBAR, tsize)
        paste_bmp= wx.ArtProvider.GetBitmap(wx.ART_PASTE, wx.ART_TOOLBAR, tsize)

        self.AddLabelTool(10, "New", new_bmp, shortHelp="New", longHelp="Long help for 'New'")
        self.AddLabelTool(20, "Open", open_bmp, shortHelp="Open", longHelp="Long help for 'Open'")
        self.AddSimpleTool(30, copy_bmp, "Copy", "Long help for 'Copy'")
        self.AddSimpleTool(40, paste_bmp, "Paste", "Long help for 'Paste'")

then I have extend this and i make another clas like this

import wx
import Main.View.Template 

class Customer(Main.View.Template.Age):
    def __init__(self, parent,id):
        c= content(self,-1)
        Main.View.Template.Age.__init__(self, parent,id,c)

class content(wx.Panel):
    """ Pannello contente controlli per anagrafica clienti"""
    def __init__(self, parent, id, size = wx.DefaultSize):
        wx.Panel.__init__(self, parent, id, wx.Point(0, 0), size, wx.SUNKEN_BORDER)
        vsizer = wx.BoxSizer(wx.VERTICAL)
        hsizer1 = wx.BoxSizer(wx.HORIZONTAL)
        lbl = wx.StaticText(self, -1 ,"Nome Ditta/Anno")
        txt = wx.TextCtrl(self, -1)
        txt2 = wx.TextCtrl(self, -1)
        btn = wx.Button(self, -1, "&Connetti")
        btn2 = wx.Button(self, -1, "&Disconnetti")
        btn3 = wx.Button(self, -1, "C&alcola")
        btn4 = wx.Button(self, -1, "&Esporta")
        hsizer1.Add(lbl, 1, wx.ALL , 5)
        hsizer1.Add(txt, 2, wx.ALL , 5)
        hsizer1.Add(txt2, 3, wx.ALL ,5)
        hsizer1.Add(btn, 1, wx.ALL , 5)
        hsizer1.Add(btn2, 1, wx.ALL ,5)
        hsizer1.Add(btn3, 1, wx.ALL ,5)
        hsizer1.Add(btn4, 1, wx.ALL ,5)
        vsizer.Add(hsizer1, 1, wx.ALL)

my problem is the content class because i can't pass self to this class imust pass parent but is not corret can somone help me

my problem is the content class because i can't pass self to this class imust pass parent but is not corret can somone help me

Please clarify your question. What's "not correct"

I think these two lines:
c= content(self,-1)
Main.View.Template.Age.__init__(self, parent,id,c)
present a catch22 situation
self comes from line2 and c comes from 1

excuse my all for my bad english
i'think that i can add some parameters on base class

class Age(wx.Panel):
    """ Template per gestione Anagrafiche"""
    def __init__(self, parent, id,content,content,size = wx.DefaultSize):

so now i'll try to create a function inside Age class and call it in __init__ then, i'll can override this function in Customer class
Is correct?

This line of code ...
def __init__(self, parent, id,content,content,size = wx.DefaultSize):
will give an error, since you are passing variable content twice.

Also I would replace 'Main.View.Template' with 'Main_View_Template'.

This line of code ...
def __init__(self, parent, id,content,content,size = wx.DefaultSize):
will give an error, since you are passing variable content twice.

Also I would replace 'Main.View.Template' with 'Main_View_Template'.

Tanks....
I'm very newbie python programmer can you clarify this method or can you give me a link

Make your life easier (less complex) and put all the toolbar stuff into class Age. Similarly put all the content things into class Customer. There is no reason to split those out.

Python will not accept a module saved as Main.View.Template.py, but it will accept MainViewTemplate.py or Main_View_Template.py

Thank you very much!
I need have content in customer class, soon i'll post solution

OK now my Template class is

#!/usr/bin/python
# -*- coding: latin-1 -*-
import wx

class Age(wx.Panel):
    """ Template per gestione Anagrafiche
        agginge con gestione tool bar metodo tool bar da definire"""
    def __init__(self, parent, id,size = wx.DefaultSize):
        wx.Panel.__init__(self, parent, id, wx.Point(0, 0), size, wx.SUNKEN_BORDER)
        ## Create the vertical sizer for the toolbar and Panel
        self.box = wx.BoxSizer(wx.VERTICAL)
        tb = _NavigationTool(self)
        self.box.Add(tb,0,wx.ALL | wx.ALIGN_LEFT | wx.EXPAND,4)
        self.myinit()

        self.box.Fit(self)
        self.SetAutoLayout(True)
        self.SetSizer(self.box)

    def myinit(self):
        pass

    def addcontent(self,content):
        self.box.Add(content,1,wx.EXPAND)

and the customer class is

class Customer(Main.View.Template.Age):
    def __init__(self, parent,id):
        Main.View.Template.Age.__init__(self, parent,id)

    def myinit(self):
        self.main_panel = Content(self, -1)
        self.addcontent(self.main_panel)


class Content(wx.Panel):
    """ Pannello contente controlli per anagrafica clienti"""
    def __init__(self, parent, id, size = wx.DefaultSize):
        wx.Panel.__init__(self, parent, id, wx.Point(0, 0), size, wx.SUNKEN_BORDER)

so myinit def can be override in customer class
Problem solved tanks to all!!!

This article has been dead for over six months. Start a new discussion instead.