LoginSignup
0
0

More than 5 years have passed since last update.

tkinterでthread その2

Posted at

概要

tkinterでthreadやってみた。
threadから、ライン引いてみた。

写真

image.png

サンプルコード

import Tkinter
import random
import threading
import time

a = 0
class Emu(threading.Thread):
   def __init__(self):
      threading.Thread.__init__(self)
   def run(self):
      a = 0
      while a < 400:
         a += 1
         canvas.create_line(a % 400 + random.randrange(a), 
                a % 400 + random.randrange(a), 
                a % 400 + random.randrange(a), 
                a % 400 + random.randrange(a), fill = "red")

root = Tkinter.Tk();
root.minsize(420, 420)
canvas = Tkinter.Canvas(root, width = 400, height = 400)
canvas.place(x = 10, y = 10)
Emu().start()
root.mainloop()

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0