-
Notifications
You must be signed in to change notification settings - Fork 0
/
DeleteCatalog.py
54 lines (42 loc) · 1.63 KB
/
DeleteCatalog.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python
# -*- coding: cp1250 -*-
import pygtk
import gtk
import json
import LeftColumnWithCatalogs
class DeleteCatalog(gtk.Window):
catalog = 'katalog_link'
def __init__(self):
super(DeleteCatalog, self).__init__()
self.connect('destroy', gtk.main_quit)
self.set_default_size(400, 50)
self.set_position(gtk.WIN_POS_CENTER)
self.set_title('Czy potwierdzasz wybor pozycji ?')
buttonConfirm = gtk.Button('Tak')
buttonConfirm.connect('clicked', self.deleteConfirmation, DeleteCatalog.catalog)
catalogName = gtk.Label(DeleteCatalog.catalog)
screen = gtk.Fixed()
screen.put(catalogName, 10, 10)
screen.put(buttonConfirm, 10, 30)
self.add(screen)
self.show_all()
gtk.main()
return
def deleteConfirmation(self, widgets, catalog):
catalog = catalog
with open('Database.json') as json_file:
data = json.load(json_file)
catalogsAsKeys = data.keys()
if catalog in catalogsAsKeys:
data.pop(str(catalog), None)
with open('Database.json', 'w') as outfile:
json.dump(data, outfile)
LeftColumnWithCatalogs.LeftColumnWithCatalogs()
else:
for i in catalogsAsKeys:
for j in data[i]:
if j == catalog:
data[i].pop(j, None)
with open('Database.json', 'w') as outfile:
json.dump(data, outfile)
return