質問編集履歴

2

修正

2020/08/12 10:56

投稿

skysoul
skysoul

スコア111

test CHANGED
File without changes
test CHANGED
@@ -211,3 +211,41 @@
211
211
 
212
212
 
213
213
  これの76行目の文です。このreturn文をmake_calendar関数の呼んだところにreturnしたいと思ってます
214
+
215
+
216
+
217
+ 追記
218
+
219
+ 「def make_date_button_push(i):
220
+
221
+
222
+
223
+ でリターンさせたら、ボタンのcommandに行きますよね?」
224
+
225
+
226
+
227
+
228
+
229
+ ```
230
+
231
+ def make_date_button_push(i):
232
+
233
+ def date_button_push():
234
+
235
+ global check
236
+
237
+ click_day = month_first_day + i-1
238
+
239
+ print(year,month,click_day)
240
+
241
+
242
+
243
+ check = 1
244
+
245
+
246
+
247
+ return year,month,click_day
248
+
249
+ ```
250
+
251
+ です

1

端折りました

2020/08/12 10:56

投稿

skysoul
skysoul

スコア111

test CHANGED
File without changes
test CHANGED
@@ -72,219 +72,83 @@
72
72
 
73
73
 
74
74
 
75
+
76
+
75
- def before_month(year,month):
77
+ def window_open():
76
-
77
- month = month - 1
78
+
78
-
79
- if month == 0:
80
-
81
- month = 12
82
-
83
- year = year - 1
79
+ global calendar_tk
84
-
85
-
86
-
80
+
87
- month_first_day = datetime.date(year,month,1).isoweekday()
81
+ global window_open_flag
88
82
 
89
83
 
90
84
 
85
+ calendar_tk = tkinter.Toplevel()
86
+
87
+ calendar_tk.geometry('413x245+%d+%d' % (center_x - 207,center_y - 122))
88
+
89
+ calendar_tk.title('かれんだー')
90
+
91
+ calendar_tk.configure(bg='#FFFFB3')
92
+
93
+ calendar_tk.resizable(width=0, height=0)
94
+
95
+ calendar_tk.focus_set()
96
+
97
+ calendar_tk.grab_set()
98
+
99
+
100
+
101
+ window_open_flag = 1
102
+
103
+
104
+
105
+
106
+
107
+
108
+
109
+ def make_calendar(year, month, month_first_day):
110
+
111
+ global month_lbl
112
+
113
+ global before_month_button
114
+
115
+ global after_month_button
116
+
117
+ global lbl
118
+
119
+ global button
120
+
121
+ global day_list
122
+
123
+
124
+
125
+
126
+
91
- if month_first_day == 7:
127
+ if window_open_flag == 0:
128
+
92
-
129
+ window_open()
130
+
131
+
132
+
133
+
134
+
135
+ en_month_lbl = tkinter.Label(calendar_tk,text=monthlist[month-1], bg='#FFFFB3')
136
+
93
- month_first_day = 0
137
+ en_month_lbl.grid(row=2, column=3)
138
+
139
+
140
+
141
+ sat_color = '#0000FF'
142
+
143
+ sun_color = '#FF0000'
94
144
 
95
145
 
96
146
 
97
147
  for i in range(len(day_list)):
98
148
 
