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

Issue with tkinter being unable to open a window (Python + tkinter module)

我不明白我的代码有什么问题 - 它有我需要的一切,应该可以正常执行。

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

我们将不胜感激。

from tkinter import *
from tkinter import ttk

def Payment_Computation(self):

 
def Getting_Payment_in_Monthly():


def __init__(self):

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

您遗漏了 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

您需要将代码放在 class 中。然后,您需要实例化 class,如上例所示。

阅读 Best way to structure a tkinter application?

中有关 oop 程序结构的更多信息