tkinter无法打开窗口的问题(Python + tkinter模块)



我不明白我的代码出了什么问题-它有我需要的一切,应该执行得很好。

没有错误产生,所以我认为这是一个逻辑错误,但我不知道如何修复它。

如果你能帮助我,我将不胜感激。

from tkinter import *
from tkinter import ttk
def Payment_Computation(self):

def Getting_Payment_in_Monthly():

def __init__(self):

您错过了oop程序的一些重要部分:

from tkinter import *
from tkinter import ttk
class MainApplication():   # create class
def __init__(self):
# method code
def Payment_Computation(self):
# method code

def Getting_Payment_in_Monthly(self, Amount_Loan, mon_rate_interest, no_of_yrs):
# method code
if __name__ == "__main__":
MainApplication()    # Instantiate class

您需要将代码放在一个类中。然后需要像上面的例子那样实例化这个类。

阅读更多关于面向对象程序结构的最佳方式来构建一个更好的应用程序?

您没有调用__init__()函数。请仔细检查:)

最新更新