Skip to main content

Chinese

tkchart

A Python library for creating live-updating line charts in Tkinter.

PyPI version

Downloads Downloads last 6 month Downloads/Month Downloads/Week

License: MIT


🎥 Watch the Main Demo Video on GitHub


✨ Features

Feature Description
⚡ Live Updates Stream and display real-time data continuously
📉 Multiple Lines Plot several lines on the same chart for easy comparison
🎨 Color Customization Tailor colors to match your app's design
🔤 Font Customization Adjust text fonts for better readability
📐 Dimension Control Resize charts to fit any layout
🎛️ Granular Config Fine-grained control via configure_*() methods (v2.2.0+)

📋 See what's new in the latest release →


📦 Installation

pip install tkchart
import tkchart

🚀 Quick Start

import tkinter as tk
import tkchart
import random
import threading
import time

root = tk.Tk()

# 1. Create the chart
chart = tkchart.LineChart(
    master=root,
    x_axis_values=("a", "b", "c", "d", "e", "f"),
    y_axis_values=(100, 900)
)
chart.place(x=10, y=10)

# 2. Create a line
line = tkchart.Line(master=chart)

# 3. Stream data in a background thread
def loop():
    while True:
        chart.show_data(line=line, data=[random.choice(range(100, 900))])
        time.sleep(1)

threading.Thread(target=loop, daemon=True).start()
root.mainloop()

🎬 Live Examples

1 — Simple

▶️ View Simple Demo Video on GitHub

View code
import tkinter as tk
import tkchart
import random
import threading
import time

root = tk.Tk()
root.configure(bg="#0d1117")
root.geometry("720x430+200+200")

line_chart = tkchart.LineChart(
    master=root,
    x_axis_values=("01-01", "01-02", "01-03", "01-04", "01-05", "01-06", "01-07", "01-08", "01-09", "01-10"),
    y_axis_values=(0, 1000)
)
line_chart.pack(pady=15)

line = tkchart.Line(master=line_chart)

def display_data():
    while True:
        line_chart.show_data(line=line, data=[random.choice(range(0, 1000))])
        time.sleep(0.5)

threading.Thread(target=display_data, daemon=True).start()
root.mainloop()

2 — Styled & Filled Line

▶️ View Styled & Filled Line Demo Video on GitHub

View code
import tkinter as tk
import tkchart
import random
import threading
import time

root = tk.Tk()
root.configure(bg="#0d1117")
root.geometry("720x430+200+200")

line_chart = tkchart.LineChart(
    master=root,
    x_axis_values=("01-01", "01-02", "01-03", "01-04", "01-05", "01-06", "01-07", "01-08", "01-09", "01-10"),
    y_axis_values=(0, 1000),
    y_axis_label_count=10,
)
line_chart.pack(pady=15)

line = tkchart.Line(
    master=line_chart,
    size=2,
    fill="enabled"
)

def display_data():
    while True:
        line_chart.show_data(line=line, data=[random.choice(range(0, 1000))])
        time.sleep(0.5)

threading.Thread(target=display_data, daemon=True).start()
root.mainloop()

3 — 2 Lines with Different Styles

▶️ View 2 Lines Demo Video on GitHub

View code
import tkinter as tk
import tkchart
import random
import threading
import time

root = tk.Tk()
root.configure(bg="#0d1117")
root.geometry("720x430+200+200")

line_chart = tkchart.LineChart(
    master=root,
    x_axis_values=("01-01", "01-02", "01-03", "01-04", "01-05", "01-06", "01-07", "01-08", "01-09", "01-10"),
    y_axis_values=(0, 1000),
    y_axis_label_count=10,
)
line_chart.pack(pady=15)

line1 = tkchart.Line(
    master=line_chart,
    color="#5dffb6",
    size=2,
    style="dashed",
    style_type=(10, 5),
)

line2 = tkchart.Line(
    master=line_chart,
    color="#FFBAD2",
    size=2,
    point_highlight="enabled",
    point_highlight_color="#FFBAD2",
)

def display_data():
    while True:
        line_chart.show_data(line=line1, data=[random.choice(range(0, 1000))])
        line_chart.show_data(line=line2, data=[random.choice(range(0, 1000))])
        time.sleep(0.5)

