質問編集履歴
2
改訂版
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
###やりたいこと
|
1
|
+
###やりたいこと(修正後)
|
2
|
-
|
3
|
-
2つあるのですが、まず表題の件について
|
4
2
|
|
5
3
|
複数のエクセルファイルがあり、どれもA列に番号、B列にリストがあります。
|
6
4
|
|
@@ -286,8 +284,6 @@
|
|
286
284
|
|
287
285
|
コードは以上です。
|
288
286
|
|
289
|
-
そして、もう一つ、ボタンをただの四角ではなく、楕円の図にしたいのですが、ただの白い四角にしかなりません。上記のような書き方で、Buttonに図を表示し、その上にテキストを表示することはできるでしょうか??
|
290
|
-
|
291
287
|
|
292
288
|
|
293
289
|
すいませんが、よろしくお願いします。
|
1
コードの簡略化
test
CHANGED
File without changes
|
test
CHANGED
@@ -32,81 +32,39 @@
|
|
32
32
|
|
33
33
|
|
34
34
|
|
35
|
-
import openpyxl
|
36
|
-
|
37
|
-
|
35
|
+
#エクセルファイル名
|
36
|
+
|
38
|
-
|
37
|
+
file = ["a","b","c"]
|
38
|
+
|
39
|
-
|
39
|
+
report = []
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
|
44
|
-
|
45
|
-
dir = os.path.dirname(os.path.abspath(__file__))
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
#####フォルダのエクセルファイルをリスト化######
|
50
|
-
|
51
|
-
excels =glob.glob(dir + '/*.xls*') #xls,xlsxの拡張子のファイルをフルパス付リスト化
|
52
|
-
|
53
|
-
e
|
41
|
+
#reportの内容
|
54
|
-
|
55
|
-
|
42
|
+
|
56
|
-
|
57
|
-
|
43
|
+
a = ["営業","経営","人事","福利"]
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
44
|
+
|
62
|
-
|
63
|
-
|
45
|
+
b = ["社会","公民","歴史"]
|
64
|
-
|
65
|
-
|
46
|
+
|
66
|
-
|
67
|
-
tate = 0 #縦の値
|
68
|
-
|
69
|
-
seito = 0 #生徒数
|
70
|
-
|
71
|
-
seki = 0 #座席の数)
|
72
|
-
|
73
|
-
meibo =[] #名簿
|
74
|
-
|
75
|
-
num =0 #名簿の長さ
|
76
|
-
|
77
|
-
|
47
|
+
c = ["政治","経済","司法"]
|
78
|
-
|
79
|
-
wb = True
|
80
|
-
|
81
|
-
wbp = True
|
82
|
-
|
83
|
-
sheet = True
|
84
|
-
|
85
|
-
button = []
|
86
48
|
|
87
49
|
|
88
50
|
|
89
51
|
######################################################################
|
90
52
|
|
91
|
-
class CustomSpinner(Spinner):
|
53
|
+
class CustomSpinner(Spinner):
|
92
|
-
|
93
|
-
global excels_file
|
94
54
|
|
95
55
|
text = StringProperty()
|
96
56
|
|
97
|
-
values =
|
57
|
+
values = file
|
98
58
|
|
99
59
|
pass
|
100
60
|
|
101
61
|
|
102
62
|
|
103
|
-
class CustomSpinner2(Spinner):
|
63
|
+
class CustomSpinner2(Spinner):
|
104
|
-
|
105
|
-
global report
|
106
64
|
|
107
65
|
text = StringProperty()
|
108
66
|
|
109
|
-
values = report
|
67
|
+
values = report
|
110
68
|
|
111
69
|
pass
|
112
70
|
|
@@ -114,12 +72,8 @@
|
|
114
72
|
|
115
73
|
class MainScreen(Screen):
|
116
74
|
|
117
|
-
global excels_file,report
|
118
|
-
|
119
75
|
text = StringProperty()
|
120
76
|
|
121
|
-
values = excels_file
|
122
|
-
|
123
77
|
pass
|
124
78
|
|
125
79
|
|
@@ -128,91 +82,15 @@
|
|
128
82
|
|
129
83
|
def on_spinner_change(self , text ):
|
130
84
|
|
131
|
-
col = excels_file.index(text) #ボタンが何番目かを取得(横列の検索用)
|
132
|
-
|
133
|
-
self.file = excels[col]
|
134
|
-
|
135
|
-
self.excell_import(self.file)
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
#####提出物名変更時の動作#####
|
142
|
-
|
143
|
-
def on_spinner_change2(self , text ):
|
144
|
-
|
145
|
-
|
85
|
+
global report
|
146
|
-
|
147
|
-
|
86
|
+
|
148
|
-
|
149
|
-
pass
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
#####選択したエクセルから情報を取得#####
|
154
|
-
|
155
|
-
def excell_import (self ,file) :
|
156
|
-
|
157
|
-
global meibo ,myclass,yoko,tate,seito,seki,num,report,wb,wbp,sheet
|
158
|
-
|
159
|
-
wb = openpyxl.load_workbook(file ,data_only=True,read_only=False)
|
160
|
-
|
161
|
-
sheet = wb['date']
|
162
|
-
|
163
|
-
#####ファイルへのフルパス#####
|
164
|
-
|
165
|
-
wbp = os.path.normpath(file)
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
#クラスセルの値を取得
|
170
|
-
|
171
|
-
myclass = sheet.cell(1,3).value
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
####配列####
|
176
|
-
|
177
|
-
yoko = int(sheet.cell(1,5).value) #横の値を取得
|
178
|
-
|
179
|
-
tate = int(sheet.cell(2,5).value) #縦の値を取得
|
180
|
-
|
181
|
-
seito = int(sheet.cell(3,5).value) #生徒数を取得
|
182
|
-
|
183
|
-
seki = int(sheet.cell(3,6).value) #座席の数の値を取得(空白の席を含む数)
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
####名簿を取得####
|
188
|
-
|
189
|
-
meibo =[]
|
190
|
-
|
191
|
-
def get_value_list(cellr):
|
192
|
-
|
193
|
-
return([[cell.value for cell in row] for row in cellr])
|
194
|
-
|
195
|
-
meibo = get_value_list(sheet['A1:B'+ str(seki)])
|
196
|
-
|
197
|
-
num = len(meibo)
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
####初期レポート名を取得####
|
202
|
-
|
203
|
-
report
|
87
|
+
self.report = text
|
204
|
-
|
205
|
-
|
88
|
+
|
206
|
-
|
207
|
-
|
89
|
+
report = eval(self.report)
|
208
|
-
|
209
|
-
|
210
|
-
|
90
|
+
|
211
|
-
|
91
|
+
return report
|
212
|
-
|
213
|
-
|
92
|
+
|
214
|
-
|
215
|
-
|
93
|
+
|
216
94
|
|
217
95
|
|
218
96
|
|
@@ -226,8 +104,6 @@
|
|
226
104
|
|
227
105
|
screen.add_widget(MainScreen(name='Screen 1'))
|
228
106
|
|
229
|
-
|
230
|
-
|
231
107
|
self.add_widget(screen)
|
232
108
|
|
233
109
|
base=Base('main')
|
@@ -236,16 +112,6 @@
|
|
236
112
|
|
237
113
|
|
238
114
|
|
239
|
-
def refresh(self):
|
240
|
-
|
241
|
-
self.clear_widgets(screens=[self.get_screen('main')])
|
242
|
-
|
243
|
-
base=Base('main')
|
244
|
-
|
245
|
-
self.add_widget(base)
|
246
|
-
|
247
|
-
|
248
|
-
|
249
115
|
class Nav(GridLayout):
|
250
116
|
|
251
117
|
def __init__(self,sm=None):
|
@@ -256,27 +122,7 @@
|
|
256
122
|
|
257
123
|
self.cols =4
|
258
124
|
|
259
|
-
self.size_hint = (1,0.0
|
125
|
+
self.size_hint = (1,0.05)
|
260
|
-
|
261
|
-
self.add_widget(Button(text="レイアウトへ", on_release=self.change))
|
262
|
-
|
263
|
-
self.add_widget(Button(text="ファイル選択へ", on_release=self.goscreen))
|
264
|
-
|
265
|
-
self.add_widget(Label(text = ""))
|
266
|
-
|
267
|
-
self.add_widget(Button(text="Quit", on_release=self.quit))
|
268
|
-
|
269
|
-
def change(self, btn):
|
270
|
-
|
271
|
-
self.sm.current='main'
|
272
|
-
|
273
|
-
def quit(self,ins):
|
274
|
-
|
275
|
-
exit()
|
276
|
-
|
277
|
-
def goscreen(self,ins):
|
278
|
-
|
279
|
-
self.sm.current='Screen 1'
|
280
126
|
|
281
127
|
|
282
128
|
|
@@ -286,40 +132,6 @@
|
|
286
132
|
|
287
133
|
super(Base, self).__init__()
|
288
134
|
|
289
|
-
global button
|
290
|
-
|
291
|
-
options = {
|
292
|
-
|
293
|
-
"font_size" : "14sp",
|
294
|
-
|
295
|
-
"color": ( .3 , 0 , 0 , 1 ),
|
296
|
-
|
297
|
-
"background_color": ( 1 , 2.5 , 2 , 1 ),
|
298
|
-
|
299
|
-
}
|
300
|
-
|
301
|
-
self.lay=GridLayout(cols = yoko)
|
302
|
-
|
303
|
-
self.lay.spacing=[5,5]
|
304
|
-
|
305
|
-
self.name=name
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
button = [] #ボタン本体
|
310
|
-
|
311
|
-
for idx, _ in enumerate(range(seki)):
|
312
|
-
|
313
|
-
button = Button(text=f"{idx}", background_normal = 'maru.png',**options)
|
314
|
-
|
315
|
-
button.my_id = idx
|
316
|
-
|
317
|
-
self.lay.add_widget(button)
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
self.add_widget(self.lay)
|
322
|
-
|
323
135
|
|
324
136
|
|
325
137
|
class Root(BoxLayout):
|
@@ -340,27 +152,7 @@
|
|
340
152
|
|
341
153
|
self.add_widget(sm)
|
342
154
|
|
343
|
-
|
155
|
+
|
344
|
-
|
345
|
-
box.add_widget(Button(text='refresh',on_release=self.refresh))
|
346
|
-
|
347
|
-
box.add_widget(Label(text = "time"))
|
348
|
-
|
349
|
-
box.add_widget(Button(text='取消!',on_release=self.delbuttonClicked))
|
350
|
-
|
351
|
-
self.add_widget(box)
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
def refresh(self,ins):
|
356
|
-
|
357
|
-
self.sm.refresh()
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
def delbuttonClicked(self, **kwargs ):
|
362
|
-
|
363
|
-
self.text = self.ids.textinput.text
|
364
156
|
|
365
157
|
|
366
158
|
|
@@ -456,74 +248,28 @@
|
|
456
248
|
|
457
249
|
text: '選択'
|
458
250
|
|
459
|
-
#values: 'Home', 'Work', 'Other', 'Custom'
|
460
|
-
|
461
251
|
size_hint: 0.5 , 1
|
462
252
|
|
463
253
|
on_text: root.on_spinner_change2(self.text)
|
464
254
|
|
465
255
|
|
466
256
|
|
467
|
-
|
257
|
+
Widget:
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
BoxLayout:
|
262
|
+
|
263
|
+
size_hint_y: 0.7
|
264
|
+
|
265
|
+
|
468
266
|
|
469
267
|
Label:
|
470
268
|
|
471
|
-
id: label
|
269
|
+
id: label3
|
472
|
-
|
473
|
-
size_hint: 0.3 , 1
|
474
270
|
|
475
271
|
font_size: 14
|
476
272
|
|
477
|
-
text: "提出物名→"
|
478
|
-
|
479
|
-
# 追加入力欄
|
480
|
-
|
481
|
-
TextInput:
|
482
|
-
|
483
|
-
id: textinput
|
484
|
-
|
485
|
-
size_hint: 0.4, 1
|
486
|
-
|
487
|
-
#text: "新しい提出物名"
|
488
|
-
|
489
|
-
font_size: 12
|
490
|
-
|
491
|
-
multiline: False
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
# 追加ボタン
|
496
|
-
|
497
|
-
Button:
|
498
|
-
|
499
|
-
id: button2
|
500
|
-
|
501
|
-
size_hint: 0.2, 1
|
502
|
-
|
503
|
-
text: "追加!"
|
504
|
-
|
505
|
-
font_size: 12
|
506
|
-
|
507
|
-
on_press: root.add_buttonClicked() # ボタンをクリックした時にpython側の関数を呼ぶ
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
Widget:
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
BoxLayout:
|
516
|
-
|
517
|
-
size_hint_y: 0.7
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
Label:
|
522
|
-
|
523
|
-
id: label3
|
524
|
-
|
525
|
-
font_size: 14
|
526
|
-
|
527
273
|
text: "使い方\n こちらを参照 \n ①エクセルファイルを選びます。"
|
528
274
|
|
529
275
|
text_size: self.size
|