Try using Tkinter

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.

Sample code

# -*- 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()

Execution example

1a72ae3c.png

reference

Recommended Posts

Try using Tkinter
Try using Python's Tkinter
Try using docker-py
Try using cookiecutter
Try using PDFMiner
Try using geopandas
Try using Selenium
Try using scipy
Try using pandas.DataFrame
Try using django-swiftbrowser
Try using matplotlib
Try using tf.metrics
Try using PyODE
Try using virtualenv (virtualenvwrapper)
[Azure] Try using Azure Functions
Try using virtualenv now
Try using W & B
Try using Django templates.html
[Kaggle] Try using LGBM
Try using Python's feedparser.
Try using Tweepy [Python2.7]
Try using Pytorch's collate_fn
Environment variables when using Tkinter
Try using PythonTex with Texpad.
[Python] Try using Tkinter's canvas
Try using Jupyter's Docker image
Try using scikit-learn (1) --K-means clustering
Try function optimization using Hyperopt
Try using matplotlib with PyCharm
Try using Azure Logic Apps
Try using Kubernetes Client -Python-
[Kaggle] Try using xg boost
Try using the Twitter API
Try using OpenCV on Windows
Try using Jupyter Notebook dynamically
Try using AWS SageMaker Studio
Try tweeting automatically using Selenium.
Try using SQLAlchemy + MySQL (Part 1)
Try using the Twitter API
Try using SQLAlchemy + MySQL (Part 2)
Try using Django's template feature
Try using the PeeringDB 2.0 API
Try using Pelican's draft feature
Try using pytest-Overview and Samples-
Try using folium with anaconda
Try to make PC setting change software using TKinter (beginner)
Try using Janus gateway's Admin API
[Statistics] [R] Try using quantile regression.
Try using Spyder included in Anaconda
Try using design patterns (exporter edition)
Try using Pillow on iPython (Part 1)
Create a python GUI using tkinter
Try using Pillow on iPython (Part 2)
Try using Pleasant's API (python / FastAPI)
Try using LevelDB in Python (plyvel)
Try using pynag to configure Nagios
Try using PyCharm's remote debugging feature
Try using ArUco on Raspberry Pi
Try using cheap LiDAR (Camsense X1)
[Sakura rental server] Try using flask.
Try using Pillow on iPython (Part 3)