self.client = HUBClient(credentials) TypeError: 'str' object is not callable
时间: 2024-01-15 21:19:47 浏览: 36
这个错误是因为你将一个字符串对象当作函数来调用了。在这个错误中,你将一个字符串对象赋值给了`self.client`,然后尝试将其作为函数来调用。然而,字符串对象是不可调用的,因此会引发`TypeError`。
要解决这个问题,你需要确保`self.client`是一个可调用的函数或方法,而不是一个字符串对象。你可以检查一下你的代码,看看是否在这个地方出现了错误。
相关问题
class LoginWindow: def __init__(self, master): self.master = master self.master.title("BL 製造表單點檢系統") self.master.geometry("300x250+400+250") self.master.resizable(0, 0) self.username = tk.StringVar() self.password = tk.StringVar() tk.Label(self.master, text="賬號").grid(row=0, column=0, padx=5, pady=5) tk.Entry(self.master, textvariable=self.username).grid(row=0, column=1, padx=5, pady=5) tk.Label(self.master, text="密碼").grid(row=1, column=0, padx=5, pady=5) tk.Entry(self.master, textvariable=self.password, show="*").grid(row=1, column=1, padx=5, pady=5) tk.Button(self.master, text="確認", command=self.login).grid(row=2, column=0, columnspan=2, padx=5, pady=5) def login(self): if self.username.get() == "smt" and self.password.get() == "bl": self.master.destroy() root = tk.Tk() app = ExcelApp(root) root.mainloop() else: messagebox.showwarning("Invalid Credentials", "密碼或賬號錯誤.")將這段代碼的窗口優化得更美觀一些
class LoginWindow:
def __init__(self, master):
self.master = master
self.master.title("BL 製造表單點檢系統")
self.master.geometry("300x250+400+250")
self.master.resizable(0, 0)
self.username = tk.StringVar()
self.password = tk.StringVar()
tk.Label(self.master, text="賬號").grid(row=0, column=0, padx=5, pady=5)
tk.Entry(self.master, textvariable=self.username, width=20).grid(row=0, column=1, padx=5, pady=5)
tk.Label(self.master, text="密碼").grid(row=1, column=0, padx=5, pady=5)
tk.Entry(self.master, textvariable=self.password, show="*", width=20).grid(row=1, column=1, padx=5, pady=5)
tk.Button(self.master, text="確認", command=self.login, width=20, bg="#4CAF50", fg="white").grid(row=2, column=0, columnspan=2, padx=5, pady=5)
def login(self):
if self.username.get() == "smt" and self.password.get() == "bl":
self.master.destroy()
root = tk.Tk()
app = ExcelApp(root)
root.mainloop()
else:
messagebox.showwarning("Invalid Credentials", "密碼或賬號錯誤.")
# 更改了输入框的宽度和按钮的颜色和宽度,使界面更美观
class LoginWindow: def init(self, master): self.master = master self.master.title("BL 製造表單點檢系統") self.master.geometry("300x250+400+250") self.master.resizable(0, 0) self.username = tk.StringVar() self.password = tk.StringVar() ttk.Label(self.master, text="賬號", width=10).grid(row=2, column=0, padx=5, pady=5) ttk.Entry(self.master, textvariable=self.username, width=20).grid(row=2, column=1, columnspan=2, padx=5, pady=5) ttk.Label(self.master, text="密碼", width=10).grid(row=3, column=0, padx=5, pady=5) ttk.Entry(self.master, textvariable=self.password, show="*", width=20).grid(row=3, column=1, columnspan=2, padx=5, pady=5) style = ttk.Style() style.configure("TButton", background="#4CAF50", foreground="white", font=("Helvetica", 12), width=10) ttk.Button(self.master, text="確認", command=self.login, style="TButton").grid(row=4, column=0, columnspan=2, padx=5, pady=5) # 设置列的宽度 self.master.grid_columnconfigure(0, weight=1) self.master.grid_columnconfigure(1, weight=1) self.master.grid_columnconfigure(2, weight=1) def login(self): if self.username.get() == "smt" and self.password.get() == "bl": self.master.destroy() root = tk.Tk() app = ExcelApp(root) root.mainloop() else: messagebox.showwarning("Invalid Credentials", "密碼或賬號錯誤.")讓這個代碼的文本框與標簽修改得近一些
class LoginWindow:
def __init__(self, master):
self.master = master
self.master.title("BL 製造表單點檢系統")
self.master.geometry("300x250+400+250")
self.master.resizable(0, 0)
self.username = tk.StringVar()
self.password = tk.StringVar()
ttk.Label(self.master, text="賬號", width=10).grid(row=0, column=0, padx=5, pady=5)
ttk.Entry(self.master, textvariable=self.username, width=20).grid(row=0, column=1, columnspan=2, padx=5, pady=5)
ttk.Label(self.master, text="密碼", width=10).grid(row=1, column=0, padx=5, pady=5)
ttk.Entry(self.master, textvariable=self.password, show="*", width=20).grid(row=1, column=1, columnspan=2, padx=5, pady=5)
style = ttk.Style()
style.configure("TButton", background="#4CAF50", foreground="white", font=("Helvetica", 12), width=10)
ttk.Button(self.master, text="確認", command=self.login, style="TButton").grid(row=2, column=1, columnspan=2, padx=5, pady=5)
# 设置列的宽度
self.master.grid_columnconfigure(0, weight=1)
self.master.grid_columnconfigure(1, weight=1)
self.master.grid_columnconfigure(2, weight=1)
def login(self):
if self.username.get() == "smt" and self.password.get() == "bl":
self.master.destroy()
root = tk.Tk()
app = ExcelApp(root)
root.mainloop()
else:
messagebox.showwarning("Invalid Credentials", "密碼或賬號錯誤.")
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)