【问题标题】:Getting an error while inserting values from the tkinter GUi to the database将值从 tkinter GUI 插入数据库时​​出错
【发布时间】:2019-03-30 22:07:54
【问题描述】:

将值从 tkinter GUI 插入 sqlite3 数据库时出错。 接受用户的输入

【问题讨论】:

  • 欢迎来到 Stack Overflow!请提供您的代码。
  • 您在使用Entry() 小部件吗?如果你这样做,那么我有答案。否则,请务必告诉您正在使用哪些小部件,您的代码也会有所帮助。谢谢!!
  • 是的,我正在使用条目小部件!
  • 您需要显示一些显示此问题的代码,并显示您遇到的实际错误。
  • @RishiJaiswar 您在获取文本框中的内容时遇到问题吗?

标签: python-3.x tkinter sqlite tkinter-entry


【解决方案1】:

从您的问题的语气来看,您似乎无法访问文本框中的内容。

答案是.get() 方法。这基本上允许您访问文本框中的内容。

这是一个简单的代码:

from tkinter import *
window = Tk()
window.title("Example")
window.geometry("500x500")
window.configure(bg = "sky blue")
e = Entry(window, bg = "blue", fg = "orange")
e.pack()
def com1():
    acess = e.get()
    print(acess)
button1 = Button(window, text = "enter", command = com1)
button1.pack()

e.get()Entry 小部件中的内容。

您将它保存在一个变量中,然后将该变量用于您想要的任何内容。

希望对你有帮助!!!

【讨论】:

  • 你在吗??
猜你喜欢
  • 2019-10-11
  • 2011-01-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-10-25
相关资源
最近更新 更多