<i id='XRrbl'><tr id='XRrbl'><dt id='XRrbl'><q id='XRrbl'><span id='XRrbl'><b id='XRrbl'><form id='XRrbl'><ins id='XRrbl'></ins><ul id='XRrbl'></ul><sub id='XRrbl'></sub></form><legend id='XRrbl'></legend><bdo id='XRrbl'><pre id='XRrbl'><center id='XRrbl'></center></pre></bdo></b><th id='XRrbl'></th></span></q></dt></tr></i><div id='XRrbl'><tfoot id='XRrbl'></tfoot><dl id='XRrbl'><fieldset id='XRrbl'></fieldset></dl></div>
<legend id='XRrbl'><style id='XRrbl'><dir id='XRrbl'><q id='XRrbl'></q></dir></style></legend>
      <tfoot id='XRrbl'></tfoot>

      <small id='XRrbl'></small><noframes id='XRrbl'>

        <bdo id='XRrbl'></bdo><ul id='XRrbl'></ul>

        如何在 tkinter、Python 3.2.5 的文本框中打印并让用

        时间:2023-09-14
      1. <tfoot id='tAwfP'></tfoot>
          <bdo id='tAwfP'></bdo><ul id='tAwfP'></ul>

          <small id='tAwfP'></small><noframes id='tAwfP'>

              <i id='tAwfP'><tr id='tAwfP'><dt id='tAwfP'><q id='tAwfP'><span id='tAwfP'><b id='tAwfP'><form id='tAwfP'><ins id='tAwfP'></ins><ul id='tAwfP'></ul><sub id='tAwfP'></sub></form><legend id='tAwfP'></legend><bdo id='tAwfP'><pre id='tAwfP'><center id='tAwfP'></center></pre></bdo></b><th id='tAwfP'></th></span></q></dt></tr></i><div id='tAwfP'><tfoot id='tAwfP'></tfoot><dl id='tAwfP'><fieldset id='tAwfP'></fieldset></dl></div>

                  <tbody id='tAwfP'></tbody>
                <legend id='tAwfP'><style id='tAwfP'><dir id='tAwfP'><q id='tAwfP'></q></dir></style></legend>

                • 本文介绍了如何在 tkinter、Python 3.2.5 的文本框中打印并让用户输入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我对 Python 完全陌生,我刚刚编写了一小段代码,用于在 python shell 中打印并请求输入.它就像一本日记,要求输入日期,然后打印该日期的条目.我希望将此调用和响应合并到 tkinter GUI 中的文本框中.我想知道如何让这段代码在文本框中而不是在 python shell 中执行.

                  I am completely new to Python, and I just wrote a short bit of code that prints and asks for input in the python shell. It works like a diary where it asks for a date and then prints the entries for that date. I was hoping to incorporate this call and response into a text box in a tkinter GUI. I am wondering how to get this bit of code to perform in the text box instead of in the python shell.

                  month = int(float(input("Month(MM): ")))
                  day = int(float(input("Day(DD): ")))
                  year = int(float(input("Year(YYYY): ")))
                  
                  print(str(month)+"/"+str(day)+"/"+str(year))
                  
                  noEntry = True
                  
                  if month == 1 and day == 2 and year == 3456:
                      noEntry = False
                      print("Text")
                  if month == 7 and day == 8 and year == 9012:
                      noEntry = False
                      print("More Text")
                  if noEntry:
                      print("No Entry Found")
                  

                  我还想避免将此代码作为外部文件调用.我想知道如何将此代码实现到 tkinter GUI 文本框中,而不是如何检索包含此代码的文件.主要是因为它是一个如此短的程序,似乎没有必要.提前感谢您的帮助!

                  I would also like to avoid calling for this code as an outside file. I want to know how to implement this code into a tkinter GUI text box, not how to retrieve a file which contains this code. Mostly because it is such a short program and it seems unnecessary. Thanks for the help in advance!

                  推荐答案

                  这是一个基本的 Tk 窗口,它将接受月、日和年的输入

                  Here is a basic Tk window that will take input for month, day and year

                  from Tkinter import *
                  
                  root = Tk()
                  
                  
                  label1 = Label( root, text="Month(MM)")
                  E1 = Entry(root, bd =5)
                  
                  label2 = Label( root, text="Day(DD)")
                  E2 = Entry(root, bd =5)
                  
                  label3 = Label( root, text="Year(YYYY)")
                  E3 = Entry(root, bd =5)
                  
                  def getDate():
                      print E1.get()
                      print E2.get()
                      print E3.get()
                  
                  submit = Button(root, text ="Submit", command = getDate)
                  
                  label1.pack()
                  E1.pack()
                  label2.pack()
                  E2.pack()
                  label3.pack()
                  E3.pack()
                  submit.pack(side =BOTTOM) 
                  root.mainloop()
                  

                  当您单击提交时,它会打印月份和年份,我相信您可以弄清楚从那里

                  when you click submit it prints the month day and year and im sure you can figure it out from there

                  编辑

                  这里是一个显示日记条目的文本框示例:

                  here is an example of a text box to display the diary entry:

                  from Tkinter import *
                  
                  root = Tk()
                  text = Text(root)
                  text.insert(INSERT, diary)
                  text.pack()
                  
                  root.mainloop()
                  

                  在本例中,diary 是日记条目字符串!

                  in this example diary is the diary entry string!

                  祝你好运:)

                  这篇关于如何在 tkinter、Python 3.2.5 的文本框中打印并让用户输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:matplotlib中换行的文本框? 下一篇:pymongo 中的快速或批量更新

                  相关文章

                  最新文章

                  <i id='5E3iA'><tr id='5E3iA'><dt id='5E3iA'><q id='5E3iA'><span id='5E3iA'><b id='5E3iA'><form id='5E3iA'><ins id='5E3iA'></ins><ul id='5E3iA'></ul><sub id='5E3iA'></sub></form><legend id='5E3iA'></legend><bdo id='5E3iA'><pre id='5E3iA'><center id='5E3iA'></center></pre></bdo></b><th id='5E3iA'></th></span></q></dt></tr></i><div id='5E3iA'><tfoot id='5E3iA'></tfoot><dl id='5E3iA'><fieldset id='5E3iA'></fieldset></dl></div>

                  <small id='5E3iA'></small><noframes id='5E3iA'>

                      • <bdo id='5E3iA'></bdo><ul id='5E3iA'></ul>

                      <tfoot id='5E3iA'></tfoot>
                    1. <legend id='5E3iA'><style id='5E3iA'><dir id='5E3iA'><q id='5E3iA'></q></dir></style></legend>