csync-git
[mirrors/ArchLinux-Packages.git] / wxccrypt / wx_ccrypt_2.py
1 #!/usr/bin/env python
2 from wxPython.wx import *
3 from wxPython.lib.stattext import wxGenStaticText
4 import os
5 import gettext
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()
15 ID_LANG_CZ =wxNewId()
16 ID_DIR_CRYPT=wxNewId()
17 ID_DIR_DECRYPT=wxNewId()
18 ID_HELP_MANUAL=wxNewId()
19 ID_OPTION=wxNewId()
20
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 :-)
41 #
42 file_menu = wxMenu()
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
51 help_menu = wxMenu()
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()
56
57 pref_menu = wxMenu()
58
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')
63
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.
72 #
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 -----------------------------------------------
81
82 self.button1 = wxButton(id=wxID_WXFRAME1BUTTON1, label='vyber',
83 name='button1', parent=self, pos=wxPoint(408, 56), size=wxSize(80,
84 22), style=0)
85 EVT_BUTTON(self.button1, wxID_WXFRAME1BUTTON1, self.file_encrypt)
86
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)
91
92 self.staticBox1 = wxStaticBox(id=wxID_WXFRAME1STATICBOX1, label='',
93 name='staticBox1', parent=self, pos=wxPoint(8, 48),
94 size=wxSize(528, 32), style=0)
95
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,
100 'helvetica'))
101
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='')
105
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)
109
110 self.staticBox2 = wxStaticBox(id=wxID_WXFRAME1STATICBOX2, label='',
111 name='staticBox2', parent=self, pos=wxPoint(9, 183),
112 size=wxSize(528, 42), style=0)
113
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)
118
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)
123
124 self.staticBox3 = wxStaticBox(id=wxID_WXFRAME1STATICBOX3, label='',
125 name='staticBox3', parent=self, pos=wxPoint(8, 88),
126 size=wxSize(528, 40), style=0)
127
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)
132
133 self.button3 = wxButton(id=wxID_WXFRAME1BUTTON3, label='vyber',
134 name='button3', parent=self, pos=wxPoint(408, 96), size=wxSize(80,
135 22), style=0)
136 EVT_BUTTON(self.button3, wxID_WXFRAME1BUTTON3, self.de_file)
137
138 self.staticBox4 = wxStaticBox(id=wxID_WXFRAME1STATICBOX4, label='',
139 name='staticBox4', parent=self, pos=wxPoint(8, 136),
140 size=wxSize(528, 40), style=0)
141
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)
146
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)
151
152
153
154 def OnFileExit(self, evt):
155 """
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.
159 """
160 dlg = wxMessageDialog(self, 'Exit Program?', 'I Need To Know!',
161 wxYES_NO | wxICON_QUESTION)
162 if dlg.ShowModal() == wxID_YES:
163 dlg.Destroy()
164 self.Close(true)
165 else:
166 dlg.Destroy()
167 def ToDo(self, evt):
168 """
169 A general purpose "we'll do it later" dialog box
170 """
171 dlg = wxMessageDialog(self, 'Not Yet Implimented!', 'ToDo',
172 wxOK | wxICON_INFORMATION)
173 dlg.ShowModal()
174 dlg.Destroy()
175 def file_encrypt2(self, event):
176 event.Skip()
177 dlg = wxFileDialog(self, "Choose a file", ".", "", "*.*", wxOPEN)
178 try:
179 if dlg.ShowModal() == wxID_OK:
180 filename = dlg.GetPath()
181 # Your code
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 %")
187
188 finally:
189 dlg.Destroy()
190
191
192
193
194
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)
200 nazev=filename[:-4]
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%")
204 Kde=os.getcwd()
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)
211 #nazev=filename[:-4]
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%")
215 #Kde=os.getcwd()
216 # vypis=os.system("ls -la %s" % Kde)
217 #self.textCtrl1.AppendText("\n %s" % vypis)
218 def de_file(self, event):
219
220 event.Skip()
221 dlg = wxFileDialog(self, "Choose a file", ".", "", "*.cpt", wxOPEN)
222 try:
223 if dlg.ShowModal() == wxID_OK:
224 filename = dlg.GetPath()
225 # Your code
226 self.textCtrl1.AppendText("vybraly ste %s" % filename)
227 dlg = wxMessageDialog(self, 'Chcete rozkryptovat %s. ??? \n ' % (filename),
228 'Potvrzeni', wxYES_NO | wxICON_INFORMATION)
229 try:
230 dlg.ShowModal()
231
232 finally:
233 #dlg.Destroy()
234 if dlg.ShowModal() == wxID_YES:
235 self.decryptujHO2(filename)
236 finally:
237 dlg.Destroy
238
239
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)
244 nazev= dir + '.tar'
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)
256 #nazev= dir + '.tar'
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 %")
263
264 def adr_encrypt(self, event):
265 event.Skip()
266 dlg = wxDirDialog(self, "Choose a file", ".")
267 try:
268 if dlg.ShowModal() == wxID_OK:
269 dir = dlg.GetPath()
270
271 self.textCtrl1.AppendText("vybral si adresar %s \n" % dir)
272 #kolik = os.popen("du -ch %s" % dir , 'r' ).readline()
273 kde=os.getcwd()
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)
277
278 try:
279 dlg.ShowModal()
280
281 finally:
282 if dlg.ShowModal() == wxID_YES:
283 self.cryptujHO(dir)
284
285
286 dlg.Destroy()
287
288
289 # Your code
290 finally:
291 dlg.Destroy()
292 def file_encrypt(self, event):
293
294 event.Skip()
295 dlg = wxFileDialog(self)
296 try:
297 if dlg.ShowModal() == wxID_OK:
298 dir = dlg.GetPath()
299 self.textCtrl1.AppendText("vybral si subor %s \n" % dir)
300 # kolik = os.popen("du -ch %s" % dir , 'r' ).readline()
301 kde=os.getcwd()
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)
305
306 try:
307 dlg.ShowModal()
308
309 finally:
310 if dlg.ShowModal() == wxID_YES:
311 self.cryptujHO3(dir)
312
313
314 dlg.Destroy()
315
316
317 # Your code
318 finally:
319 dlg.Destroy()
320
321
322 def adr_de_crypt(self, event):
323 event.Skip()
324 dlg = wxFileDialog(self, "Choose a file", ".", "", "*.cpt", wxOPEN)
325 try:
326 if dlg.ShowModal() == wxID_OK:
327 filename = dlg.GetPath()
328 # Your code
329 self.textCtrl1.AppendText("vybraly ste %s" % filename)
330 dlg = wxMessageDialog(self, 'Chcete rozkryptovat %s. ??? \n ' % (filename),
331 'Potvrzeni', wxYES_NO | wxICON_INFORMATION)
332 try:
333 dlg.ShowModal()
334
335 finally:
336 #dlg.Destroy()
337 if dlg.ShowModal() == wxID_YES:
338 self.decryptujHO(filename)
339 finally:
340 dlg.Destroy
341
342 def konec(self, event):
343 event.Skip()
344
345 def OnMenu1Items0Menu(self, event):
346 event.Skip()
347 def options(self, event):
348 event.Skip()
349 class myMenuApp(wxApp):
350 def OnInit(self):
351 frame = myFrame(NULL, -1, 'WX CCRYPT , encrytpt your file or directory')
352
353
354
355
356 frame.Show(true)
357 self.SetTopWindow(frame)
358 return true
359 ##########################################################################
360 ### Test Code ############################################################
361 ##########################################################################
362 app=myMenuApp(0)
363 app.MainLoop()
This page took 0.50381 seconds and 4 git commands to generate.