โดย Jom07 » 12/02/2018 6:18 pm
การใช้งาน Python GUI (Tkinter) :Text Widgets ( วิดเจ็ตข้อความ) เป็นเครื่องมือข้อความถูกใช้สำหรับพื้นที่ข้อความหลายบรรทัด วิดเจ็ตข้อความ Tkinter มีประสิทธิภาพและยืดหยุ่นสูงและสามารถใช้งานได้หลากหลาย แม้ว่าจุดประสงค์หลักอย่างหนึ่งก็คือการให้พื้นที่หลายบรรทัดที่เรียบง่ายเนื่องจากมักใช้ในรูปแบบเครื่องมือข้อความสามารถใช้เป็นตัวแก้ไขข้อความธรรมดาหรือแม้แต่เว็บเบราเซอร์ เช่น
ตัวอย่าง
โค้ด: เลือกทั้งหมด
from tkinter import *
root = Tk()
S = Scrollbar(root)
T = Text(root, height=4, width=50)
S.pack(side=RIGHT, fill=Y)
T.pack(side=LEFT, fill=Y)
S.config(command=T.yview)
T.config(yscrollcommand=S.set)
quote = """HAMLET: A text widget is used for multi-line text area.The Tkinter text widget is very powerful and flexible and can be used for a wide range of tasks.Though one of the main purposes is to provide simple multi-line areas, as they are often used in forms, text widgets can also be used as simple text editors or even web browsers. """
T.insert(END, quote)
mainloop( )
ผลรัน
ศึกษาจาก :
https://www.python-course.eu/tkinter_text_widget.php
การใช้งาน Python GUI (Tkinter) :Text Widgets ( วิดเจ็ตข้อความ) เป็นเครื่องมือข้อความถูกใช้สำหรับพื้นที่ข้อความหลายบรรทัด วิดเจ็ตข้อความ Tkinter มีประสิทธิภาพและยืดหยุ่นสูงและสามารถใช้งานได้หลากหลาย แม้ว่าจุดประสงค์หลักอย่างหนึ่งก็คือการให้พื้นที่หลายบรรทัดที่เรียบง่ายเนื่องจากมักใช้ในรูปแบบเครื่องมือข้อความสามารถใช้เป็นตัวแก้ไขข้อความธรรมดาหรือแม้แต่เว็บเบราเซอร์ เช่น
[b]ตัวอย่าง[/b]
[code]from tkinter import *
root = Tk()
S = Scrollbar(root)
T = Text(root, height=4, width=50)
S.pack(side=RIGHT, fill=Y)
T.pack(side=LEFT, fill=Y)
S.config(command=T.yview)
T.config(yscrollcommand=S.set)
quote = """HAMLET: A text widget is used for multi-line text area.The Tkinter text widget is very powerful and flexible and can be used for a wide range of tasks.Though one of the main purposes is to provide simple multi-line areas, as they are often used in forms, text widgets can also be used as simple text editors or even web browsers. """
T.insert(END, quote)
mainloop( )
[/code]
[b]ผลรัน[/b]
[img]http://snap.mindphp.com/index.php?view=2018Feb12_5a8174d9aad82[/img]
ศึกษาจาก :[url]https://www.python-course.eu/tkinter_text_widget.php[/url]