teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

コードの変更

2017/12/19 08:38

投稿

gymgym
gymgym

スコア99

title CHANGED
File without changes
body CHANGED
@@ -41,54 +41,10 @@
41
41
  このエラーの原因はどこからくるのでしょうか。
42
42
 
43
43
  ```Python
44
- def show_selection(x, y):
45
- for i in lb.curselection():
46
- if i == 0:
47
- one = sum(x)
48
- zero = len(x) - sum(x)
44
+ from tkinter import *
49
- if one < zero:
50
- label.config(text="OK")
51
- elif i == 1:
52
- one = sum(y)
53
- zero = len(y) - sum(y)
54
- if one > zero:
55
- label.config(text="BAD")
56
45
 
57
- if __name__ == '__main__':
58
- root = Tk()
46
+ root = Tk()
59
- root.title('Scrollbar 1')
60
-
61
- # Frame
62
- frame1 = ttk.Frame(root, padding=10)
63
- frame1.grid()
64
-
65
- # Listbox
66
- currencies = ("A", "B")
67
- v1 = StringVar(value=currencies)
68
- lb = Listbox(frame1, listvariable=v1,height=3)
69
- lb.grid(row=0, column=0)
70
-
71
- # Label (新規追加)
72
- label = Label(frame1, width=18)
73
- label.grid(row=1, column=0, columnspan=2)
74
-
75
- # Scrollbar
76
- scrollbar = ttk.Scrollbar(
77
- frame1,
78
- orient=VERTICAL,
79
- command=lb.yview)
80
- lb['yscrollcommand'] = scrollbar.set
81
- scrollbar.grid(row=0,column=1,sticky=(N,S))
82
-
83
- a = [0,0,0,0,1,1,1]
84
- b = [1,1,1,1,1,0,0]
85
-
86
-
87
- #Button
88
- button1 = ttk.Button(frame1, text='データ学習', command=lambda: show_selection(a,b))
47
+ button = Button(root, text = 'Python/Tkinter')
89
- button1.grid(row=2, column=0, columnspan=2)
48
+ button.pack()
90
-
91
- button2 = ttk.Button(frame1, text='認証', command=lambda: show_selection(a,b))
92
- button2.grid(row=3, column=0, columnspan=2)
93
- root.mainloop()
49
+ root.mainloop()
94
50
  ```