tkinter Canvas Frameの枠線が消えない。
解決したいこと
frameを削除した後に枠線が残ります。
canvasの枠線だと思うのですが消えません。
よろしくお願いします。
該当するソースコード
from tkinter import *
from tkinter import Tk
import pprint
class TkApp(Frame):
def __init__(self, master=None):
super().__init__(master)
self.pack()
self.master = master
# self.master.resizable(width=0, height=0)
self.window = []
# main frame
self.frame = Frame(self.master, bd=3)
self.frame.pack()
# left frame
self.left_frame_container = Frame(self.frame)
self.left_frame_container.pack(side='left')
self.left_frame = LabelFrame(self.left_frame_container, text='Config')
self.left_frame.pack(fill='both')
self.data_entry_frame = LabelFrame(self.left_frame_container, text='Data to collect')
self.data_entry_frame.pack(fil='both')
self.user_frame = LabelFrame(self.left_frame, text='user')
self.user_frame.grid(row=1, column=0, rowspan=2, columnspan=2, sticky='nsew', padx=20, pady=20)
# right frame
self.canvas = Canvas(self.frame, width=400, height=400, bd=0, highlightthickness=0)
self.canvas.pack(side='left')
scrollbar = Scrollbar(self.frame, orient=VERTICAL, command=self.canvas.yview)
scrollbar.pack(side='right', fill='y', anchor='e')
self.canvas["yscrollcommand"] = scrollbar.set
self.canvas.yview_moveto(0)
self.right_frame = LabelFrame(self.canvas, text='data')
self.canvas.create_window((0, 0), window=self.right_frame, anchor=NW, width=self.canvas.cget('width'))
self.padx = 10
self.pady = 10
self.create_widget()
self.user()
self.data_info()
self.submit_data = []
self.widget = []
def create_widget(self):
blank = Label(self.left_frame, text='blank')
blank.grid(row=0, column=0, padx=self.padx, pady=self.pady)
self.num_blank = Spinbox(self.left_frame, state='readonly', from_=0, to=100, increment=1)
self.num_blank.grid(row=0, column=1, padx=self.padx, pady=self.pady)
def user(self):
self.user_maki = Checkbutton(self.user_frame, text='ma', width=8, height=3)
self.user_maki.grid(row=0, column=0, padx=self.padx, pady=self.pady)
self.user_tuki = Checkbutton(self.user_frame, text='tu', width=8, height=3)
self.user_tuki.grid(row=0, column=1, padx=self.padx, pady=self.pady)
self.user_zoe = Checkbutton(self.user_frame, text='zo', width=8, height=3)
self.user_zoe.grid(row=0, column=2, padx=self.padx, pady=self.pady)
def data_info(self):
data_name_label = Label(self.data_entry_frame, text='data name')
data_name_label.grid(row=0, column=0, padx=self.padx, pady=self.pady)
self.data_name = Entry(self.data_entry_frame)
self.data_name.grid(row=0, column=1)
num_data_label = Label(self.data_entry_frame, text='num data')
num_data_label.grid(row=1, column=0, padx=self.padx, pady=self.pady)
self.num_data = Spinbox(self.data_entry_frame, state='readonly', from_=0, to=100, increment=1)
self.num_data.grid(row=1, column=1, padx=self.padx, pady=self.pady)
# submit btn
btn = Button(self.data_entry_frame, command=self.click_btn, text='OK', width=10, height=2)
btn.grid(row=2, column=0, columnspan=2, padx=self.padx, pady=self.pady)
def click_btn(self):
frame = Frame(self.right_frame, width=20, height=10, highlightthickness=0)
frame.pack(side='top', pady=10)
data_name = Label(frame, text=self.data_name.get(), width=10)
data_name.pack(side='left', fill='both')
num_data = Label(frame, text=self.num_data.get(), width=5)
num_data.pack(side='left')
# -------------------ここです!
del_btn = Button(frame, text='delete', command=lambda: [w.destroy() for w in frame.winfo_children()] and frame.destroy(), width=5, height=1)
# -------------------
del_btn.pack(side='right')
# scroll 調整
print(self.right_frame.winfo_children())
self.canvas.config(scrollregion=(0, 0, 0, len(self.right_frame.winfo_children())*50))
def get_data(self):
for w in self.widget:
c = w.winfo_children()
for cc in c:
print(cc.cget('text'))
root = Tk()
app = TkApp(master=root)
app.mainloop()
自分で試したこと
highlightthickness=0
をcanvasに設定しましたがダメでした。
0