質問編集履歴

7

修正

2016/09/21 08:29

投稿

anmitu
anmitu

スコア37

test CHANGED
File without changes
test CHANGED
@@ -1,6 +1,6 @@
1
1
  ###前提・実現したいこと
2
2
 
3
- TkinterでGUIを作っています。Labelウィジェットを使用しカウントダウンを表示するウィンドウを作成したいのですが、作成したウィンドウにカウントされずにPythonシェルでのみカウントダウンが表示されてしまいます。。。
3
+ TkinterでGUIを作っています。選択ウィンドウで選択後選択ウィンドウを破棄、新しいウィンドウを作成してLabelウィジェットを使用しカウントダウンを表示するウィンドウを作成したいのですが、作成したウィンドウにカウントされずにPythonシェルでのみカウントダウンが表示されてしまいます。。。
4
4
 
5
5
 
6
6
 
@@ -12,7 +12,9 @@
12
12
 
13
13
  ###発生している問題・エラーメッセージ
14
14
 
15
+ ・選択ウィンドウと共にカウントダウンウィンドウも一緒に表示されてしまう。
16
+
15
- 作成したカウントダウンウィンドウ内に数字が表示されない。
17
+ 作成したカウントダウンウィンドウ内に数字が表示されない。
16
18
 
17
19
 
18
20
 
@@ -22,18 +24,6 @@
22
24
 
23
25
  def countdown(count):
24
26
 
25
-
26
-
27
- LABEL1 = tk.Label(base1, text=count).pack()
28
-
29
- print(type(base0))
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
27
  while (count>0):
38
28
 
39
29
  print(count)
@@ -41,8 +31,6 @@
41
31
  count = count -1
42
32
 
43
33
  time.sleep(1)
44
-
45
-
46
34
 
47
35
  label['text'] = count
48
36
 
@@ -72,41 +60,13 @@
72
60
 
73
61
 
74
62
 
75
-
76
-
77
- base0 = tk.Tk()
78
-
79
- base0.geometry("400x150")
63
+ base0 = tk.Tk() ###ここで選択ウィンドウを作成
80
64
 
81
65
 
82
66
 
83
-
84
-
85
- Radio_Value = tk.IntVar()
86
-
87
- Radio_Value.set(1)
88
-
89
-
90
-
91
- Shutdown_Option = {0:'Force Shutdown', 1:'Restart', 2:'Save'}
92
-
93
- RADIOBUTTON1 = tk.Radiobutton(base0,text = Shutdown_Option[0],variable=Radio_Value,value=0).pack()
94
-
95
- BUTTON1 = tk.Button(base0, text='Decision', command= lambda: countdown(5)).pack()
96
-
97
-
98
-
99
-
100
-
101
- base1 = tk.Tk()
102
-
103
- base1.geometry("200x200")
67
+ base1 = tk.Tk() ###ここでカウントダウンウィンドウを作成
104
-
105
-
106
68
 
107
69
  label = tk.Label(base1)
108
-
109
- label.place(x=90, y=70)
110
70
 
111
71
  '''
112
72
 

6

  修正

2016/09/21 08:29

投稿

anmitu
anmitu

スコア37

test CHANGED
File without changes
test CHANGED
@@ -11,8 +11,6 @@
11
11
 
12
12
 
13
13
  ###発生している問題・エラーメッセージ
14
-
15
- ・エラーメッセージ
16
14
 
17
15
  作成したカウントダウンウィンドウ内に数字が表示されない。
18
16
 

5

修正

2016/09/21 08:08

投稿

anmitu
anmitu

スコア37

test CHANGED
File without changes
test CHANGED
@@ -20,7 +20,7 @@
20
20
 
21
21
  ###該当のソースコード
22
22
 
23
- """
23
+ '''
24
24
 
25
25
  def countdown(count):
26
26
 
@@ -92,12 +92,6 @@
92
92
 
93
93
  Shutdown_Option = {0:'Force Shutdown', 1:'Restart', 2:'Save'}
94
94
 
95
-
96
-
97
-
98
-
99
-
100
-
101
95
  RADIOBUTTON1 = tk.Radiobutton(base0,text = Shutdown_Option[0],variable=Radio_Value,value=0).pack()
102
96
 
103
97
  BUTTON1 = tk.Button(base0, text='Decision', command= lambda: countdown(5)).pack()
@@ -116,7 +110,7 @@
116
110
 
117
111
  label.place(x=90, y=70)
118
112
 
