Try using Tkinter, which allows you to write GUI programs in Python.
Tkinter
A library that allows you to create GUI applications in Python. Since it is included in Python as standard, it can be used without any special installation.
# -*- coding : utf-8 -*-
u"""
GUI programming sample
"""
import tkinter
from tkinter import messagebox
def button_push(event):
u"What happens when the button is clicked"
edit_box.delete(0, tkinter.END)
def func_check(event):
u"Check the status of the check box and display it"
global val1
global val2
global val3
text = ""
if val1.get() == True:
text += "Item 1 is checked\n"
else:
text += "Item 1 is unchecked\n"
if val2.get() == True:
text += "Item 2 is checked\n"
else:
text += "Item 2 is unchecked\n"
if val3.get() == True:
text += "Item 3 is checked\n"
else:
text += "Item 3 is unchecked\n"
messagebox.showinfo("info", text)
if __name__ == "__main__":
root = tkinter.Tk()
root.title(u"GUI sample")
root.geometry("400x300")
#Text box
edit_box = tkinter.Entry(width=50)
edit_box.insert(tkinter.END, "Sample string")
edit_box.pack()
#button
button = tkinter.Button(text=u"Erase", width=30)
button.bind("<Button-1>", button_push)
button.pack()
# button.place(x=105, y=30)
#Checkbox
val1 = tkinter.BooleanVar()
val2 = tkinter.BooleanVar()
val3 = tkinter.BooleanVar()
val1.set(False)
val2.set(True)
val3.set(False)
checkbox1 = tkinter.Checkbutton(text=u"Check 1", variable=val1)
checkbox1.pack()
checkbox2 = tkinter.Checkbutton(text=u"Check 2", variable=val2)
checkbox2.pack()
checkbox3 = tkinter.Checkbutton(text=u"Check 3", variable=val3)
checkbox3.pack()
#button
button2 = tkinter.Button(root, text=u"Get checkbox", width=50)
button2.bind("<Button-1>", func_check)
button2.pack()
tkinter.mainloop()
Recommended Posts