Python | Tkinter中的文本区域和按钮

Library:

图书馆:

Tkinter

Tkinter (Tkinter)

Tkinter(Tk interface) is a Standard python library that is used to create easy, fast, and simple GUI applications.

Tkinter(Tk接口)是一个标准的python库,用于创建简单,快速和简单的GUI应用程序。

Download Tkinter:

下载Tkinter:

General Way:
pip install python-tk
Pycharm Users:
Go to the project interpreter and install tkinter from there.

In this tutorial, we will create a label and text area, and we will extract the text from the text area, and we will see the functioning of the buttons.

在本教程中,我们将创建一个标签和文本区域,并从文本区域中提取文本,然后我们将看到按钮的功能。

Tkinter功能 (Tkinter functions)

  1. Importing all the inner functions of the Tkinter: from tkinter import *

    导入Tkinter的所有内部功能 :从tkinter import *

  2. Creating Root: root=Tk(), this function will create the root window.

    创建Rootroot = Tk() ,此函数将创建根窗口。

  3. Setting Geometry: root.geometry("500x500") we can set the geometry.

    设置几何root.geometry(“ 500x500”)我们可以设置几何。

  4. Setting Title: root.title("<Set the title>") we can set the title with the help of this function

    设置标题root.title(“ <设置标题>”)我们可以借助此功能设置标题

  5. Creating Label: Label(root,text="Hello"), we can set the label with the help of this function.

    创建标签Label(root,text =“ Hello”) ,我们可以借助此功能设置标签。

  6. Creating Text areas: Input(root,textvariable=<set text variable>,width=<set width>)

    创建文本区域Input(root,textvariable = <设置文本变量>,width = <设置宽度>)

  7. Creating Buttons: Button(root,text="<Set text>",command=<set funnction>,bg=<set background color>)

    创建按钮按钮(root,text =“ <设置文本>”,command = <设置功能>,bg = <设置背景颜色>)

  8. Running Loop: root.mainloop(), without running this function we will not be able to open the window.

    运行循环root.mainloop() ,如果不运行此功能,我们将无法打开窗口。

Program:

程序:

# import the module and all specifications
from tkinter import *
# create the window and set geometry and title
root=Tk()
root.geometry("500x500")
root.title("Include Help")
# creating the commanding 
# function of the button
def get_value():
name=Text_Area.get()
# creating a new window
root2=Tk()
root2.geometry("500x500")
root2.title("Include Help")
# setting the Label in the window
label2=Label(root2,text=f"Welcome To Include Help {name}")
label2.place(x=160, y=80)
root2.mainloop()
# set the string variable
Text_Area=StringVar()
# create a label
label=Label(root,text="Enter Your Name")
# placing the label at the right position
label.place(x=190,y=80)
# creating the text area
# we will set the text variable in this
Input=Entry(root,textvariable=Text_Area,width=30)
Input.place(x=130,y=100)
# create a button
button=Button(root,text="Submit",command=get_value,bg="green")
button.place(x=180,y=130)
root.mainloop()

Output:

输出:

Python | Text Area and Button in Tkinter (Output)

This is the output, so in the above code we have done like we will take the name with the help of text area and after pressing the button, the commands of function will work and we will pop the new window where our name will get displayed.

这是输出,因此在上面的代码中我们已经完成了工作,就像我们将在文本区域的帮助下获取名称一样,在按下按钮之后,函数的命令将起作用,并且我们将弹出一个显示名称的新窗口。

翻译自: https://www.includehelp.com/python/text-area-and-button-in-tkinter.aspx

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/542905.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

