Suggestion needed on layout and class hierarchy

I have main GUI.py and ImageView.py

in Main GUI.py
i have created variable

import ImageView


self.panel1 = wx.Panel(self,-1, style=wx.SUNKEN_BORDER)


and after that
I am passing this to ImageView.py
by
self.imagewindow = ImageView.ImageView(self.panel3)


Code of ImageView.py is

class ImageView(wx.Panel):
def init(self,parent):
wx.Panel.init(self, parent, wx.ID_ANY)


I guess, This will create a panel inside panel. How I can avoid this ?? My code is working well…
Also, I am using Sizers… ani loading Image inside it. I want My Image should take maximum possible area . how I can do it ? currently it is taking fixed size.

currently I am loading one Image, but I want to load thumbnails of all images from a dir so that user can select which image to load by clicking it. Any help ?

···


┌─────────────────────────┐
│ Narendra Sisodiya
http://narendrasisodiya.com
└─────────────────────────┘

I have main GUI.py and ImageView.py

in Main GUI.py
i have created variable

import ImageView


self.panel1 = wx.Panel(self,-1, style=wx.SUNKEN_BORDER)


and after that

I am passing this to ImageView.py

by
self.imagewindow = ImageView.ImageView(self.panel3)


Code of ImageView.py is

class ImageView(wx.Panel):
def init(self,parent):

    wx.Panel.__init__(self, parent, wx.ID_ANY)

I have modified it something like

class ImageView():
def init(self,parent):

    self.panel = parent

With some other modification, code is working fine. I guess this is right approach as I have remove extra layer of panel.

···

On Mon, Sep 5, 2011 at 7:12 PM, Narendra Sisodiya narendra@narendrasisodiya.com wrote:


I guess, This will create a panel inside panel. How I can avoid this ?? My code is working well…
Also, I am using Sizers… ani loading Image inside it. I want My Image should take maximum possible area . how I can do it ? currently it is taking fixed size.

currently I am loading one Image, but I want to load thumbnails of all images from a dir so that user can select which image to load by clicking it. Any help ?


┌─────────────────────────┐

│ Narendra Sisodiya

http://narendrasisodiya.com
└─────────────────────────┘


┌─────────────────────────┐
│ Narendra Sisodiya
http://narendrasisodiya.com
└─────────────────────────┘

I have figured the solution

following code , resize a “self.image” inside “self.panel” andput it in central mode.

bitmap = wx.BitmapFromImage(self.image)

orgheight = bitmap.GetSize().GetHeight()
orgwidth = bitmap.GetSize().GetWidth()

orgAspectRatio = float(bitmap.GetSize().GetWidth()) / bitmap.GetSize().GetHeight()
print orgAspectRatio

width = self.panel.GetSize()[0]
height = self.panel.GetSize()[1]

newAspectRatio = float(width)/height
print newAspectRatio

if (newAspectRatio > orgAspectRatio ):
mulfactor= float(height)/float(bitmap.GetSize().GetHeight())

else:
mulfactor= float(width)/float(bitmap.GetSize().GetWidth())

image = wx.ImageFromBitmap(bitmap).Scale(orgwidthmulfactor, orgheightmulfactor, wx.IMAGE_QUALITY_HIGH)

finalbitmap = wx.BitmapFromImage(image)

newPos = ((width - orgwidth)/2,(height-orgheight)/2)

print newPos

self.bitmap = wx.StaticBitmap(self.panel, -1, finalbitmap,pos=newPos)

···

On Mon, Sep 5, 2011 at 7:25 PM, Narendra Sisodiya narendra@narendrasisodiya.com wrote:

Also, I am using Sizers… ani loading Image inside it. I want My Image should take maximum possible area . how I can do it ? currently it is taking fixed size.