回答編集履歴
2
answer
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
comment3 = 'test3'
|
|
13
13
|
|
|
14
14
|
html = f'''
|
|
15
|
+
<h3 style="text-align: center;">箇条書き</h3>
|
|
15
16
|
<ul>
|
|
16
17
|
<li>test1</li> <!-- comment 1 -->
|
|
17
18
|
<li>test2</li> <!-- comment 2 -->
|
|
@@ -41,4 +42,4 @@
|
|
|
41
42
|
html_text.pack()
|
|
42
43
|
root.mainloop()
|
|
43
44
|
```
|
|
44
|
-

|
1
answer
CHANGED
|
@@ -1,32 +1,44 @@
|
|
|
1
|
-
箇条書きということであれば [tkhtmlview
|
|
1
|
+
箇条書きということであれば [tkhtmlview](https://pypi.org/project/tkhtmlview/) を利用する方法も考えられます。
|
|
2
2
|
|
|
3
3
|
```python
|
|
4
4
|
import tkinter as tk
|
|
5
|
-
from tkhtmlview import
|
|
5
|
+
from tkhtmlview import HTMLScrolledText
|
|
6
6
|
|
|
7
7
|
root = tk.Tk()
|
|
8
8
|
|
|
9
|
-
comment1 = 'test1'
|
|
10
|
-
comment2 = 'test2'
|
|
11
9
|
text = 'あいうえお'
|
|
12
10
|
comment3 = None
|
|
13
11
|
if 'か' in text:
|
|
14
12
|
comment3 = 'test3'
|
|
15
|
-
comment4 = 'test4'
|
|
16
|
-
comment5 = '<li style="color: red">コメント5</li>'
|
|
17
13
|
|
|
18
14
|
html = f'''
|
|
19
15
|
<ul>
|
|
16
|
+
<li>test1</li> <!-- comment 1 -->
|
|
17
|
+
<li>test2</li> <!-- comment 2 -->
|
|
20
|
-
<
|
|
18
|
+
<!-- comment 3 -->
|
|
21
|
-
<li>{comment2}</li>
|
|
22
|
-
{"<li>comment3</li>" if comment3 is not None else ""}
|
|
19
|
+
{"<li>"+comment3+"</li>" if comment3 is not None else ""}
|
|
23
|
-
<li>
|
|
20
|
+
<li>test4</li> <!-- comment 4 -->
|
|
21
|
+
<li style="color: red">テスト5</li> <!-- comment 5 -->
|
|
22
|
+
<li>test6</li> <!-- comment 6 -->
|
|
23
|
+
<li>test7</li> <!-- comment 7 -->
|
|
24
|
+
<li>test8</li> <!-- comment 8 -->
|
|
25
|
+
<li>test9</li> <!-- comment 9 -->
|
|
26
|
+
<li>test10</li> <!-- comment 10 -->
|
|
27
|
+
<li>test11</li> <!-- comment 11 -->
|
|
28
|
+
<li>test12</li> <!-- comment 12 -->
|
|
29
|
+
<li>test13</li> <!-- comment 13 -->
|
|
30
|
+
<li>test14</li> <!-- comment 14 -->
|
|
24
|
-
|
|
31
|
+
<li>test15</li> <!-- comment 15 -->
|
|
32
|
+
<li>test16</li> <!-- comment 16 -->
|
|
33
|
+
<li>test17</li> <!-- comment 17 -->
|
|
34
|
+
<li>test18</li> <!-- comment 18 -->
|
|
35
|
+
<li>test19</li> <!-- comment 19 -->
|
|
36
|
+
<li>test20</li> <!-- comment 20 -->
|
|
25
37
|
</ul>
|
|
26
38
|
'''
|
|
27
39
|
|
|
28
|
-
|
|
40
|
+
html_text = HTMLScrolledText(root, html=html, background='#D9D9D9', width=30, height=10)
|
|
29
|
-
|
|
41
|
+
html_text.pack()
|
|
30
42
|
root.mainloop()
|
|
31
43
|
```
|
|
32
|
-

|