Module guiclasses
[hide private]
[frames] | no frames]

Source Code for Module guiclasses

 1  """This module has gui customized componenet classes that are needed for proper alignment and control. 
 2  """ 
 3  import wx 
 4  import wx.lib.scrolledpanel 
 5   
 6   
7 -class ScrolledPanel(wx.Panel):
8 """This inherits from wx.Panel class. It provides an adaptive panel for image. 9 It creates scrollbars as soon as image goes out of the panel. So it dosent result in to any deformation. Fit for larger size of image also. 10 """
11 - def __init__(self, parent, id,bitmap=None):
12 """This is the constructor for ScrolledPanel class 13 14 @param parent: parent wx container 15 @param bitmap: wx.Bitmap image to set into the panel 16 @param id: id for this instance 17 """ 18 wx.Panel.__init__(self, parent, id) 19 self.scrolledPanel = wx.lib.scrolledpanel.ScrolledPanel(self,size=self.GetSize()) 20 21 sizer = wx.BoxSizer() 22 sizer.Add(self.scrolledPanel, 1, wx.EXPAND) 23 self.SetSizer(sizer) 24 25 if bitmap!=None: 26 self.SetBitmap(bitmap) 27 28 self.scrolledPanel.SetBackgroundColour(wx.WHITE)
29
30 - def SetBitmap(self,bitmap):
31 """Set bitmap explicitly to the panel 32 33 @param bitmap: bitmap to set 34 @return Nothing 35 """ 36 wx.StaticBitmap(self.scrolledPanel, -1, bitmap) 37 self.scrolledPanel.SetScrollbars(20,20, bitmap.GetSize()[0]/20+1, bitmap.GetSize()[1]/20+1) #(pixelsperstep,pixelsperstep,size in step count,extra_margin) 38 self.scrolledPanel.Scroll(0,0)
39 40 41
42 -class SplitterPanel(wx.Panel):
43 """To create extension user inherits its panel from SplitterPanel class. It provided three main properties: Splitter,WorkPad,ImagePanel 44 Splitter: To control over splitter 45 WorkPad: to add widgets 46 ImagePanel: Set image 47 """
48 - def __init__(self, parent, id, size=(100,100),style=wx.SUNKEN_BORDER):
49 """Constructor of SplitterPanel 50 51 @param parent: parent container 52 @param id: id of the widget 53 @param size: size tuple 54 @param style:style for panel 55 """ 56 wx.Panel.__init__(self, parent, id, (0,0),size,style) 57 58 self.Splitter = wx.SplitterWindow(self, -1) 59 self.WorkPad = wx.Panel(self.Splitter, -1) 60 61 self.ImagePanel=ScrolledPanel(self.Splitter, -1) 62 63 self.Splitter.SplitVertically(self.WorkPad, self.ImagePanel) 64 65 sizer = wx.BoxSizer() 66 sizer.Add(self.Splitter, 1, wx.EXPAND) 67 self.SetSizer(sizer)
68
69 - def SetBitmap(self,bitmap):
70 """Set bitmap explicitly to the ScrolledPanel 71 72 @param bitmap: bitmap to set 73 @return Nothing 74 """ 75 self.ImagePanel.SetBitmap(bitmap)
76