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.pswp.cn/news/542905.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/542905.shtml
英文地址,請注明出處:http://en.pswp.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 …