Hey, I'm trying to open a sub-window on top of my main window for a specific time, then close it. I'm going the
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python37\lib\tkinter\__init__.py", line 1705, in __call__
return self.func(*args)
File "c:\users\mark\downloads\practice_gui_2.py", line 83, in scan_pressed
self.sub_win = tkinter.Toplevel(self, root)
File "C:\Python37\lib\tkinter\__init__.py", line 2334, in __init__
if wmkey in cnf:
File "C:\Python37\lib\tkinter\__init__.py", line 1489, in cget
return self.tk.call(self._w, 'cget', '-' + key)
TypeError: can only concatenate str (not "int") to str
I have no clue where to even begin on that one. Google results turn up things not related to tkinter.
malonn
Well, I figured out why the window wouldn't spawn. The fix was to remove the master from the call to
tkinter.Toplevel
route for this and plan on destroying it with subwindow.destroy()
. But I keep getting an error that I have no idea what to do with. Code:class MainWindow(ttk.Frame): def __init__(self, parent): ttk.Frame.__init__(self) ttk.Frame.grid(self, column=0, row=0, sticky=('N', 'E', 'S', 'W')) ttk.Frame.columnconfigure(self, 0, weight=1) ttk.Frame.rowconfigure(self, 0, weight=1) self.mem_exists = tkinter.StringVar() self.reg_scan = tkinter.StringVar() self.widgets() def widgets(self): self.mem_labl1 = ttk.Label(self, text='Memory Dumps:') self.mem_labl1.grid(column=0, row=0) self.mem_labl2 = ttk.Label(self, textvariable=self.mem_exists) self.mem_labl2.grid(column=0, row=1) self.mem_buton = ttk.Button(self, text='Delete', command=self.delete_dmps) self.mem_buton.grid(column=0, row=2) self.dmp_separ = ttk.Separator(self, orient='horizontal') self.dmp_separ.grid(column=0, row=3, rowspan=1, sticky=('EW')) self.scn_labl1 = ttk.Label(self, text='Scan for Dumps') self.scn_labl1.grid(column=0, row=4) self.scn_buton = ttk.Button(self, text='Scan', command=self.scan_pressed) self.scn_buton.grid(column=0, row=5) self.vrt_separ = ttk.Separator(self, orient='vertical') self.vrt_separ.grid(column=1, row=0, rowspan=6, sticky=('NS')) self.reg_labl1 = ttk.Label(self, text='Unneeded Keys') self.reg_labl1.grid(column=2, row=0) self.reg_labl2 = ttk.Label(self, textvariable=self.reg_scan) self.reg_labl2.grid(column=2, row=1) self.reg_buton = ttk.Button(self, text='Delete', command=self.delete_keys) self.reg_buton.grid(column=2, row=2) ...... def scan_pressed(self): self.sub_win = tkinter.Toplevel(self, root) <----- ERROR HERE self.write_dumps() size = self.get_size() self.mem_exists.set(f'{size} KB of memory dumps found!')When I press the button (scn_buton) I want it to spawn a little window with a label that says "scanning..." (or something of that nature), but it gives me this error:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python37\lib\tkinter\__init__.py", line 1705, in __call__
return self.func(*args)
File "c:\users\mark\downloads\practice_gui_2.py", line 83, in scan_pressed
self.sub_win = tkinter.Toplevel(self, root)
File "C:\Python37\lib\tkinter\__init__.py", line 2334, in __init__
if wmkey in cnf:
File "C:\Python37\lib\tkinter\__init__.py", line 1489, in cget
return self.tk.call(self._w, 'cget', '-' + key)
TypeError: can only concatenate str (not "int") to str
I have no clue where to even begin on that one. Google results turn up things not related to tkinter.
malonn
Well, I figured out why the window wouldn't spawn. The fix was to remove the master from the call to
Toplevel()
like soself.sub_win = tkinter.Toplevel(self)but the window doesn't spawn until after the rest of the code for that method ("scan_pressed") is run. Why is that? The code calls
os.walk
which takes a while to complete and I want the second window to block it while it happens.