0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

残プロ 第-18回 ~tkinterでcsvを編集(したい)~

Posted at

わざわざtkinterで実装する意味とは...

tkinterで軽く実装することで,他言語で実装する際のプロトタイプとして利用できます.
学習コストも少ないので今回はtkinterでcsvの編集に挑みました(未完成).

機能紹介

表の作成・表示は第-14回で紹介しています.
実装済みの機能は

  • csv読込・表作成
  • タスク追加
  • タスク削除
  • csv書込

csv_editor.png

タスク追加

csvファイルの行数を取得し末尾に追加を行っています.entryやlabel等のいくつも用意する必要があるものは,リストに格納することで扱いやすくなります.

addingTask
tmp = []
for i in range(len(df.columns)):
	tmp.append(task_entrys[i].get())
df.loc[len(df)] = tmp

タスク削除

tree.selection()を利用することで楽に指定行を取得できます.今回はvaluesの先頭(インデックス)を利用していますがtagsを利用してもいいかもしれません.

deleteTask
for i in tree.selection():
	df = df.drop(index=tree.item(i)['values'][0])
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?