119
- """
113
+ '''
120
114
 
121
115
 
122
116
 

4

修正

2016/09/21 08:07

投稿

anmitu
anmitu

スコア37

test CHANGED
File without changes
test CHANGED
@@ -20,15 +20,19 @@
20
20
 
21
21
  ###該当のソースコード
22
22
 
23
+ """
24
+
25
+ def countdown(count):
26
+
27
+
28
+
29
+ LABEL1 = tk.Label(base1, text=count).pack()
30
+
31
+ print(type(base0))
23
32
 
24
33
 
25
34
 
26
35
 
27
- def countdown(count):
28
-
29
- LABEL1 = tk.Label(base1, text=count).pack()
30
-
31
- print(type(base0))
32
36
 
33
37
 
34
38
 
@@ -42,9 +46,9 @@
42
46
 
43
47
 
44
48
 
45
- # change text in label
49
+ label['text'] = count
46
50
 
47
- label['text'] = count
51
+
48
52
 
49
53
 
50
54
 
@@ -112,6 +116,8 @@
112
116
 
113
117
  label.place(x=90, y=70)
114
118
 
119
+ """
120
+
115
121
 
116
122
 
117
123
 

3

修正

2016/09/21 08:06

投稿

anmitu
anmitu

スコア37

test CHANGED
File without changes
test CHANGED
@@ -14,7 +14,7 @@
14
14
 
15
15
  ・エラーメッセージ
16
16
 
17
- UnboundLocalError: local variable 'LABEL1' referenced before assignment
17
+ 作成したカウントダウンウィンドウ内に数字が表示されない。
18
18
 
19
19
 
20
20
 
@@ -22,7 +22,15 @@
22
22
 
23
23
 
24
24
 
25
+
26
+
25
27
  def countdown(count):
28
+
29
+ LABEL1 = tk.Label(base1, text=count).pack()
30
+
31
+ print(type(base0))
32
+
33
+
26
34
 
27
35
  while (count>0):
28
36
 
@@ -32,19 +40,21 @@
32
40
 
33
41
  time.sleep(1)
34
42
 
35
-
36
43
 
44
+
45
+ # change text in label
46
+
37
- label['text'] = count
47
+ label['text'] = count
38
48
 
39
49
 
40
50
 
41
51
  if count > 0:
42
52
 
43
- LABEL1 = tk.Label(text=label).pack()
53
+ LABEL1.configure(text=label)
44
54
 
45
55
  print(LABEL1)
46
56
 
47
-
57
+
48
58
 
49
59
  if count == 0:
50
60
 
@@ -62,11 +72,55 @@
62
72
 
63
73
 
64
74
 
75
+ base0 = tk.Tk()
76
+
77
+ base0.geometry("400x150")
78
+
79
+
80
+
81
+
82
+
83
+ Radio_Value = tk.IntVar()
84
+
85
+ Radio_Value.set(1)
86
+
87
+
88
+
89
+ Shutdown_Option = {0:'Force Shutdown', 1:'Restart', 2:'Save'}
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+ RADIOBUTTON1 = tk.Radiobutton(base0,text = Shutdown_Option[0],variable=Radio_Value,value=0).pack()
98
+
99
+ BUTTON1 = tk.Button(base0, text='Decision', command= lambda: countdown(5)).pack()
100
+
101
+
102
+
103
+
104
+
105
+ base1 = tk.Tk()
106
+
107
+ base1.geometry("200x200")
108
+
109
+
110
+
111
+ label = tk.Label(base1)
112
+
113
+ label.place(x=90, y=70)
114
+
115
+
116
+
117
+
118
+
65
119
  ###試したこと
66
120
 
67
121
  リスト型のデータをGUIで表示させる方法をたくさん検索しましたがどこもヒットしませんでした。。。
68
122
 
69
- Labelウィジェットのtextを動かすことができませんでした。。。
123
+ Labelウィジェットのtextを作成したウィンドウ内で動かすことができませんでした。。。
70
124
 
71
125
 
72
126
 

2

Python

2016/09/21 08:02

投稿

anmitu
anmitu

スコア37

test CHANGED
@@ -1 +1 @@
1
- Tkinterでカウントダウンウィンドウを作成したい
1
+ Python Tkinterでカウントダウンウィンドウを作成したい
test CHANGED
File without changes

1

初心者

2016/09/20 06:52

投稿

anmitu
anmitu

スコア37

test CHANGED
File without changes
test CHANGED
File without changes