Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use Python+Tkinter to realize classic tic-tac-toe chess Mini Game

Shulou Source: shulou.com Published: 2022-06-01 05:58:56 09月17日 Update

This article mainly explains "how to use Python+Tkinter to achieve classic tic-tac-toe Mini Game". The content in the article is simple and clear and easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use Python+Tkinter to achieve classic tic-tac-toe-chess Mini Game".

Demo

Introduction

First, let's introduce the GUI library Tkinter.

Main modules:

TkinterMain Tkinter module.

Tkinter.colorchooser allows the user to select a color dialog box.

Tkinter.commondialog the base class for dialogs defined by other modules in this article.

Tkinter.filedialog allows users to specify a common dialog box for files that can be opened or saved.

Tkinter.font tools that help manipulate fonts.

Tkinter.messagebox accesses the standard Tk dialog box.

Tkinter.scrolledtext has a built-in text component for the vertical scroll bar.

Tkinter.simpledialog basic dialog box and some convenient features.

Tkinter.ttkThemed widget set introduced in Tk 8.5, providing modern alternatives for many of the classic widgets in the main tkinter module.

Let's get familiar with a little demo.

From tkinter import * from tkinter import ttkroot = Tk () frm = ttk.Frame (root, padding=10) frm.grid () ttk.Label (frm, text= "Hello World!") .grid (column=0, row=0) ttk.Button (frm, text= "Quit", command=root.destroy) .grid (column=1, row=0) root.mainloop () official documentation

No matter how good I am, I might as well take a look at the document. If you don't understand anything, you can leave a message below. Hey, the portal.

Tkinter.messagebox

In fact, I just used this part directly. I don't know much about it. I'll tell you what I often use.

Tags: Dialog boxes dialogs Mini Game classics tic-tac-toe messages learning information content that is files documents modules users convenience functions basics fonts official tools Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft vpn MySQL NVidia Linux