Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 506b7c4

Browse files
style: format code with autopep8
Format code with autopep8 This commit fixes the style issues introduced in 5f2428a according to the output from Autopep8. Details: None
1 parent e743c6a commit 506b7c4

File tree

3 files changed

+55
-46
lines changed

3 files changed

+55
-46
lines changed

‎Complaint-Management/db.py‎

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
import sqlite3
22

3+
34
class DBConnect:
4-
def __init__(self):
5-
self._db = sqlite3.connect('information.db')
6-
self._db.row_factory = sqlite3.Row
7-
self._db.execute('create table if not exists Comp(ID integer primary key autoincrement, Name varchar(255), Gender varchar(255), Comment text)')
8-
self._db.commit()
9-
defAdd(self, name, gender, comment):
10-
self._db.execute('insert into Comp (Name, Gender, Comment) values (?,?,?)',(name,gender,comment))
11-
self._db.commit()
12-
return'Your complaint has been submitted.'
13-
defListRequest(self):
14-
cursor=self._db.execute('select * from Comp')
15-
return cursor
5+
def __init__(self):
6+
self._db = sqlite3.connect('information.db')
7+
self._db.row_factory = sqlite3.Row
8+
self._db.execute(
9+
'create table if not exists Comp(ID integer primary key autoincrement, Name varchar(255), Gender varchar(255), Comment text)')
10+
self._db.commit()
11+
12+
defAdd(self, name, gender, comment):
13+
self._db.execute(
14+
'insert into Comp (Name, Gender, Comment) values (?,?,?)', (name, gender, comment))
15+
self._db.commit()
16+
return 'Your complaint has been submitted.'
1617

18+
def ListRequest(self):
19+
cursor = self._db.execute('select * from Comp')
20+
return cursor

‎Complaint-Management/listComp.py‎

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@
33
from db import DBConnect
44
import sqlite3
55

6+
67
class ListComp:
7-
def __init__(self):
8-
self._dbconnect = DBConnect()
9-
self._dbconnect.row_factory = sqlite3.Row
10-
self._root = Tk()
11-
self._root.title('List of Complaints')
12-
tv = Treeview(self._root)
13-
tv.pack()
14-
tv.heading('#0', text='ID')
15-
tv.configure(column=('#Name', '#Gender', '#Comment'))
16-
tv.heading('#Name', text='Name')
17-
tv.heading('#Gender', text='Gender')
18-
tv.heading('#Comment', text='Comment')
19-
cursor = self._dbconnect.ListRequest()
20-
for row in cursor:
21-
tv.insert('', 'end', '#{}'.format(row['ID']),text=row['ID'])
22-
tv.set('#{}'.format(row['ID']),'#Name',row['Name'])
23-
tv.set('#{}'.format(row['ID']),'#Gender',row['Gender'])
24-
tv.set('#{}'.format(row['ID']),'#Comment',row['Comment'])
25-
8+
def __init__(self):
9+
self._dbconnect = DBConnect()
10+
self._dbconnect.row_factory = sqlite3.Row
11+
self._root = Tk()
12+
self._root.title('List of Complaints')
13+
tv = Treeview(self._root)
14+
tv.pack()
15+
tv.heading('#0', text='ID')
16+
tv.configure(column=('#Name', '#Gender', '#Comment'))
17+
tv.heading('#Name', text='Name')
18+
tv.heading('#Gender', text='Gender')
19+
tv.heading('#Comment', text='Comment')
20+
cursor = self._dbconnect.ListRequest()
21+
for row in cursor:
22+
tv.insert('', 'end', '#{}'.format(row['ID']), text=row['ID'])
23+
tv.set('#{}'.format(row['ID']), '#Name', row['Name'])
24+
tv.set('#{}'.format(row['ID']), '#Gender', row['Gender'])
25+
tv.set('#{}'.format(row['ID']), '#Comment', row['Comment'])

‎Complaint-Management/main.py‎

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,52 +4,57 @@
44
from db import DBConnect
55
from listComp import ListComp
66

7-
#Config
7+
#Config
88
conn = DBConnect()
99
root = Tk()
1010
root.geometry('600x285')
1111
root.title('Complaint Management')
1212
root.configure(background='#AEB6BF')
1313

14-
#Style
14+
#Style
1515
style = Style()
1616
style.theme_use('classic')
1717
for elem in ['TLabel', 'TButton', 'TRadioutton']:
18-
style.configure(elem, background='#AEB6BF')
18+
style.configure(elem, background='#AEB6BF')
1919

20-
#Gridx1353
20+
#Gridx1353
2121
labels = ['Full Name:', 'Gender:', 'Comment:']
2222
for i in range(3):
23-
Label(root, text=labels[i]).grid(row=i, column=0, padx=10, pady=10)
23+
Label(root, text=labels[i]).grid(row=i, column=0, padx=10, pady=10)
2424

2525
BuList = Button(root, text='List Comp.')
2626
BuList.grid(row=4, column=1)
2727
BuSubmit = Button(root, text='Submit Now')
2828
BuSubmit.grid(row=4, column=2)
2929

30-
#Entries
30+
#Entries
3131
fullname = Entry(root, width=40, font=('Arial', 14))
3232
fullname.grid(row=0, column=1, columnspan=2)
3333
SpanGender = StringVar()
3434

35-
Radiobutton(root, text='Male', value='male', variable=SpanGender).grid(row=1, column=1)
36-
Radiobutton(root, text='Female', value='female', variable=SpanGender).grid(row=1, column=2)
35+
Radiobutton(root, text='Male', value='male',
36+
variable=SpanGender).grid(row=1, column=1)
37+
Radiobutton(root, text='Female', value='female',
38+
variable=SpanGender).grid(row=1, column=2)
3739

3840
comment = Text(root, width=35, height=5, font=('Arial', 14))
3941
comment.grid(row=2, column=1, columnspan=2, padx=10, pady=10)
4042

41-
#brought to you by code-projects.org
43+
# brought to you by code-projects.org
44+
45+
4246
def SaveData():
43-
msg = conn.Add(fullname.get(), SpanGender.get(), comment.get(1.0, 'end'))
44-
fullname.delete(0, 'end')
45-
comment.delete(1.0, 'end')
46-
showinfo(title='Add Info', message=msg)
47+
msg = conn.Add(fullname.get(), SpanGender.get(), comment.get(1.0, 'end'))
48+
fullname.delete(0, 'end')
49+
comment.delete(1.0, 'end')
50+
showinfo(title='Add Info', message=msg)
51+
4752

4853
def ShowList():
49-
listrequest = ListComp()
54+
listrequest = ListComp()
55+
5056

5157
BuSubmit.config(command=SaveData)
5258
BuList.config(command=ShowList)
5359

5460
root.mainloop()
55-

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /