実現したいこと
環境 : Python3.6.1
TkinterのTreeviewを用いてキーワードを表示させようとしています。
キーワードは
"Project scheduling",
"Genetic algorithm",
"Multi-objective optimization",
"Software metrics",
"Software testing",
"Optimization",
"Hardware",
"Software",
"Architectural design",
"Project management",
"The development efficiency",
"Open source software",
"System development",
"Data analysis",
"Petri net",
"Work breakdown structure",
"Project-based learning",
"Web application",
"Image processing",
"Programming",
"Network",
"Scientific modelling",
"Embedded system"
の23個となっています。
発生している問題・エラーメッセージ
文字列が途中で切れてしまい、全文が表示されないエラーが起きています。
キーワードをご覧いただくとわかります通り、文字列にはスペースが含まれています。-(ハイフン)でつながれている部分は表示されるのですが、スペースで区切られている文字列はスペースの手前までしか表示されません。
例として、
元の文字列 -> 表示される文字列
"Project scheduling" -> "Project"
"Petri net" -> "Petri"
"Project-based learning" -> ""Project-based"
エラー文などは表示されません。また、ツリーの横幅を広げてみても表示は変わりませんでした。
該当のソースコード
for文の中でif文を用いているのは、1行ごとに背景色を変更するためです。
ご助力いただけましたら幸いです。
Python
1 2import tkinter as tk 3import tkinter.ttk as ttk 4 5keyList = ["Project scheduling", 6"Genetic algorithm", 7"Multi-objective optimization", 8"Software metrics", 9"Software testing", 10"Optimization", 11"Hardware", 12"Software", 13"Architectural design", 14"Project management", 15"The development efficiency", 16"Open source software", 17"System development", 18"Data analysis", 19"Petri net", 20"Work breakdown structure", 21"Project-based learning", 22"Web application", 23"Image processing", 24"Programming", 25"Network", 26"Scientific modelling", 27"Embedded system"] 28 29root = tk.Tk() 30tree = ttk.Treeview(root) 31 32 tree["columns"] = (1) 33 tree["show"] = "headings" 34 tree.column(1, width="400") 35 tree.heading(1, text="Keyword") 36 37 i = 1 38 39 if len(keyList) == 0: 40 return 41 else: 42 for item in keyList: 43 44 tree.insert("", "end", tags=i, values=item) 45 if i & 1: 46 tree.tag_configure(i, background="#CCFFFF") 47 i += 1 48 49 tree.pack()
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/01/16 14:05