99
- lbl[i].destroy()
100
-
101
-
102
-
103
-
104
-
105
- # all dest.
106
-
107
- month_lbl.destroy()
108
-
109
-
110
-
111
- before_month_button.destroy()
112
-
113
-
114
-
115
- after_month_button.destroy()
116
-
117
- for i in range(len(button)):
118
-
119
- button[i].destroy()
120
-
121
-
122
-
123
- make_calendar(year, month, month_first_day)
124
-
125
-
126
-
127
- def after_month(year,month):
128
-
129
- month = month + 1
130
-
131
- if month == 13:
132
-
133
- month = 1
134
-
135
- year = year + 1
136
-
137
-
138
-
139
- month_first_day = datetime.date(year,month,1).isoweekday()
140
-
141
-
142
-
143
- if month_first_day == 7:
144
-
145
- month_first_day = 0
146
-
147
-
148
-
149
- # all dest.
150
-
151
- month_lbl.destroy()
152
-
153
-
154
-
155
- before_month_button.destroy()
156
-
157
-
158
-
159
- after_month_button.destroy()
160
-
161
-
162
-
163
- for i in range(len(button)):
164
-
165
- button[i].destroy()
166
-
167
-
168
-
169
- make_calendar(year, month, month_first_day)
170
-
171
-
172
-
173
- def window_open():
174
-
175
- global calendar_tk
176
-
177
- global window_open_flag
178
-
179
-
180
-
181
- calendar_tk = tkinter.Toplevel()
182
-
183
- calendar_tk.geometry('413x245+%d+%d' % (center_x - 207,center_y - 122))
184
-
185
- calendar_tk.title('かれんだー')
186
-
187
- calendar_tk.configure(bg='#FFFFB3')
188
-
189
- calendar_tk.resizable(width=0, height=0)
190
-
191
- calendar_tk.focus_set()
192
-
193
- calendar_tk.grab_set()
194
-
195
-
196
-
197
- window_open_flag = 1
198
-
199
-
200
-
201
-
202
-
203
-
204
-
205
- def make_calendar(year, month, month_first_day):
206
-
207
- global month_lbl
208
-
209
- global before_month_button
210
-
211
- global after_month_button
212
-
213
- global lbl
214
-
215
- global button
216
-
217
- global day_list
218
-
219
-
220
-
221
-
222
-
223
- if window_open_flag == 0:
224
-
225
- window_open()
226
-
227
-
228
-
229
- day_list = ['sun','mon','tue','wed','thu','fri','sat']
230
-
231
- monthlist = ['Jan','Feb','Mar','Apr','May','June','July','Aug','Sept','Oct','Nov','Dec']
232
-
233
- lbl=[0]*7
234
-
235
- year_lbl = tkinter.Label(calendar_tk, text=str(year) + '年', bg='#FFFFB3')
236
-
237
- year_lbl.grid(row=0, column=3)
238
-
239
- month_lbl = tkinter.Label(calendar_tk,text= str(month)+ '月', bg='#FFFFB3')
240
-
241
- month_lbl.grid(row=1, column=3)
242
-
243
-
244
-
245
- before_month_button = tkinter.Button(calendar_tk,text='←前の月', command=lambda:before_month(year,month))
246
-
247
- before_month_button.grid(row=1, column=2)
248
-
249
-
250
-
251
- after_month_button = tkinter.Button(calendar_tk,text='次の月→', command=lambda:after_month(year,month))
252
-
253
- after_month_button.grid(row=1, column=4)
254
-
255
-
256
-
257
- en_month_lbl = tkinter.Label(calendar_tk,text=monthlist[month-1], bg='#FFFFB3')
258
-
259
- en_month_lbl.grid(row=2, column=3)
260
-
261
-
262
-
263
- sat_color = '#0000FF'
264
-
265
- sun_color = '#FF0000'
266
-
267
-
268
-
269
- for i in range(len(day_list)):
270
-
271
- if i == 0:
272
-
273
- lbl[i] = tkinter.Label(calendar_tk, text=day_list[i], fg=sun_color, bg='#FFFFB3')
149
+ lbl[i] = tkinter.Label(calendar_tk, text=day_list[i], bg='#FFFFB3')
274
-
150
+
275
- lbl[i].grid(row=3, column=i)
151
+ lbl[i].grid(row=3, column=i)
276
-
277
- elif i == 6:
278
-
279
- lbl[i] = tkinter.Label(calendar_tk, text=day_list[i], fg=sat_color, bg='#FFFFB3')
280
-
281
- lbl[i].grid(row=3, column=i)
282
-
283
- else:
284
-
285
- lbl[i] = tkinter.Label(calendar_tk, text=day_list[i], bg='#FFFFB3')
286
-
287
- lbl[i].grid(row=3, column=i)
288
152
 
289
153
 
290
154
 
@@ -346,4 +210,4 @@
346
210
 
347
211
 
348
212
 
349
- これの146行目の文です。このreturn文をmake_calendar関数の呼んだところにreturnしたいと思ってます
213
+ これの76行目の文です。このreturn文をmake_calendar関数の呼んだところにreturnしたいと思ってます