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

แชร์ความรู้ภาษา Python ไพทอน การเขียนโปรแกรมภาษาไพทอน

Moderator: mindphp, ผู้ดูแลกระดาน

ภาพประจำตัวสมาชิก
Jom07
PHP Super Hero Member
PHP Super Hero Member
โพสต์: 514
ลงทะเบียนเมื่อ: 08/01/2018 9:56 am

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

โพสต์ที่ยังไม่ได้อ่าน โดย Jom07 »

การใช้งาน 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
รูปภาพ
  • Similar Topics
    ตอบกลับ
    แสดง
    โพสต์ล่าสุด

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 45