回答編集履歴

3

処理修正

2020/02/13 11:17

投稿

shiracamus
shiracamus

スコア5406

test CHANGED
@@ -36,17 +36,17 @@
36
36
 
37
37
 
38
38
 
39
+ dbpath = "dex.sqlite3"
40
+
41
+ conn = sql.connect(dbpath)
42
+
43
+ cur = conn.cursor()
44
+
45
+
46
+
39
47
 
40
48
 
41
49
  def get_info():
42
-
43
- dbpath = "dex.sqlite3"
44
-
45
- conn = sql.connect(dbpath)
46
-
47
- cur = conn.cursor()
48
-
49
-
50
50
 
51
51
  name = gui.aname.get()
52
52
 

2

バグ修正

2020/02/13 11:17

投稿

shiracamus
shiracamus

スコア5406

test CHANGED
@@ -48,7 +48,7 @@
48
48
 
49
49
 
50
50
 
51
- name = main.aname.get()
51
+ name = gui.aname.get()
52
52
 
53
53
  cur.execute("SELECT A FROM dex WHERE name = '%s'" % name)
54
54
 

1

printするだけの関数追記

2020/02/13 11:13

投稿

shiracamus
shiracamus

スコア5406

test CHANGED
@@ -15,3 +15,79 @@
15
15
 
16
16
 
17
17
  こうすればインスタンスメソッドで、selfが使えるようになります。
18
+
19
+
20
+
21
+ printするだけの関数にしてみました。
22
+
23
+
24
+
25
+ ```py
26
+
27
+ import tkinter as tk
28
+
29
+ import sqlite3 as sql
30
+
31
+ import tkinter.ttk as ttk
32
+
33
+
34
+
35
+ import main as gui
36
+
37
+
38
+
39
+
40
+
41
+ def get_info():
42
+
43
+ dbpath = "dex.sqlite3"
44
+
45
+ conn = sql.connect(dbpath)
46
+
47
+ cur = conn.cursor()
48
+
49
+
50
+
51
+ name = main.aname.get()
52
+
53
+ cur.execute("SELECT A FROM dex WHERE name = '%s'" % name)
54
+
55
+ A = cur.fetchone()
56
+
57
+ cur.execute("SELECT C FROM dex WHERE name = '%s'" % name)
58
+
59
+ C = cur.fetchone()
60
+
61
+ cur.execute("SELECT S FROM dex WHERE name = '%s'" % name)
62
+
63
+ S = cur.fetchone()
64
+
65
+
66
+
67
+ print(name)
68
+
69
+ print(A)
70
+
71
+ print(C)
72
+
73
+ print(S)
74
+
75
+
76
+
77
+
78
+
79
+ def main():
80
+
81
+ button = tk.Button(gui.win, text='print', command=get_info)
82
+
83
+ button.pack()
84
+
85
+ gui.win.mainloop()
86
+
87
+
88
+
89
+ if __name__ == "__main__":
90
+
91
+ main()
92
+
93
+ ```