File: events_example.py

package info (click to toggle)
pyotherside 1.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 880 kB
  • sloc: cpp: 2,869; python: 475; makefile: 152; sh: 35
file content (23 lines) | stat: -rw-r--r-- 546 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# This example demonstrates the use of pyotherside.send() to send events to Qt.

import pyotherside

import threading
import time

print('Using PyOtherSide version', pyotherside.version)

COLORS = ['red', 'green', 'blue']

def thread_func():
    i = 0
    while True:
        pyotherside.send('append', 'Next Number: ',  i)
        if i % 2 == 0:
            color = COLORS[int((i / 2) % len(COLORS))]
            pyotherside.send('color', color)
        i += 1
        time.sleep(1)

thread = threading.Thread(target=thread_func)
thread.start()