python多行注释以三个英文_Python中多行注释可以包含在三对英文半角单引号('''''')或三对英文半角双引号(\\\...

Python中多行注释可以包含在三对英文半角单引号()或三对英文半角双引号(\"\"\"\"\"\")之间答&#xff1a;√变化再现除了有形式结构的需要外,还暗示了()的变化:()答&#xff1a;表现内容治疗与抢救休克首要的中心环节是答&#xff1a;积极去除病…

决心书之学习linux高级运维

我叫振鹏&#xff0c;我是一名在国企工作运维工程师&#xff0c;其实我不是一名合格运维工程师。为什么我选择一条运维工程师的道路&#xff0c;当时候入门运维工程师比开发好玩&#xff0c;好入门&#xff0c;入门条件也不需要太苛刻&#xff0c;所以就选择了一条运维工程师的…

浅谈计算机程序设计语言,探讨计算机程序设计语言教学

【文章摘要】随着社会不断的发展与进步&#xff0c;计算机作为现代先进产物的代表&#xff0c;已经很快的进入到社会中的各行各业。而程序设计作为计算机的核心内容&#xff0c;也同样引起了大家的重视&#xff0c;同时计算机程序设计也是高校开设的一门重要学科&#xff0c;为…

十六进制转八进制c++代码_如何将十六进制代码上传到微控制器?

十六进制转八进制c代码Read: 8051 Microcontroller programming using Keil Uvision IDE 阅读&#xff1a; 使用Keil Uvision IDE进行8051单片机编程 将HEX文件上传到微控制器 (Uploading a HEX file to Microcontroller) Once you have developed the hex code for the progr…

win7驱动程序未经签名可以使用吗_手把手教你解决win7系统驱动程序签名强制禁用的设置技巧...

win7系统稳定性好&#xff0c;使用者众多&#xff1b;免不了会遇到win7系统驱动程序签名强制禁用这样的问题要处理&#xff0c;太多的用户是不想看到win7系统驱动程序签名强制禁用这种情况的&#xff0c;靠别人来解决问题太被动&#xff0c;只要我们自己找到win7系统驱动程序签…

Linux下java环境及tomcat部署

1.下载JDK与Tomcat. jdk下载地址: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html tomcat下载地址: http://tomcat.apache.org/download-70.cgi2.jdk安装与配置. (1)jdk安装 rpm包: # rpm -ivh jdk-7u55-linux-x6…

kotlin 查找id_Kotlin程序查找平行四边形的区域

kotlin 查找idFormula to find area of Parallelogram: area base*height 查找平行四边形面积的公式&#xff1a; area base * height Given the value of base and height, we have to find the area of Parallelogram. 给定基础和高度的值&#xff0c;我们必须找到平行四边…

计算机等级考试真题演示,全国计算机等级考试二级真题测试(答案)四、演示文稿题-日...

四、演示文稿题请在[答题]菜单下选择[进入 ]命令&#xff0c;并按照题目要求完成下面的操作。注意&#xff1a;以下的文件必须都保存在考生文件夹下。某会计网校的刘老师正在准备有关《小企业会计准则》的培训课件&#xff0c;她的助手已搜集并整理了一份该准则的相关资料存放在…

java工程师占比_Java工资怎么样?哪个地方Java工作机会最多?

随着IT产业的发展&#xff0c;JAVA语言因其独有的特点&#xff0c;使其在各项服务器中应用程序的开发所占有一定的优势&#xff0c;随着JSP技术的发展&#xff0c;使Java语言的网络应用更为实际化、更高效快捷&#xff0c;成为IT产业常用的技术。 越来越多的企业&#xff0c;因…

Nginx主配置文件nginx.conf中文详解

第1章 nginx配置解释图解第2章 Nginx核心配置文件nginx.conf史上最细中文详解2.1 定义Nginx运行的用户和用户组2.2 nginxworker进程数&#xff0c;即处理请求的进程&#xff08;熟称负责接客的服务员&#xff09;2.3 cpu亲和力配置&#xff0c;让不同的进程使用不同的cpu2.4 全…

Windows中获取和设置系统日期时间的C程序

In this C program, we have to set, get the system’s date and time. 在此C程序中&#xff0c;我们必须设置&#xff0c;获取系统的日期和时间。 To get, set the system’s date and time, we need to include ‘dos.h’ header file. 要获取&#xff0c;设置系统的日期和…

0到100速度测试软件,【图】到底如何完成 揭晓0-100公里/小时测试_汽车江湖

经常浏览汽车网站的朋友应该对0-100公里/小时加速测试并不会感到陌生&#xff0c;几乎所有深度测试车型都会经历的考验&#xff0c;而在各个汽车官网上通常也会将这一数值标出。然而&#xff0c;这个成绩到底是如何测出的&#xff0c;或许大多数人并不十分知晓&#xff0c;接下…

【hibernate merge】session1.merge(T entity)方法的含义和update方法的区别

注意&#xff1a; MERGE语句是SQL语句的一种。在SQL Server、Oracle数据库中可用&#xff0c;MySQL、PostgreSQL中不可用。 1》session1.merge(T entity) 合并实体的方法。 2》merge的作用是&#xff1a;新new一个对象&#xff0c;如果该对象设置了ID&#xff0c;则这个对象就…

度量计算机外部传输单位,用来度量计算机外部设备传输率的是什么度量单位?...

用来度量计算机外部设备传输率的度量单位有&#xff1a;“MB/s”。MB是存储容量&#xff0c;“MB/s”是传输速率&#xff0c;“MB/s”的含义是兆字节每秒&#xff0c;是指每秒传输的字节数量。基本概念bit(位&#xff0c;又名“比特”)&#xff1a;bit的缩写是b&#xff0c;是计…

s7300plc串口通信_西门子S7-300/400串口通信模块的信息与使用

原标题&#xff1a;西门子S7-300/400串口通信模块的信息与使用1. 串行通讯模块基本信息介绍CP340/CP341/CP440/CP441-1/CP441-2模块是西门子S7-300/400系列PLC中的串行通讯模块&#xff0c;这些模块具有1个或2个(CP441-2)串行通讯接口(RS232C、20mA-TTY或RS485/422)。可以使用这…

Java LinkedList对象的clone()方法和示例

LinkedList对象clone()方法 (LinkedList Object clone() method) This method is available in package java.util.Collection and here, Collection is an interface. 该方法在java.util.Collection包中可用&#xff0c;在这里&#xff0c; Collection是一个接口。 This metho…

计算机毕业设计谢辞怎么写,毕业论文谢辞怎么写(通用8篇)

毕业论文谢辞怎么写(通用8篇)一段忙碌又充实的大学生活要即将结束&#xff0c;毕业前要通过最后的毕业论文&#xff0c;毕业论文是一种有准备、有计划、比较正规的、比较重要的检验大学学习成果的形式&#xff0c;那么你有了解过毕业论文吗&#xff1f;以下是小编为大家整理的毕…

maya如何查看资源大纲_怎样才算入门了Maya

开个坑来和大家讨论一下这个题目。首先亮明我的观点&#xff0c;我认为所谓入门 Maya&#xff0c;或者说任何一项技能或软件&#xff0c;是了解了这个软件/技能的基本操作方式。所以在我看来掌握了下面这些内容就算是入门了 Maya。认识 Maya 界面视图操作模型操作场景显示的几种…

J2EE基础之Web服务简介

J2EE基础之Web服务简介 1、什么是Web服务&#xff1f; 在人们的日常生活中&#xff0c;经常会查询网页上某城市的天气信息&#xff0c;这些信息都是动态的、实时的&#xff0c;它是专业的气象站提供的一种服务。例如&#xff0c;在网上购物时&#xff0c;通常采用网上支付的方式…

c# uri.host_C#| Uri.CheckHostName()方法与示例

c# uri.hostUri.CheckHostName()方法 (Uri.CheckHostName() Method) Uri.CheckHostName() method is a static method that returns the object of UriHostNameType enum than we need to compare returned enum object with UriHostNameType.Dns. If both are equal then the …