1 """Simple wxPython wxApp for smartcard.
2
3 __author__ = "gemalto http://www.gemalto.com"
4
5 Copyright 2001-2012 gemalto
6 Author: Jean-Daniel Aussel, mailto:jean-daniel.aussel@gemalto.com
7
8 This file is part of pyscard.
9
10 pyscard is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14
15 pyscard is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public License
21 along with pyscard; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 """
24
25 import wx
26
27 from smartcard.wx.SimpleSCardAppFrame import SimpleSCardAppFrame
28
29 TR_SMARTCARD = 0x001
30 TR_READER = 0x002
31 TB_SMARTCARD = 0x004
32 TB_READER = 0x008
33 PANEL_APDUTRACER = 0x010
34 TR_DEFAULT = TR_SMARTCARD
35
36
38 """The SimpleSCardApp class represents the smart card application.
39 SimpleSCardApp is a subclass of wx.App.
40 """
41
42 - def __init__(self,
43 appname='',
44 apppanel=None,
45 appstyle=TR_DEFAULT,
46 appicon=None,
47 pos=(-1, -1),
48 size=(-1, -1)):
49 """Constructor for simple smart card application.
50 @param appname: the application name
51 @param apppanel: the application panel to display in the application frame
52 @param appicon: the application icon file; the default is no icon
53 @param appstyle: a combination of the following styles (bitwise or |)
54 - TR_SMARTCARD: display a smartcard tree panel
55 - TR_READER: display a reader tree panel
56 - TB_SMARTCARD: display a smartcard toolbar
57 - TB_SMARTCARD: display a reader toolbar
58 - PANEL_APDUTRACER: display an APDU tracer panel
59 - default is TR_DEFAULT = TR_SMARTCARD
60 @param pos: the application position as a (x,y) tupple; default is (-1,-1)
61 @param size: the application window size as a (x,y) tuple; default is (-1,-1)
62
63 Example:
64 C{app = SimpleSCardApp(
65 appname = 'A simple smartcard application',
66 apppanel = testpanel.MyPanel,
67 appstyle = TR_READER | TR_SMARTCARD,
68 appicon = 'resources\mysmartcard.ico')}
69 """
70 self.appname = appname
71 self.apppanel = apppanel
72 self.appstyle = appstyle
73 self.appicon = appicon
74 self.pos = pos
75 self.size = size
76 wx.App.__init__(self, False)
77
79 """Create and display application frame."""
80 self.frame = SimpleSCardAppFrame(
81 self.appname,
82 self.apppanel,
83 self.appstyle,
84 self.appicon,
85 self.pos,
86 self.size)
87 self.frame.Show(True)
88 self.SetTopWindow(self.frame)
89
90 return True
91