[PYTHON] Introduction to Tkinter 1: Introduction

0. Introduction

This article records the learning of Tkinter 8.6, the latest version of the GUI library (Tkinter).

1. Working environment

It is assumed that Pycharm and Python have been installed. What is the installation status?

2.Reference

3. Display HelloWorld!

3.1 Display an empty window

The following code will bring up the base window. It instantiates tkinter with your favorite name and runs it in .mainloop.

code


#tkinter library call
import tkinter as tk

#Instantiation of tkinter
pop = tk.Tk()

#
#Widget addition area
#

#.mainloop()Will display a window with.
pop.mainloop()

Result of execution image.png

3.2 Add a label

Widgets are parts such as buttons and labels. Let's write a process to display Hello World !! in the widget addition area.

code


import tkinter as tk

pop = tk.Tk()

#Hello World in the pop window!!I want to place the text.
label = tk.Label(pop,text="Hello World!!")
#.pack is a function that places objects.
label.pack()

pop.mainloop()

Result of execution image.png

Was it displayed correctly? The contents so far are the basis of tkinter. From the next time, I will explain the widget and introduce the properties in several chapters.

Recommended Posts

Introduction to Tkinter 1: Introduction
Introduction to MQTT (Introduction)
Introduction to Scrapy (1)
Introduction to Scrapy (3)
Introduction to Supervisor
Introduction to PyQt
Introduction to Scrapy (2)
[Linux] Introduction to Linux
Introduction to Scrapy (4)
Introduction to discord.py (2)
Introduction to discord.py
Introduction to Lightning pytorch
Introduction to Web Scraping
Introduction to Nonparametric Bayes
Introduction to EV3 / MicroPython
Introduction to Python language
Introduction to TensorFlow-Image Recognition
Introduction to OpenCV (python)-(2)
Introduction to PyQt4 Part 1
Introduction to Dependency Injection
Introduction to Private Chainer
Introduction to machine learning
AOJ Introduction to Programming Topic # 1, Topic # 2, Topic # 3, Topic # 4
Introduction to electronic paper modules
A quick introduction to pytest-mock
Introduction to dictionary lookup algorithm
Introduction to Monte Carlo Method
[Learning memorandum] Introduction to vim
Introduction to PyTorch (1) Automatic differentiation
opencv-python Introduction to image processing
Introduction to Python Django (2) Win
Introduction to Cython Writing [Notes]
An introduction to private TensorFlow
Kubernetes Scheduler Introduction to Homebrew
An introduction to machine learning
[Introduction to cx_Oracle] Overview of cx_Oracle
A super introduction to Linux
Introduction
AOJ Introduction to Programming Topic # 7, Topic # 8
[Introduction to pytorch-lightning] First Lit ♬
How to update Python Tkinter to 8.6
Introduction to Anomaly Detection 1 Basics
Introduction to RDB with sqlalchemy Ⅰ
[Introduction to Systre] Fibonacci Retracement ♬
Introduction to Nonlinear Optimization (I)
Introduction to serial communication [Python]
AOJ Introduction to Programming Topic # 5, Topic # 6
Introduction to Deep Learning ~ Learning Rules ~
[Introduction to Python] <list> [edit: 2020/02/22]
Introduction to Python (Python version APG4b)
An introduction to Python Programming
[Introduction to cx_Oracle] (8th) cx_Oracle 8.0 release
Introduction to discord.py (3) Using voice
An introduction to Bayesian optimization
Deep Reinforcement Learning 1 Introduction to Reinforcement Learning
Super introduction to machine learning
Introduction to Ansible Part ③'Inventory'
Series: Introduction to cx_Oracle Contents
How to rewrite Tkinter labels
[Introduction] How to use open3d
Introduction to Python For, While