2 from wxPython
.wx
import *
3 from wxPython
.lib
.stattext
import wxGenStaticText
6 # we want a unique identifiers to associate with each menu
7 # option. I use the convention of all (menu) identifiers begin
8 # with 'ID', followed by the menu the option belongs to, then
9 # the option name. It's a bit wordy, but I like it.
10 ID_FILE_CRYPT
= wxNewId()
11 ID_FILE_DECRYPT
= wxNewId()
12 ID_FILE_EXIT
= wxNewId()
13 ID_HELP_ABOUT
= wxNewId()
14 ID_LANG_US
= wxNewId()
16 ID_DIR_CRYPT
=wxNewId()
17 ID_DIR_DECRYPT
=wxNewId()
18 ID_HELP_MANUAL
=wxNewId()
21 [wxID_WXFRAME1
, wxID_WXFRAME1BUTTON1
, wxID_WXFRAME1BUTTON2
,
22 wxID_WXFRAME1BUTTON3
, wxID_WXFRAME1BUTTON4
, wxID_WXFRAME1GENSTATICTEXT1
,
23 wxID_WXFRAME1STATICBOX1
, wxID_WXFRAME1STATICBOX2
, wxID_WXFRAME1STATICBOX3
,
24 wxID_WXFRAME1STATICBOX4
, wxID_WXFRAME1STATICTEXT1
, wxID_WXFRAME1STATICTEXT2
,
25 wxID_WXFRAME1STATICTEXT3
, wxID_WXFRAME1STATICTEXT4
, wxID_WXFRAME1STATICTEXT5
,
26 wxID_WXFRAME1TEXTCTRL1
,
27 ] = map(lambda _init_ctrls
: wxNewId(), range(16))
28 class myFrame(wxFrame
):
29 def __init__(self
, parent
, id, title
):
30 # create a frame for our demo
31 wxFrame
.__init
__(self
, parent
, id, title
)
32 self
.SetClientSize(wxSize(545, 436))
33 # create the 'File' menu, then add the 'open',
34 # 'close', and 'exit' options. Notice that we use
35 # the identifiers created above to associate an id
36 # to each menu item (we will use the id again when
37 # we want to 'tell' the program what to do when the
38 # user selects a menu item). We didn't mention
39 # the 'AppendSeparator()', but you should be able
40 # to figure out what it does :-)
43 file_menu
.Append(ID_FILE_CRYPT
, 'Crypt File')
44 file_menu
.Append(ID_FILE_DECRYPT
, 'Decrypt File')
45 file_menu
.AppendSeparator()
46 file_menu
.Append(ID_DIR_CRYPT
, 'crypt directory')
47 file_menu
.Append(ID_DIR_DECRYPT
, 'decrypt directory')
48 file_menu
.AppendSeparator()
49 file_menu
.Append(ID_FILE_EXIT
, 'Exit Program')
50 # create the 'Help' menu
52 help_menu
.Append(ID_HELP_ABOUT
, 'About')
53 help_menu
.Append(ID_HELP_MANUAL
, 'Manual')
54 # we now need a menu bar to hold the 2 menus just created
55 menu_bar
= wxMenuBar()
59 pref_menu
.Append(ID_OPTION
, 'Options')
60 menu_bar
.Append(file_menu
, 'File')
61 menu_bar
.Append(pref_menu
, "Options")
62 menu_bar
.Append(help_menu
, 'Help')
64 # set the menu bar (tells the system we're done)
65 self
.SetMenuBar(menu_bar
)
66 # that's great! Now let's make the menu options do something!
67 # Using EVT_MENU, we associate the identifier for each menu
68 # item to a method to be called when the menu item is selected.
69 # Most of these items will call the 'ToDo' function; essentially
70 # a small stub method to tell the user something will happen,
71 # but we have not got around to programming it, yet.
73 EVT_MENU(self
, ID_FILE_CRYPT
, self
.file_encrypt
)
74 EVT_MENU(self
, ID_FILE_DECRYPT
, self
.de_file
)
75 EVT_MENU(self
, ID_FILE_EXIT
, self
.OnFileExit
)
76 EVT_MENU(self
, ID_HELP_ABOUT
, self
.ToDo
)
77 EVT_MENU(self
, ID_DIR_CRYPT
, self
.adr_encrypt
)
78 EVT_MENU(self
, ID_DIR_DECRYPT
, self
.adr_de_crypt
)
79 EVT_MENU(self
, ID_OPTION
, self
.ToDo
)
80 #-----------------------------------------Zacatek -----------------------------------------------
82 self
.button1
= wxButton(id=wxID_WXFRAME1BUTTON1
, label
='vyber',
83 name
='button1', parent
=self
, pos
=wxPoint(408, 56), size
=wxSize(80,
85 EVT_BUTTON(self
.button1
, wxID_WXFRAME1BUTTON1
, self
.file_encrypt
)
87 self
.staticText1
= wxStaticText(id=wxID_WXFRAME1STATICTEXT1
,
88 label
='vyber s\xfabor kter\xfd chce\xb9 zakryptovat',
89 name
='staticText1', parent
=self
, pos
=wxPoint(24, 56),
90 size
=wxSize(384, 32), style
=0)
92 self
.staticBox1
= wxStaticBox(id=wxID_WXFRAME1STATICBOX1
, label
='',
93 name
='staticBox1', parent
=self
, pos
=wxPoint(8, 48),
94 size
=wxSize(528, 32), style
=0)
96 self
.genStaticText1
= wxGenStaticText(ID
=wxID_WXFRAME1GENSTATICTEXT1
,
97 label
='WX CCRYPT v0.2', name
='genStaticText1', parent
=self
,
98 pos
=wxPoint(152, 8), size
=wxSize(202, 27), style
=0)
99 self
.genStaticText1
.SetFont(wxFont(24, 77, wxNORMAL
, wxBOLD
, False,
102 self
.textCtrl1
= wxTextCtrl(id=wxID_WXFRAME1TEXTCTRL1
, name
='textCtrl1',
103 parent
=self
, pos
=wxPoint(8, 272), size
=wxSize(528, 136),
104 style
=wxTE_MULTILINE | wxVSCROLL | wxTE_READONLY
, value
='')
106 self
.staticText2
= wxStaticText(id=wxID_WXFRAME1STATICTEXT2
,
107 label
='status', name
='staticText2', parent
=self
, pos
=wxPoint(8,
108 248), size
=wxSize(48, 32), style
=0)
110 self
.staticBox2
= wxStaticBox(id=wxID_WXFRAME1STATICBOX2
, label
='',
111 name
='staticBox2', parent
=self
, pos
=wxPoint(9, 183),
112 size
=wxSize(528, 42), style
=0)
114 self
.staticText3
= wxStaticText(id=wxID_WXFRAME1STATICTEXT3
,
115 label
='vyber adres\xe1r kter\xfd chce\xb9 zakrypovat',
116 name
='staticText3', parent
=self
, pos
=wxPoint(24, 152),
117 size
=wxSize(232, 72), style
=0)
119 self
.button2
= wxButton(id=wxID_WXFRAME1BUTTON2
, label
='vyber',
120 name
='button2', parent
=self
, pos
=wxPoint(408, 144),
121 size
=wxSize(80, 22), style
=0)
122 EVT_BUTTON(self
.button2
, wxID_WXFRAME1BUTTON2
, self
.adr_encrypt
)
124 self
.staticBox3
= wxStaticBox(id=wxID_WXFRAME1STATICBOX3
, label
='',
125 name
='staticBox3', parent
=self
, pos
=wxPoint(8, 88),
126 size
=wxSize(528, 40), style
=0)
128 self
.staticText4
= wxStaticText(id=wxID_WXFRAME1STATICTEXT4
,
129 label
='vyber s\xfabor kter\xfd chce\xb9 rozkryptovat',
130 name
='staticText4', parent
=self
, pos
=wxPoint(24, 104),
131 size
=wxSize(208, 16), style
=0)
133 self
.button3
= wxButton(id=wxID_WXFRAME1BUTTON3
, label
='vyber',
134 name
='button3', parent
=self
, pos
=wxPoint(408, 96), size
=wxSize(80,
136 EVT_BUTTON(self
.button3
, wxID_WXFRAME1BUTTON3
, self
.de_file
)
138 self
.staticBox4
= wxStaticBox(id=wxID_WXFRAME1STATICBOX4
, label
='',
139 name
='staticBox4', parent
=self
, pos
=wxPoint(8, 136),
140 size
=wxSize(528, 40), style
=0)
142 self
.staticText5
= wxStaticText(id=wxID_WXFRAME1STATICTEXT5
,
143 label
='vyber adres\xe1r kter\xfd chce\xb9 rozkryptovat',
144 name
='staticText5', parent
=self
, pos
=wxPoint(21, 194),
145 size
=wxSize(488, 32), style
=0)
147 self
.button4
= wxButton(id=wxID_WXFRAME1BUTTON4
, label
='vyber',
148 name
='button4', parent
=self
, pos
=wxPoint(411, 188),
149 size
=wxSize(80, 22), style
=0)
150 EVT_BUTTON(self
.button4
, wxID_WXFRAME1BUTTON4
, self
.adr_de_crypt
)
154 def OnFileExit(self
, evt
):
156 This is executed when the user clicks the 'Exit' option
157 under the 'File' menu. We ask the user if they *really*
158 want to exit, then close everything down if they do.
160 dlg
= wxMessageDialog(self
, 'Exit Program?', 'I Need To Know!',
161 wxYES_NO | wxICON_QUESTION
)
162 if dlg
.ShowModal() == wxID_YES
:
169 A general purpose "we'll do it later" dialog box
171 dlg
= wxMessageDialog(self
, 'Not Yet Implimented!', 'ToDo',
172 wxOK | wxICON_INFORMATION
)
175 def file_encrypt2(self
, event
):
177 dlg
= wxFileDialog(self
, "Choose a file", ".", "", "*.*", wxOPEN
)
179 if dlg
.ShowModal() == wxID_OK
:
180 filename
= dlg
.GetPath()
182 self
.textCtrl1
.AppendText("vybral si %s" % filename
)
183 os
.system("xterm -e ccencrypt %s" % filename
)
184 konecny
= filename
+ '.cpt'
185 self
.textCtrl1
.AppendText(" \n zakryptoval sem %s " % konecny
)
186 self
.textCtrl1
.AppendText("\n Ukol splnen na 100 %")
195 def decryptujHO(self
, filename
):
196 #funkce decryptuj adresar
197 self
.textCtrl1
.AppendText("\n rozkryptovavam %s" % filename
)
198 self
.textCtrl1
.AppendText("\n Budete dotazany na heslo")
199 os
.system("xterm -e ccdecrypt %s" % filename
)
201 self
.textCtrl1
.AppendText("\n rozkryptoval sem %s" % nazev
)
202 os
.system("tar -xPf %s" % nazev
)
203 self
.textCtrl1
.AppendText("\n Ukol splnen na 100%")
205 vypis
=os
.system("ls -la %s" % Kde
)
206 self
.textCtrl1
.AppendText("\n %s" % vypis
)
207 def decryptujHO2(self
, filename
):
208 self
.textCtrl1
.AppendText("\n rozkryptovavam %s" % filename
)
209 self
.textCtrl1
.AppendText("\n Budete dotazany na heslo")
210 os
.system("xterm -e ccdecrypt -d %s" % filename
)
212 self
.textCtrl1
.AppendText("\n rozkryptoval sem %s" % filename
)
213 #os.system("tar -xvvf %s" % nazev)
214 self
.textCtrl1
.AppendText("\n Ukol splnen na 100%")
216 # vypis=os.system("ls -la %s" % Kde)
217 #self.textCtrl1.AppendText("\n %s" % vypis)
218 def de_file(self
, event
):
221 dlg
= wxFileDialog(self
, "Choose a file", ".", "", "*.cpt", wxOPEN
)
223 if dlg
.ShowModal() == wxID_OK
:
224 filename
= dlg
.GetPath()
226 self
.textCtrl1
.AppendText("vybraly ste %s" % filename
)
227 dlg
= wxMessageDialog(self
, 'Chcete rozkryptovat %s. ??? \n ' % (filename
),
228 'Potvrzeni', wxYES_NO | wxICON_INFORMATION
)
234 if dlg
.ShowModal() == wxID_YES
:
235 self
.decryptujHO2(filename
)
240 def cryptujHO(self
, dir):
241 # metoda zakryptuj adresar priamo funkce
242 #print "a sme tu a chceme zakryptovat %s" %dir
243 self
.textCtrl1
.AppendText("potvril si zakryptovat adresar %s " % dir)
245 os
.system("tar -cPvf %s %s" % (nazev
, dir))
246 os
.system("rm -r -f %s" % (dir))
247 self
.textCtrl1
.AppendText("\n zapakoval sem %s " % nazev
)
248 os
.system("xterm -e ccencrypt %s" % nazev
)
249 konecny
= nazev
+ '.cpt'
250 self
.textCtrl1
.AppendText(" \n zakryptoval sem %s " % konecny
)
251 self
.textCtrl1
.AppendText("\n Ukol splnen na 100 %")
252 def cryptujHO3(self
, dir):
253 # metoda zakryptuj adresar priamo funkce
254 #print "a sme tu a chceme zakryptovat %s" %dir
255 self
.textCtrl1
.AppendText("potvril si zakryptovat subor %s " % dir)
257 #os.system("tar -cvvf %s " % (nazev))
258 #self.textCtrl1.AppendText("\n zapakoval sem %s " % nazev)
259 os
.system("xterm -e ccencrypt %s" % dir)
260 konecny
= dir + '.cpt'
261 self
.textCtrl1
.AppendText(" \n zakryptoval sem %s " % konecny
)
262 self
.textCtrl1
.AppendText("\n Ukol splnen na 100 %")
264 def adr_encrypt(self
, event
):
266 dlg
= wxDirDialog(self
, "Choose a file", ".")
268 if dlg
.ShowModal() == wxID_OK
:
271 self
.textCtrl1
.AppendText("vybral si adresar %s \n" % dir)
272 #kolik = os.popen("du -ch %s" % dir , 'r' ).readline()
274 #self.textCtrl1.AppendText("Bude se kryptovat %s" % kolik)
275 dlg
= wxMessageDialog(self
, 'Vybral si adresar %s. \n Vytvoreny zakryptovany subor bude ulozen do \n %s .\n Opravdu ho chces zakryptovat ? \n' % (dir, kde
),
276 'Potvrzeni', wxYES_NO | wxICON_INFORMATION
)
282 if dlg
.ShowModal() == wxID_YES
:
292 def file_encrypt(self
, event
):
295 dlg
= wxFileDialog(self
)
297 if dlg
.ShowModal() == wxID_OK
:
299 self
.textCtrl1
.AppendText("vybral si subor %s \n" % dir)
300 # kolik = os.popen("du -ch %s" % dir , 'r' ).readline()
302 # self.textCtrl1.AppendText("Bude se kryptovat %s" % kolik)
303 dlg
= wxMessageDialog(self
, 'Vybral si subor %s. \n Vytvoreny zakryptovany subor bude ulozen do \n %s .\n Opravdu ho chces zakryptovat ? \n' % (dir, kde
),
304 'Potvrzeni', wxYES_NO | wxICON_INFORMATION
)
310 if dlg
.ShowModal() == wxID_YES
:
322 def adr_de_crypt(self
, event
):
324 dlg
= wxFileDialog(self
, "Choose a file", ".", "", "*.cpt", wxOPEN
)
326 if dlg
.ShowModal() == wxID_OK
:
327 filename
= dlg
.GetPath()
329 self
.textCtrl1
.AppendText("vybraly ste %s" % filename
)
330 dlg
= wxMessageDialog(self
, 'Chcete rozkryptovat %s. ??? \n ' % (filename
),
331 'Potvrzeni', wxYES_NO | wxICON_INFORMATION
)
337 if dlg
.ShowModal() == wxID_YES
:
338 self
.decryptujHO(filename
)
342 def konec(self
, event
):
345 def OnMenu1Items0Menu(self
, event
):
347 def options(self
, event
):
349 class myMenuApp(wxApp
):
351 frame
= myFrame(NULL
, -1, 'WX CCRYPT , encrytpt your file or directory')
357 self
.SetTopWindow(frame
)
359 ##########################################################################
360 ### Test Code ############################################################
361 ##########################################################################