我已经来过一段时间了,但是我没有看到这个问题。当我在DBSyncRoot类中调用addSyncPoints函数时,它告诉我它需要2个参数,但我只给出了一个。有人可以告诉我为什么吗?自变量应该是类声明本身,不是吗?
from tkinter import *
from tkinter import ttk
class DBSyncRoot(Tk):
def __init__(self):
defaultBackColor = "Black"
defaultForeColor = "White"
super(DBSyncRoot, self).__init__() # Not sure why this is required. Found it at https://www.youtube.com/watch?v=VGIK3P9gNkM
# Setting up the main form.
self.title("DBSync")
self.geometry("500x300")
self.minsize(500,300)
self.maxsize(500,300)
self.wm_iconbitmap("sync.ico") # https://icons8.com/icon/set/sync/all and converted with https://icoconvert.com
self.configure(background="black")
# The dropdown Menu
self.menuBar = Menu(self)
self.fileMenu = Menu(self.menuBar, tearoff=0)
self.helpMenu = Menu(self.menuBar, tearoff=0)
self.config(menu=self.menuBar)
self.menuBar.add_cascade(label="File", menu=self.fileMenu) # Add the top "File" menu.
self.fileMenu.add_command(label="Quit", command=self.destroy)
self.menuBar.add_cascade(label="Help", menu=self.helpMenu) # Add the top "Help" menu.
self.helpMenu.add_command(label="About")
# The combobox
self.lblSyncPoint = Label(text = "Sync Points", background=defaultBackColor, foreground = defaultForeColor)
self.combo = ttk.Combobox(self, width = 25, background=defaultBackColor, foreground=defaultForeColor)
self.lblSyncPoint.place(x=0, y=0)
self.combo.place(x = 30, y = 25)
def addSyncPoints(self, syncPoint):
self.combo["values"] += syncPoint
if __name__=="__main__":
DBSync = DBSyncRoot()
DBSyncRoot.addSyncPoints("Apple")
DBSync.mainloop()