質問編集履歴

1

コードの変更

2017/12/19 08:38

投稿

gymgym
gymgym

スコア97

test CHANGED
File without changes
test CHANGED
@@ -84,104 +84,16 @@
84
84
 
85
85
  ```Python
86
86
 
87
- def show_selection(x, y):
88
-
89
- for i in lb.curselection():
90
-
91
- if i == 0:
92
-
93
- one = sum(x)
94
-
95
- zero = len(x) - sum(x)
87
+ from tkinter import *
96
-
97
- if one < zero:
98
-
99
- label.config(text="OK")
100
-
101
- elif i == 1:
102
-
103
- one = sum(y)
104
-
105
- zero = len(y) - sum(y)
106
-
107
- if one > zero:
108
-
109
- label.config(text="BAD")
110
88
 
111
89
 
112
90
 
113
- if __name__ == '__main__':
91
+ root = Tk()
114
92
 
115
- root = Tk()
93
+ button = Button(root, text = 'Python/Tkinter')
116
94
 
117
- root.title('Scrollbar 1')
95
+ button.pack()
118
96
 
119
-
120
-
121
- # Frame
122
-
123
- frame1 = ttk.Frame(root, padding=10)
124
-
125
- frame1.grid()
126
-
127
-
128
-
129
- # Listbox
130
-
131
- currencies = ("A", "B")
132
-
133
- v1 = StringVar(value=currencies)
134
-
135
- lb = Listbox(frame1, listvariable=v1,height=3)
136
-
137
- lb.grid(row=0, column=0)
138
-
139
-
140
-
141
- # Label (新規追加)
142
-
143
- label = Label(frame1, width=18)
144
-
145
- label.grid(row=1, column=0, columnspan=2)
146
-
147
-
148
-
149
- # Scrollbar
150
-
151
- scrollbar = ttk.Scrollbar(
152
-
153
- frame1,
154
-
155
- orient=VERTICAL,
156
-
157
- command=lb.yview)
158
-
159
- lb['yscrollcommand'] = scrollbar.set
160
-
161
- scrollbar.grid(row=0,column=1,sticky=(N,S))
162
-
163
-
164
-
165
- a = [0,0,0,0,1,1,1]
166
-
167
- b = [1,1,1,1,1,0,0]
168
-
169
-
170
-
171
-
172
-
173
- #Button
174
-
175
- button1 = ttk.Button(frame1, text='データ学習', command=lambda: show_selection(a,b))
176
-
177
- button1.grid(row=2, column=0, columnspan=2)
178
-
179
-
180
-
181
- button2 = ttk.Button(frame1, text='認証', command=lambda: show_selection(a,b))
182
-
183
- button2.grid(row=3, column=0, columnspan=2)
184
-
185
- root.mainloop()
97
+ root.mainloop()
186
98
 
187
99
  ```