回答編集履歴

5

関数名変更

2020/02/05 04:32

投稿

shiracamus
shiracamus

スコア5406

test CHANGED
@@ -20,7 +20,7 @@
20
20
 
21
21
 
22
22
 
23
- def repeat():
23
+ def action():
24
24
 
25
25
  callback()
26
26
 
@@ -34,7 +34,7 @@
34
34
 
35
35
  delta = target - now
36
36
 
37
- win.after(int(delta.total_seconds() * 1000 + 1), repeat)
37
+ win.after(int(delta.total_seconds() * 1000 + 1), action)
38
38
 
39
39
 
40
40
 

4

デバッグprint削除

2020/02/05 04:32

投稿

shiracamus
shiracamus

スコア5406

test CHANGED
@@ -34,8 +34,6 @@
34
34
 
35
35
  delta = target - now
36
36
 
37
- print(delta)
38
-
39
37
  win.after(int(delta.total_seconds() * 1000 + 1), repeat)
40
38
 
41
39
 

3

日付をまたぐときのバグ修正

2020/02/05 04:24

投稿

shiracamus
shiracamus

スコア5406

test CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  ```python
6
6
 
7
- from datetime import datetime
7
+ from datetime import datetime, timedelta
8
8
 
9
9
  import tkinter as tk
10
10
 
@@ -30,11 +30,11 @@
30
30
 
31
31
  now = datetime.now()
32
32
 
33
- target = datetime(year=now.year, month=now.month, day=now.day,
33
+ target = (now + timedelta(hours=1)).replace(minute=0, second=0, microsecond=0)
34
-
35
- hour=now.hour + 1, minute=0, second=0)
36
34
 
37
35
  delta = target - now
36
+
37
+ print(delta)
38
38
 
39
39
  win.after(int(delta.total_seconds() * 1000 + 1), repeat)
40
40
 

2

コード修正

2020/02/05 04:21

投稿

shiracamus
shiracamus

スコア5406

test CHANGED
@@ -36,7 +36,7 @@
36
36
 
37
37
  delta = target - now
38
38
 
39
- win.after(int(delta.total_seconds() + 1) * 1000, repeat)
39
+ win.after(int(delta.total_seconds() * 1000 + 1), repeat)
40
40
 
41
41
 
42
42
 

1

関数名変更

2020/02/05 04:05

投稿

shiracamus
shiracamus

スコア5406

test CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
 
18
18
 
19
- def after(win, callback):
19
+ def each_hour(win, callback):
20
20
 
21
21
 
22
22
 
@@ -24,7 +24,7 @@
24
24
 
25
25
  callback()
26
26
 
27
- after(win, callback)
27
+ each_hour(win, callback)
28
28
 
29
29
 
30
30
 
@@ -44,7 +44,7 @@
44
44
 
45
45
  win = tk.Tk()
46
46
 
47
- after(win, func)
47
+ each_hour(win, func)
48
48
 
49
49
  win.mainloop()
50
50