|
|
@ -5,9 +5,11 @@ Created on Dec 23, 2013 |
|
|
|
''' |
|
|
|
|
|
|
|
import wx |
|
|
|
import itertools |
|
|
|
import imageutil |
|
|
|
from app.images import image_store |
|
|
|
|
|
|
|
|
|
|
|
PAD_SIZE = 10 |
|
|
|
|
|
|
|
class FrameHeader(wx.Panel): |
|
|
@ -25,6 +27,7 @@ class FrameHeader(wx.Panel): |
|
|
|
|
|
|
|
self._init_properties() |
|
|
|
self._init_components(heading, subheading, image_path) |
|
|
|
self._init_pages() |
|
|
|
self._do_layout() |
|
|
|
|
|
|
|
|
|
|
@ -35,8 +38,10 @@ class FrameHeader(wx.Panel): |
|
|
|
def _init_components(self, heading, subheading, image_path): |
|
|
|
self._header = self._bold_static_text(heading) |
|
|
|
self._subheader = wx.StaticText(self, label=subheading) |
|
|
|
self._settings_img = self._load_image(image_path) |
|
|
|
self._running_img = self._load_image(image_store.harwen_monitor) |
|
|
|
self._settings_img = self._load_image(image_path, height=79) |
|
|
|
self._running_img = self._load_image(image_store.computer3, 79) |
|
|
|
self._check_mark = self._load_image(image_store.alessandro_rei_checkmark, height=75) |
|
|
|
|
|
|
|
|
|
|
|
def _do_layout(self): |
|
|
|
vsizer = wx.BoxSizer(wx.VERTICAL) |
|
|
@ -45,7 +50,9 @@ class FrameHeader(wx.Panel): |
|
|
|
sizer.Add(headings_sizer, 1, wx.ALIGN_LEFT | wx.ALIGN_CENTER_HORIZONTAL | wx.EXPAND | wx.LEFT, PAD_SIZE) |
|
|
|
sizer.Add(self._settings_img, 0, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, PAD_SIZE) |
|
|
|
sizer.Add(self._running_img, 0, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, PAD_SIZE) |
|
|
|
self._running_img.Hide() |
|
|
|
sizer.Add(self._check_mark, 0, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, PAD_SIZE) |
|
|
|
self._running_img.Hide() |
|
|
|
self._check_mark.Hide() |
|
|
|
vsizer.Add(sizer, 1, wx.EXPAND) |
|
|
|
self.SetSizer(vsizer) |
|
|
|
|
|
|
@ -56,6 +63,11 @@ class FrameHeader(wx.Panel): |
|
|
|
wx.FONTWEIGHT_NORMAL, wx.FONTWEIGHT_BOLD, False) |
|
|
|
) |
|
|
|
return txt |
|
|
|
|
|
|
|
def _load_image(self, img_path, height=70): |
|
|
|
return imageutil._resize_bitmap(self, |
|
|
|
imageutil._load_image(img_path), |
|
|
|
height) |
|
|
|
|
|
|
|
def build_heading_sizer(self): |
|
|
|
sizer = wx.BoxSizer(wx.VERTICAL) |
|
|
@ -65,42 +77,48 @@ class FrameHeader(wx.Panel): |
|
|
|
sizer.AddStretchSpacer(1) |
|
|
|
return sizer |
|
|
|
|
|
|
|
def _load_image(self, image_path): |
|
|
|
try: |
|
|
|
bitmap = wx.Bitmap(image_path) |
|
|
|
print bitmap |
|
|
|
bitmap = self._resize_bitmap(bitmap) |
|
|
|
return wx.StaticBitmap(self, -1, bitmap) |
|
|
|
except: |
|
|
|
raise IOError('Invalid Image path') |
|
|
|
|
|
|
|
def _resize_bitmap(self, bmap): |
|
|
|
''' |
|
|
|
Resizes a bitmap to a height of 89 pixels (the |
|
|
|
size of the top panel), while keeping aspect ratio |
|
|
|
in tact |
|
|
|
''' |
|
|
|
image = wx.ImageFromBitmap(bmap) |
|
|
|
width, height = image.GetSize() |
|
|
|
ratio = float(width) / height |
|
|
|
target_height = 79 |
|
|
|
image = image.Scale(target_height * ratio, target_height, |
|
|
|
wx.IMAGE_QUALITY_HIGH |
|
|
|
) |
|
|
|
return wx.BitmapFromImage(image) |
|
|
|
|
|
|
|
def RegisterController(self, controller): |
|
|
|
if self._controller is None: |
|
|
|
self._controller = controller |
|
|
|
|
|
|
|
def _init_pages(self): |
|
|
|
messages = [[ |
|
|
|
"Running", |
|
|
|
'Please wait while the application performs its tasks. ' + |
|
|
|
'\nThis may take a few moments' |
|
|
|
],[ |
|
|
|
'Finished', |
|
|
|
'All done! You may now safely close the program.' |
|
|
|
]] |
|
|
|
pages = [[ |
|
|
|
self._header.SetLabel, |
|
|
|
self._subheader.SetLabel, |
|
|
|
self._settings_img.Hide, |
|
|
|
self._running_img.Show, |
|
|
|
self.Layout, |
|
|
|
],[ |
|
|
|
self._header.SetLabel, |
|
|
|
self._subheader.SetLabel, |
|
|
|
self._running_img.Hide, |
|
|
|
self._check_mark.Show, |
|
|
|
self.Layout, |
|
|
|
]] |
|
|
|
self._messages = iter(messages) |
|
|
|
self._pages = iter(pages) |
|
|
|
|
|
|
|
def NextPage(self): |
|
|
|
self._header.SetLabel("Running") |
|
|
|
self._subheader.SetLabel('Please wait while the application performs its tasks. ' |
|
|
|
'\nThis may take a few moments') |
|
|
|
self._settings_img.Hide() |
|
|
|
self._running_img.Show() |
|
|
|
self.Layout() |
|
|
|
|
|
|
|
messages = next(self._messages) |
|
|
|
commands = next(self._pages) |
|
|
|
|
|
|
|
_zipl = itertools.izip_longest |
|
|
|
|
|
|
|
for func, arg in _zipl(commands, messages, fillvalue=None): |
|
|
|
if arg: |
|
|
|
func(arg) |
|
|
|
else: |
|
|
|
func() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|