|
| 1 | +#!/usr/bin/env python |
| 2 | +# -*- coding: utf-8 -*- |
| 3 | +""" |
| 4 | +File: __init__.py |
| 5 | +Description: View components for Python SDK sample. |
| 6 | +""" |
| 7 | + |
| 8 | +import wx |
| 9 | +import wx.lib.agw.labelbook as LB |
| 10 | + |
| 11 | +from wx.lib.agw.fmresources import INB_FIT_LABELTEXT |
| 12 | +from wx.lib.agw.fmresources import INB_LEFT |
| 13 | +from wx.lib.agw.fmresources import INB_NO_RESIZE |
| 14 | + |
| 15 | +from view.panel_detection import DetectionPanel |
| 16 | +from view.panel_subscription import SubscriptionPanel |
| 17 | +from view.panel_find_similar import FindSimilarPanel |
| 18 | +from view.panel_group import GroupPanel |
| 19 | +from view.panel_identification import IdentificationPanel |
| 20 | +from view.panel_verification import VerificationPanel |
| 21 | + |
| 22 | +TITLE = u"Microsoft Cognitive Services Face Samples" |
| 23 | + |
| 24 | + |
| 25 | +class MyLabelBook(LB.LabelBook): |
| 26 | + """LabelBook part in Main Frame.""" |
| 27 | + def __init__(self, parent): |
| 28 | + agw_style = INB_LEFT | INB_FIT_LABELTEXT | INB_NO_RESIZE |
| 29 | + super(MyLabelBook, self).__init__(parent, agwStyle=agw_style) |
| 30 | + |
| 31 | + subscription_panel = SubscriptionPanel(self) |
| 32 | + subscription_text = u"Subscription Key Management" |
| 33 | + self.AddPage(subscription_panel, subscription_text, True) |
| 34 | + |
| 35 | + self.AddPage(wx.Panel(self), u"Select a scenario:") |
| 36 | + self.EnableTab(1, False) |
| 37 | + |
| 38 | + self.AddPage(DetectionPanel(self), u" - Face Detection") |
| 39 | + self.AddPage(FindSimilarPanel(self), u" - Face Find Similar") |
| 40 | + self.AddPage(GroupPanel(self), u" - Face Grouping") |
| 41 | + self.AddPage(IdentificationPanel(self), u" - Face Identification") |
| 42 | + self.AddPage(VerificationPanel(self), u" - Face Verification") |
| 43 | + |
| 44 | + |
| 45 | +class MyTitle(wx.Panel): |
| 46 | + """Title part in Main Frame.""" |
| 47 | + def __init__(self, parent): |
| 48 | + super(MyTitle, self).__init__(parent) |
| 49 | + self.SetBackgroundColour('#00b294') |
| 50 | + self.SetMinSize((-1, 80)) |
| 51 | + |
| 52 | + sizer = wx.BoxSizer() |
| 53 | + sizer.AddStretchSpacer() |
| 54 | + |
| 55 | + family = wx.FONTFAMILY_DEFAULT |
| 56 | + style = wx.FONTSTYLE_NORMAL |
| 57 | + weight = wx.FONTWEIGHT_NORMAL |
| 58 | + font = wx.Font(20, family, style, weight) |
| 59 | + self.text = wx.StaticText(self, label=TITLE, style=wx.ALIGN_CENTER) |
| 60 | + self.text.SetFont(font) |
| 61 | + sizer.Add(self.text, flag=wx.ALIGN_CENTER_VERTICAL) |
| 62 | + |
| 63 | + sizer.AddStretchSpacer() |
| 64 | + self.SetSizer(sizer) |
| 65 | + |
| 66 | + |
| 67 | +class MyFrame(wx.Frame): |
| 68 | + """Main Frame.""" |
| 69 | + def __init__(self, parent): |
| 70 | + super(MyFrame, self).__init__(parent, title=TITLE, size=(1280, 768)) |
| 71 | + |
| 72 | + icon_path = 'Assets/Microsoft-logo_rgb_c-gray.png' |
| 73 | + self.SetIcon(wx.Icon(icon_path)) |
| 74 | + |
| 75 | + sizer = wx.BoxSizer(wx.VERTICAL) |
| 76 | + |
| 77 | + self.title = MyTitle(self) |
| 78 | + sizer.Add(self.title, flag=wx.EXPAND) |
| 79 | + |
| 80 | + self.book = MyLabelBook(self) |
| 81 | + sizer.Add(self.book, 1, flag=wx.EXPAND) |
| 82 | + |
| 83 | + status_text = ( |
| 84 | + 'Microsoft will receive the images you upload and may use them to ' |
| 85 | + 'improve Face API and related services. By submitting an image, ' |
| 86 | + 'you confirm you have consent from everyone in it.' |
| 87 | + ) |
| 88 | + self.status = wx.StatusBar(self) |
| 89 | + self.status.SetStatusText(status_text) |
| 90 | + sizer.Add(self.status, flag=wx.EXPAND) |
| 91 | + |
| 92 | + self.SetSizer(sizer) |
| 93 | + self.Layout() |
| 94 | + |
| 95 | + |
| 96 | +class MyApp(wx.App): |
| 97 | + """The whole app.""" |
| 98 | + def OnInit(self): |
| 99 | + """Show main frame.""" |
| 100 | + frame = MyFrame(None) |
| 101 | + frame.Show() |
| 102 | + return True |
0 commit comments