threading.Thread(target=display_data, daemon=True).start()
root.mainloop()

4 — 3 Lines with Different Styles

▶️ View 3 Lines Demo Video on GitHub

View code
import tkinter as tk
import tkchart
import random
import threading
import time

root = tk.Tk()
root.configure(bg="#0d1117")
root.geometry("720x430+200+200")

line_chart = tkchart.LineChart(
    master=root,
    x_axis_values=("01-01", "01-02", "01-03", "01-04", "01-05", "01-06", "01-07", "01-08", "01-09", "01-10"),
    y_axis_values=(0, 1000),
    y_axis_label_count=10,
)
line_chart.pack(pady=15)

line1 = tkchart.Line(master=line_chart, size=2, fill="enabled")

line2 = tkchart.Line(
    master=line_chart,
    color="#5dffb6",
    size=2,
    style="dashed",
    style_type=(10, 5),
)

line3 = tkchart.Line(
    master=line_chart,
    color="#FFBAD2",
    size=2,
    point_highlight="enabled",
    point_highlight_color="#FFBAD2",
)

def display_data():
    while True:
        line_chart.show_data(line=line1, data=random.choices(range(0, 1000), k=1))
        line_chart.show_data(line=line2, data=random.choices(range(0, 1000), k=1))
        line_chart.show_data(line=line3, data=random.choices(range(0, 1000), k=1))
        time.sleep(0.5)

threading.Thread(target=display_data, daemon=True).start()
root.mainloop()

5 — With Grid Sections

▶️ View Grid Sections Demo Video on GitHub

View code
import tkinter as tk
import tkchart
import random
import threading
import time

root = tk.Tk()
root.configure(bg="#0d1117")
root.geometry("720x430+200+200")

line_chart = tkchart.LineChart(
    master=root,
    x_axis_values=("01-01", "01-02", "01-03", "01-04", "01-05", "01-06", "01-07", "01-08", "01-09", "01-10"),
    y_axis_values=(0, 1000),
    y_axis_label_count=10,
    y_axis_section_count=10,
    x_axis_section_count=10,
)
line_chart.pack(pady=15)

line1 = tkchart.Line(
    master=line_chart,
    color="#5dffb6",
    size=2,
    style="dashed",
    style_type=(10, 5),
)

line2 = tkchart.Line(
    master=line_chart,
    color="#FFBAD2",
    size=2,
    point_highlight="enabled",
    point_highlight_color="#FFBAD2",
)

def display_data():
    while True:
        line_chart.show_data(line=line1, data=[random.choice(range(0, 1000))])
        line_chart.show_data(line=line2, data=[random.choice(range(0, 1000))])
        time.sleep(0.5)

threading.Thread(target=display_data, daemon=True).start()
root.mainloop()

📚 Documentation

Explore all parameters, configuration methods, and advanced usage:


👥 Contributors

Metadata

Release files for tkchart 2.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tkchart 2.2.1
File Size Uploaded Provenance Actions
tkchart-2.2.1.tar.gz 35.8 kB Without provenance Details for tkchart-2.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tkchart 2.2.1
File Interpreter ABI Platform Actions
tkchart-2.2.1-py3-none-any.whl Python 3 none any Details for tkchart-2.2.1-py3-none-any.whl

Total release size: 67.5 kB

Release files / tkchart-2.2.1.tar.gz

Download URL tkchart-2.2.1.tar.gz
Size 35.8 kB
Tags Source
SHA-256 checksum
How to use checksums
3085023e5244480cbf6321a4752714d7ac9c69ca1658fbd21aecbbf2d8ab3c4b
BLAKE2b-256 checksum
How to use checksums
7d90bb9bf7e856a6ae972031774fe25aaa31be44631b454abc1db88d2900fcdc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / tkchart-2.2.1-py3-none-any.whl

Download URL tkchart-2.2.1-py3-none-any.whl
Size 31.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8f4f37373d13d920726847de2569d1e2ca32e895d50660f599c8f4deea3bde5f
BLAKE2b-256 checksum
How to use checksums
562d020e793fe723d29de1e2b1ec27344ba020d96777fa770e1fdc38f6ed6ea1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Security for tkchart 2.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page