I am trying to make a replacemnt display for an old tube based instrument using a raspi and LCD. I have a start on the GUI code and it works but when I add the while loop at the end waiting for input the GUI does not display. when I remove the while loop it does display. Any help will be appreciated.
Code below
from Tkinter import *
import numpy, math, serial
import RPi.GPIO as GPIO
import time
GPIO.setmode(GP IO.BOARD)
GPIO.setup(21, GPIO.IN,pull_up _down=GPIO.PUD_ UP) # USE PIN 21 INPUT, 25 GND
def bezel(canvas, xlinedistance, ylinedistance): # Create the canvas
# vertical lines at an interval of "line_dista nce" pixel
canvas.create_r ectangle(xlined istance, 0, canvas_width, canvas_height *0.9, fill="black")
for x in rangpython probleme(xlined istance,canvas_ width,xlinedist ance):
a= x / xlinedistance - 1
canvas.create_l ine(x, 0, x, canvas_height, fill="#333333", dash=(4, 4))
canvas.create_t ext(x+3, canvas_height-10, fill="green", text=str(10*a) + 'Mhz', anchor="e")
# horizontal lines at an interval of "line_dista nce" pixel
for y in range(ylinedist ance,canvas_hei ght,ylinedistan ce):
b= y / ylinedistance - 1
canvas.create_l ine(0, y, canvas_width, y, fill="#333333", dash=(4, 4))
canvas.create_t ext(5, y-10, fill="green", text=str(-10*b) + "db", anchor="w")
master = Tk()
master.wm_title ("HPSA")
canvas_width = 640
canvas_height = 480
grid = Canvas(master, width=canvas_wi dth, height=canvas_h eight)
grid.pack()
xlinedistance= canvas_width/11
ylinedistance= canvas_height/10
bezel(grid,xlin edistance, ylinedistance)
grid.create_lin e(xlinedistance , canvas_height/2, canvas_width, canvas_height/2, fill="red")
while True:
print("Test ")
while (GPIO.input(21) ==TRUE):
pass
print("Starting Scan ")
master.mainloop ()
Code below
from Tkinter import *
import numpy, math, serial
import RPi.GPIO as GPIO
import time
GPIO.setmode(GP IO.BOARD)
GPIO.setup(21, GPIO.IN,pull_up _down=GPIO.PUD_ UP) # USE PIN 21 INPUT, 25 GND
def bezel(canvas, xlinedistance, ylinedistance): # Create the canvas
# vertical lines at an interval of "line_dista nce" pixel
canvas.create_r ectangle(xlined istance, 0, canvas_width, canvas_height *0.9, fill="black")
for x in rangpython probleme(xlined istance,canvas_ width,xlinedist ance):
a= x / xlinedistance - 1
canvas.create_l ine(x, 0, x, canvas_height, fill="#333333", dash=(4, 4))
canvas.create_t ext(x+3, canvas_height-10, fill="green", text=str(10*a) + 'Mhz', anchor="e")
# horizontal lines at an interval of "line_dista nce" pixel
for y in range(ylinedist ance,canvas_hei ght,ylinedistan ce):
b= y / ylinedistance - 1
canvas.create_l ine(0, y, canvas_width, y, fill="#333333", dash=(4, 4))
canvas.create_t ext(5, y-10, fill="green", text=str(-10*b) + "db", anchor="w")
master = Tk()
master.wm_title ("HPSA")
canvas_width = 640
canvas_height = 480
grid = Canvas(master, width=canvas_wi dth, height=canvas_h eight)
grid.pack()
xlinedistance= canvas_width/11
ylinedistance= canvas_height/10
bezel(grid,xlin edistance, ylinedistance)
grid.create_lin e(xlinedistance , canvas_height/2, canvas_width, canvas_height/2, fill="red")
while True:
print("Test ")
while (GPIO.input(21) ==TRUE):
pass
print("Starting Scan ")
master.mainloop ()
Comment