在主窗口文件中,我定义了这样的代码:
from tkinter import *
import configureUAHChange as cA
class TracingInterface(Frame):
def __init__(self, master):
super().__init__()
root.minsize(width=700, height=520)
root.maxsize(width=700, height=520)
Frame.__init__(self, master)
Grid.config(self)
self.TracingMethod()
self.logDetails()
self.otherFunctionInterface()
# Default window state
self._configureUA_window = None
def UAconfig_window(self):
if self._configureUA_window is not None:
return
self._configureUA_window =cA.ConfigureUAinterface(self)
def closeUA(self):
# Destroy the 2nd and reset the value to None
if self._configureUA_window is not None:
self._configureUA_window.destroy()
self._configureUA_window = None
此行用于按钮单击命令:
self.configUAButton = Button(self.radioframe, text="Configuration",command=self.UAconfig_window)
接下来,这就是我在第二个python文件中定义函数的方法
class ConfigureUAinterface(Toplevel):
def __init__(self, master):
super().__init__(master)
master.minsize(width=700, height=520)
master.maxsize(width=700, height=520)
Frame.__init__(self, master)
Grid.config(self)
master.title("UA Configuration")
#Pre define combobox value in case suggestion
self.value_of_combo='Identity Theft'
#Run the all Function
self.DateSelection()
self.finish()
self.UASuggestion()
self.ConfigurationUA()
self.suggestionCombo()
请告诉我如何修改我的代码以解决上述错误。
这是主窗口的完整编码:https://drive.google.com/open?id=1KKgYPbGMNNWBfPVazHfcM_NSFlv5eEpKg3_uXsvQsNE
这是第二个窗口的完整编码:https://drive.google.com/open?id=1LuqJXIUrDMLfuz8gnZynZXUN6-SvFAyw9c-puJ3REPQ
答案 0 :(得分:1)
1)我认为在root
的{{1}}函数中有一些master
应该是__init__
。
2)您传递给TracingInterface
的主人不是一个窗口,而是ConfigureUAinterface
这是一个框架,没有TracingInterface
,minsize
和{{1方法。
3)我不知道为什么在maxsize
继承title
时使用Frame.__init__(self, master)
。
编辑: 主窗口的更改:
ConfigureUAinterface
第二个窗口的更改:
Toplevel
我没有修改代码中的任何其他内容,当我尝试时,它有效。