我使用devoloping一个桌面应用程序的Tkinter。设置字体引发异常。
tmp.py
def main(root):
frame = Frame(root.master)
font = Font(size=25 , weight="bold")
label = Label(frame , font=font , text="tuna fish")
label.pack()
frame.pack()
Run Code Online (Sandbox Code Playgroud)
这是驱动程序main.py
main.py
if __name__ == "__main__":
root = start.baseApp()
root.Menu_Customer.add_command(label="New customer", command=lambda: tmp.main(root=root))
root.master.mainloop()
Run Code Online (Sandbox Code Playgroud)
基础应用程序
我创建了名为Customer 的根窗口和菜单栏,并在main.py.
我tmp.py说例外
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib64/python3.5/tkinter/__init__.py", line 1559, in __call__
return self.func(*args)
File "main.py", line 10, in <lambda>
root.Menu_Customer.add_command(label="New customer", command=lambda: tmp.main(root=root))
File "/home/engle/Documents/Project/CleanMaster/tmp.py", line 6, …Run Code Online (Sandbox Code Playgroud) 我想访问views.py 中的post 方法数据。我正在遵循将纯 html 用于表单而不是Django 表单类的过程。我在 Django 中尝试了MultiValueDictKeyError解决方案 ,但仍然无法正常工作。帮帮我
索引.html
<form action="{% url "Sample:print" %}" method="post">
{% csrf_token %}
<input type="text" placeholder="enter anything" id="TB_sample"/><br>
<input type="submit" value="submit">
</form>
Run Code Online (Sandbox Code Playgroud)
视图.py
def print(request):
value=request.POST['TB_sample']
# value = request.REQUEST.get(request,'TB_sample')
# value = request.POST.get('TB_sample','')
print(value)
return render(request , 'static/Sample/print.html',{"data":"I want to pass here 'Value'"})
Run Code Online (Sandbox Code Playgroud)
我尝试了所有注释类型。我仍然有很多错误。这些解决方案都不起作用。