Created
September 28, 2018 01:14
-
-
Save jarobins/3a334e1961456644039239e22c685c43 to your computer and use it in GitHub Desktop.
Simple graphical display using tkinter. Refresh rate is a bit slow.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# File: tk_graphic.py | |
# Author: Jake Robinson | |
# Date: 27SEP2018 | |
from Tkinter import * | |
import datetime | |
import random | |
import time | |
class App: | |
def __init__(self, master): | |
self.screen_rom = {} | |
frame = Frame(master) | |
frame.pack() | |
self.canvas = Canvas(frame, width=800, height=600) | |
self.canvas.pack() | |
self.fill_screen_rom() | |
def test_print(self): | |
print "TK Base Program" | |
def create_pixel(self, x, y): | |
return self.canvas.create_rectangle(10+(y*8), 10+(x*8), 2+(y*8), 2+(x*8), fill='white', outline='white') | |
def fill_screen_rom(self): | |
for x in range(32): | |
self.screen_rom[x] = [self.create_pixel(x, y) for y in range(64)] | |
def update_screen(self, address, data): | |
for x, y in enumerate(format(data, '064b')): | |
if y == '1': | |
self.canvas.itemconfig(self.screen_rom[address][x], fill='black') | |
else: | |
self.canvas.itemconfig(self.screen_rom[address][x], fill='white') | |
root = Tk() | |
root.geometry("518x265") | |
app = App(master=root) | |
counter = [2**x for x in range(0, 32)] | |
print counter | |
while True: | |
root.update() | |
for x, y in enumerate(counter): | |
counter[x] = counter[x] >> 1 | |
if counter[x] == 0: | |
counter[x] = 2**63 | |
app.update_screen(x, counter[x]) | |
time.sleep(0.1) | |
root.title("TK Base Program") | |
root.mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment