การใช้งาน Python GUI (Tkinter) :Radio Buttons (ปุ่มเรดิโอ)

ตอบกระทู้

รูปแสดงอารมณ์
:icon_plusone: :like: :plusone: :gfb: :-D :) :( :-o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angry: :baa: :biggrin:
รูปแสดงอารมณ์อื่นๆ

BBCode เปิด
[img] เปิด
[url] เปิด
[Smile icon] เปิด

กระทู้แนะนำ
   

มุมมองที่ขยายได้ กระทู้แนะนำ: การใช้งาน Python GUI (Tkinter) :Radio Buttons (ปุ่มเรดิโอ)

การใช้งาน Python GUI (Tkinter) :Radio Buttons (ปุ่มเรดิโอ)

โดย Jom07 » 08/02/2018 5:44 pm

การใช้งาน Python GUI (Tkinter) :Radio Buttons (ปุ่มเรดิโอ) เป็นการสร้างปุ่มตัวเลือกแบบเรดิโอ
ตัวอย่าง

โค้ด: เลือกทั้งหมด

import tkinter as tk

root = tk.Tk()

v = tk.IntVar()

tk.Label(root,
        text="""Choose a programming language :""",
        justify = tk.LEFT,
        padx = 20).pack()
tk.Radiobutton(root,
              text="Python",
              padx = 20,
              variable=v,
              value=1).pack(anchor=tk.W)
tk.Radiobutton(root,
              text="Perl",
              padx = 20,
              variable=v,
              value=2).pack(anchor=tk.W)
tk.Radiobutton(root,
              text="Java",
              padx = 20,
              variable=v,
              value=3).pack(anchor=tk.W)
tk.Radiobutton(root,
              text="C++",
              padx = 20,
              variable=v,
              value=4).pack(anchor=tk.W)
tk.Radiobutton(root,
              text="C",
              padx = 20,
              variable=v,
              value=5).pack(anchor=tk.W)

root.mainloop()
ผลรัน

รูปภาพ

ศึกษาจาก : https://www.python-course.eu/tkinter_radiobuttons.php

ข้างบน