説明](51ca5dd8473ef84a27fab3b617877188.jpeg)](4f7fdc5aee61037a420dd515c9e5f119.jpeg)
python3
1import tkinter as tk
2import tkinter.ttk as ttk
3import pandas as pd
4import numpy as np
5
6win = tk.Tk()
7id_var = tk.StringVar()
8name_var = tk.StringVar()
9age_var = tk.IntVar()
10gen_var = tk.StringVar()
11hei_var = tk.IntVar()
12wei_var = tk.IntVar()
13site_var = tk.StringVar()
14x_var = tk.IntVar()
15y_var = tk.IntVar()
16z_var = tk.IntVar()
17
18#originalデータフレーム
19list_pt = [["0000001", "山田太郎", 50,"男性",170,70,"prostate",0.9,0.5,0.2],
20 ["0000001", "山田太郎", 50,"男性",170,70,"prostate",0.6,0.4,0.1],
21 ["1111111", "佐藤花子", 45,"女性",162,48,"breast",0.1,0.2,0.1]]
22columns = ["ID","名前","年齢","性別","身長 (cm)","体重 (kg)","部位","x","y","z"]
23df = pd.DataFrame(data=list_pt, columns=columns)
24df
25print(df)
26
27class Application(tk.Frame):
28 def __init__(self,master):
29 super().__init__(master)
30 master.geometry("650x380")
31 master.title("Daily Image Guidance Manager")
32
33 self.window = []
34 self.user = []
35
36 self.button = tk.Button(master,text='Daily IGRT', height=5, width=20, command=self.buttonClick1)
37 self.button.grid(row=0, column=0, padx=40, pady=60)
38
39 self.button = tk.Button(master,text='新規患者登録/修正', height=5, width=20, command=self.buttonClick2)
40 self.button.grid(row=0, column=1, padx=20, pady=60)
41
42 def buttonClick1(self):
43 self.window.append(tk.Toplevel())
44 self.user.append(User1(self.window[len(self.window)-1],len(self.window)))
45
46 def buttonClick2(self):
47 self.window.append(tk.Toplevel())
48 self.user.append(User2(self.window[len(self.window)-1],len(self.window)))
49
50
51class User1(tk.Frame):
52 def __init__(self,master,num):
53 super().__init__(master)
54 master.geometry("700x450")
55 master.title(u"Daily IGRT")
56
57 self.listbutton = tk.Button(master, text='治療中リスト', height=2, width=10)
58 self.listbutton.place(x=20, y=20)
59
60 self.regbutton = tk.Button(master, text='登録', height=2, width=10)
61 self.regbutton.place(x=20, y=80)
62
63 self.id_text = tk.Label(master, text="ID")
64 self.id_text.place(x=270,y=20)
65 self.id_entry = tk.Entry(master, width=15)
66 self.id_entry.place(x=310,y=20)
67
68 self.name_text = tk.Label(master, text="名前")
69 self.name_text.place(x=420,y=20)
70 self.name_entry = tk.Entry(master, width=15)
71 self.name_entry.place(x=460,y=20)
72
73 self.site_text = tk.Label(master, text="部位")
74 self.site_text.place(x=120,y=60)
75 self.site_entry = tk.Entry(master, textvariable=site_var, width=15)
76 self.site_entry.place(x=160,y=60)
77
78 self.x_text = tk.Label(master, text="x")
79 self.x_text.place(x=120,y=100)
80 self.x_entry = tk.Entry(master, textvariable=x_var, width=7)
81 self.x_entry.place(x=140,y=100)
82
83 self.y_text = tk.Label(master, text="y")
84 self.y_text.place(x=210,y=100)
85 self.y_entry = tk.Entry(master, textvariable=y_var, width=7)
86 self.y_entry.place(x=230,y=100)
87
88 self.z_text = tk.Label(master, text="z")
89 self.z_text.place(x=300,y=100)
90 self.z_entry = tk.Entry(master, textvariable=z_var, width=7)
91 self.z_entry.place(x=320,y=100)
92
93
94class User2(tk.Frame):
95 def __init__(self,master,num):
96 super().__init__(master)
97 master.geometry("670x520")
98 master.title(u"新規患者登録/修正")
99
100 self.id_text = tk.Label(master, text="ID")
101 self.id_text.place(x=20,y=20)
102 self.id_entry = tk.Entry(master, textvariable=id_var, width=18)
103 self.id_entry.place(x=80,y=20)
104
105 self.name_text = tk.Label(master, text="名前")
106 self.name_text.place(x=20,y=60)
107 self.name_entry = tk.Entry(master, textvariable=name_var, width=18)
108 self.name_entry.place(x=80,y=60)
109
110 self.age_text = tk.Label(master, text="年齢")
111 self.age_text.place(x=20,y=100)
112 self.age_entry = tk.Entry(master, textvariable=age_var, width=18)
113 self.age_entry.place(x=80,y=100)
114
115 self.gen_text = tk.Label(master, text="性別")
116 self.gen_text.place(x=20,y=140)
117 self.gen_entry = tk.Entry(master, textvariable=gen_var, width=18)
118 self.gen_entry.place(x=80,y=140)
119
120 self.hei_text = tk.Label(master, text="身長 (cm)")
121 self.hei_text.place(x=20,y=180)
122 self.hei_entry = tk.Entry(master, textvariable=hei_var, width=18)
123 self.hei_entry.place(x=80,y=180)
124
125 self.wei_text = tk.Label(master, text="体重 (kg)")
126 self.wei_text.place(x=20,y=220)
127 self.wei_entry = tk.Entry(master, textvariable=wei_var, width=18)
128 self.wei_entry.place(x=80,y=220)
129
130 self.button = tk.Button(master, text='保存', command=MakeList, height=2, width=10)
131 self.button.place(x=200, y=300)
132
133#originalデータフレームを新たに得られた値を追加し更新したい
134#pt_datを返してdfの更新を外で記述したほうが良いのか?
135#その際はどこに書くのかがわかりません
136def MakeList():
137 idnum = id_var.get()
138 name = name_var.get()
139 age = age_var.get()
140 gen = gen_var.get()
141 hei = hei_var.get()
142 wei = wei_var.get()
143 site = site_var.get()
144 x = x_var.get()
145 y = y_var.get()
146 z = z_var.get()
147 pt_dat = pd.Series(["idnum","name", age, "gen", hei, wei, "site", x, y, z], index =["ID","名前","年齢","性別","身長 (cm)","体重 (kg)","部位","x","y","z"])
148 df = df.append(pt_dat, ignore_index=True )
149 print(df)
150
151def main():
152 win = tk.Tk()
153 app = Application(win)
154 app.mainloop()
155
156
157if __name__ == '__main__':
158 main()
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/03/26 23:49 編集
2020/03/27 05:44
2020/03/31 08:14
2020/03/31 08:21
2020/03/31 21:05
2020/04/01 03:00
2020/04/07 20:12
2020/04/07 20:15
2020/04/07 23:03 編集
2020/04/07 22:53 編集
2020/04/07 22:52
2020/04/08 19:31