Skip to main content

Killable, non-blocking threads for tkinter

Project description

Killable, non-blocking threads for tkinter

Tested against Windows / Python 3.11 / Anaconda

Made for tkinter, but can be used without it too!

from tkinter import *
from tkinter import messagebox
from tkkillablethreads import ExecuteAsThreadedTask
import time


def sleepprinter(*args, **kwargs):
    print(args, kwargs)
    for q in range(7):
        print("sleeping")
        time.sleep(1)
    messagebox.showinfo("Thread Ready", f"Results Ready - check: c.results ")
    return "bab"


top = Tk()
top.geometry("100x400")
c = ExecuteAsThreadedTask(fu=sleepprinter, args=("baba", "bbu"), kwargs={"oi": "badxx"})


def threadCallBack():
    c()
    messagebox.showinfo("Started Thread", str(c))


def threadCallBack2():
    c.killthread()
    messagebox.showinfo("Killed Thread", str(c))


B = Button(top, text="Start Thread", command=threadCallBack)
B.pack()
BCancel = Button(top, text="Cancel Thread", command=threadCallBack2)
BCancel.pack()
top.mainloop()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tkkillablethreads-0.10.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tkkillablethreads-0.10-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file tkkillablethreads-0.10.tar.gz.

File metadata

  • Download URL: tkkillablethreads-0.10.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for tkkillablethreads-0.10.tar.gz
Algorithm Hash digest
SHA256 833f11c1c55a18be67fd465c016352adbeba5d962fb57f31b89a5a0c3b8d6eea
MD5 b7e39b2c1cdc509a84a16856fee33250
BLAKE2b-256 2b17f63392e4f1b4adbfe5f794072473762c0e965c7ffb12152bad7244a68e82

See more details on using hashes here.

File details

Details for the file tkkillablethreads-0.10-py3-none-any.whl.

File metadata

File hashes

Hashes for tkkillablethreads-0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 44a4ed430e02e8871ffdae81c5bf85dc780a3ab54b2325c1efc53d6ca2dfc3d8
MD5 e8f706d5e070c103cdb8ff7b45cea1dd
BLAKE2b-256 4d53e426bec1ceb2e6c0f84ce0db108cce26341080c8ab9070adae53b0188821

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page