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:

输出:

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

Python | Tkinter中的文本区域和按钮相关推荐

  1. opencv python3 文本区域识别_使用等高线从图像中提取文本区域 - Opencv,Python

    我一直在使用python中的opencv开发名片的OCR项目 . 直到现在,我已经能够裁剪图像卡 . 我试图使用轮廓检测裁剪图像中的文本区域 . (即,拍摄Canny图像,从这些边缘找到轮廓并将它们扩 ...

  2. tkinter回调异常_处理python tkinter中的异常

    我在 Python Tkinter中编写了一个应用程序.我最近注意到,对于其中一个操作,如果该操作失败,它有时会关闭(不会给出任何错误).我写了一个小程序来说明问题: – import os from ...

  3. python tkinter进度条_在python tkinter中Canvas实现进度条显示的方法

    如下所示: from tkinter import * import time #更新进度条函数 def change_schedule(now_schedule,all_schedule): can ...

  4. python tkinter中的锚点(anchor)问题

    tkinter中anchor参数 (注意,参数的英文都是小写) 字母 方位 n 北 s 南 w 西 e 东 center 中心 nw 西北 ne 东北 sw 西南 se 东南 from tkinter ...

  5. python tkinter pack 同一行_用python tkinter中的一行连接2个复选按钮

    我有一个程序在画布中放置复选按钮,当选项(另一个复选按钮)被选中时.我有另一个选项(另一个复选按钮)来画线.为了画线,首先我应该选择checkbutton"draw a line" ...

  6. python tkinter text改变文本字体颜色_如何更改Tkinter中文本的颜色?

    在Tkinter图形用户界面中,我无法确定如何更改文本的颜色.我试着让Label1变成红色,Label2变成蓝色,Label3变成棕色,Label4变成黄色,但我似乎想不出来.提前谢谢:)import ...

  7. python tkinter text改变文本字体颜色_Python3 tkinter基础 Button text,fg 按钮上显示的文字 文字的颜色...

    ? python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 conda : 4.5.11 type setting : Markdo ...

  8. python tkinter 循环显示文本_Python简易音乐播放器

    上一篇介绍了点阵字展现动态歌词,后续的思路有一条是添加图形界面.这两天搜了下tkinter图形界面的帖子,做了个简单的播放器界面,听首<盗将行>感受下效果吧 Python图形界面 图形界面 ...

  9. python tkinter button_Python连载60-Tkinter布局、按钮以及属性详解

    一.Tkinter​ 1.组件的大致使用步骤 (1)创建总面板 (2)创建面板上的各种组件: i.指定组件的父组件,即依附关系:ii.利用相应的属性对组件进行设置:iii.给组件安排布局. (3)同步 ...

最新文章

  1. 软件工程 之 动物世界
  2. 08-01-json-loggin-模块
  3. (0095)iOS开发之本地文件预览的三种方法(3)
  4. python爬虫百度百科-python每日一题:网络爬虫百度百科
  5. 支付宝支付回调异常_支付宝崩了是怎么回事 支付宝崩了部分用户使用异常现已恢复...
  6. 多级缓存中的一级缓存全网流量分发CDN
  7. QML 信号和处理程序事件系统
  8. 微软Build 2017第一天:值得开发者关注的热点
  9. sudo gedit出现No protocol specified
  10. c语言fopen_s的用法,fopen和fopen_s用法的比较
  11. C++ 手动实现简单的智能指针类
  12. JavaScript 是如何成为一门严肃的编程语言的
  13. 我的世界java版如何装mod_我的世界考古“初代贝爷生存”?开局3滴血,还没进游戏就要自闭了...
  14. Android okHttp网络请求之缓存控制Cache-Control
  15. python数字图像处理(12):基本图形的绘制
  16. Android好用的桌面小工具,Android桌面小工具Widget功能实现
  17. 大象装进冰箱要几步?Python 来解答
  18. 如何用PS(photoshop)给照片加文字
  19. 【Python自学笔记】学习Python控制键盘鼠标的库 pyautogui
  20. Elasticsearch简易入门讲解

热门文章

  1. c语言2048项目报告,c语言----项目_小游戏2048
  2. 浏览器是指在用户计算机上,自考《网页设计与制作》测试题及答案
  3. inur new.php id,Cmsez(随易)全站系统 0day
  4. java 两个页面传递数据,请问Cookie怎么在两个页面间传递数据?
  5. 电脑打字手指正确姿势_正确的弹琴手型,应该是怎样的?
  6. 笔吧评测室所用测试软件,这是一台假游戏本:笔吧评测室 GIGABYTE 技嘉 Aero15 Classic-XA 游戏本 测评...
  7. 华为4g模块 linux驱动程序,定制Android之4G-LTE模块驱动
  8. java 按位_Java中的按位运算
  9. Linux添加新硬盘-挂载硬盘,设置开机自动挂载 解决/home 空间不足问题
  10. go实现数组切片洗牌函数Shuffle