Hi,
Here is my code.

# class DefaultTamplate

import wx
import Image

BUFFERED = 1

class FourByTwo(wx.Window):
    def __init__(self, parent, id=-1, image="JPEGImage", size=wx.DefaultSize):
        wx.Window.__init__(self, parent, id, image, size=size)

        self.SetBackgroundColour("white")
        self.W = 384
        self.H = 272

        self.photo = image # wx.Image("Test.jpg", wx.BITMAP_TYPE_JPEG)
        self.FrameSize = 96

        self.SetVirtualSize((self.W, self.H))

        if BUFFERED:
            self._Buffer = wx.EmptyBitmap(self.W, self.H)
            dc = wx.BufferedDC(None, self._Buffer)
            dc.SetBackground(wx.Brush(self.GetBackgroundColour()))
            dc.Clear()
            self.DoFraming(dc)

        self.Bind(wx.EVT_PAINT, self.onPaint)

    def onPaint(self, event):
        if BUFFERED:
            dc = wx.BufferedPaintDC(self, self._Buffer, wx.BUFFER_VIRTUAL_AREA)
        else:
            dc = wx.PaintDC(self)
            self.PrepareDC(dc)
            self.DoFraming(dc)

    def DoFraming(self, dc, printing=False):
        dc.BeginDrawing()

        self.LoadPhoto(dc)
        
        dc.SetPen(wx.Pen('WHITE'))
        dc.DrawRectangle(0,0,96,136)

        if not printing:
            pass

        dc.EndDrawing()

    def LoadPhoto(self, dc):
        W = self.photo.GetWidth()
        H = self.photo.GetHeight()
        NewH = self.FrameSize * H / W

        photo1 = self.photo.Scale(self.FrameSize, NewH)

        height  = photo1.GetHeight()/2
        frame_height = 68-height
        
        bitmap = wx.BitmapFromImage(photo1)
        dc.DrawBitmap(bitmap,0,frame_height, True)

class DefaultTamplate(wx.Dialog):
    def __init__(self, parent, image="JPEGImage", size=wx.DefaultSize):
        wx.Dialog.__init__(self, None, -1, "Test", image, size=(500,410))

        self.image = image

        self_v  = wx.BoxSizer(wx.VERTICAL)
        sizer_v = wx.BoxSizer(wx.VERTICAL)
        main2_h = wx.BoxSizer(wx.HORIZONTAL)
        main2_v  = wx.BoxSizer(wx.VERTICAL)
        button_v  = wx.BoxSizer(wx.VERTICAL)

        self.mainPanel = wx.Panel(self, -1, pos=(50,50), style=wx.SIMPLE_BORDER)
        self.mainPanel2 = wx.Panel(self.mainPanel, -1, pos=(50,50), style=wx.NO_BORDER)

        self.Tamplate1 = FourByTwo(self.mainPanel, -1, self.image,size=(384, 272))

        self.button = wx.Button(self.mainPanel2, 1, "OK")
        self.Bind(wx.EVT_BUTTON, self.onOK, self.button)

        sizer_v.Add(self.Tamplate1, 0, wx.ALL | wx.CENTER, 10)
        sizer_v.Add(self.mainPanel2, 0, wx.ALL | wx.CENTER | wx.EXPAND, 10)

        main2_v.Add(self.button, 1, wx.ALL | wx.CENTER  | wx.RIGHT, 10)

        self_v.Add(self.mainPanel, 0, wx.ALL | wx.CENTER | wx.EXPAND, 10)

        self.mainPanel2.SetSizer(main2_v)
        self.mainPanel.SetSizer(sizer_v)

        self.SetSizer(self_v)

    def onOK(self, event):
        self.Destroy()
        
class Main(wx.App):
    def OnInit(self):
        self.SetBackgroundColour(wx.Colour(236,233,216))
        wx.Image("Test.jpg,", wx.BITMAP_TYPE_JPEG)
        frame = DefaultTamplate(self, image)
        frame.CenterOnScreen()
        frame.Show(True)

        self.SetTopWindow(frame)

        return True
        
        

if __name__ == "__main__":
    app = Main(0)
    app.MainLoop()

If I load the image direcly in FourByTwo class it works. But when I am trying to load it from its parent I got stuck. I am getting this error:

_windows_.Dialog_swiginit(self,_windows_.new_Dialog(*args, **kwargs))
TypeError: Expected a 2-tuple of integers or a wxPoint object.

I don't understand what does it mean? Could someone kindly tell me what I am doing wrong?


Thanks
Regards

Then you should mark this thread solved. You could also consider posting your explanation of what the solution was.

Hi tonyjv,
I have already marked this thread as 'Solved' yesterday and the solution was this

image="JPEGImage"

Thanks
Regards

This question has already been answered. Start a new discussion instead.