I have this tkinter GUI of an old school texter that runs on a Raspberry pi 3. I have 16 pressure analog pressure sensors that i am readding them through a multiplexor, and i pass there values to an ADC mcp3002. if the value pass a thresshold i consider it as a key press, and there i need some chars to roll while i have it pressed inside a text area, if the voltage passes the thresshold the other way i consider the key to be released and the last char that was inside the text area will be set at that cursor point, the cursor will move one place next, and wait untill an other press to do the same thing again. this is the code for the def : def process(value):
global keypressed, keyreleased num_press=0 #message=[] #this table gets the chars. After the roll is finished the last char is appented to it. eventually this table is piped to minimodem. steps=0 i=0 x=int(value) key_pressed=x #proceedInLoop = True while True: binary_x="{0:04b}".format(x) #get the binary of x and set each 0 and 1 to the appropreate GPIO GPIO.output(26, int(binary_x[0])) GPIO.output(13, int(binary_x[1])) GPIO.output(12, int(binary_x[2])) GPIO.output(5, int(binary_x[3])) # average three readings to get a more stable one channeldata_1 = read_mcp3002(0) # get CH0 input sleep(0.001) channeldata_2 = read_mcp3002(0) # get CH0 input sleep(0.001) channeldata_3 = read_mcp3002(0) # get CH0 input channeldata = (channeldata_1+channeldata_2+channeldata_3)/3 # # Voltage = (CHX data * (V-ref [= 3300 mV] * 2 [= 1:2 input divider]) / 1024 [= 10bit resolution] # voltage = int(round(((channeldata * vref * 2) / resolution),0))+ calibration #voltage = 6000 # temporary voltage for testing print(voltage) if DEBUG : print("Data (bin) {0:010b}".format(channeldata)) key_pressed=x if ( voltage < 4000) : #key is released keypressed = False keyreleased = True x=x+1 if ( voltage >= 4001) : #key is pressed keypressed = True keyreleased = False key_pressed=x#define which key is pressed # print(i) if key_pressed==0: transmite(message) x=x+1 sleep(0.01) keypressed = False keyreleased = True if key_pressed==1: print('read') keypressed = False keyreleased = True if key_pressed==2: sys.stdout.write('\033[2K]') sys.stdout.write('\033[1G]') keypressed = False keyreleased = True if key_pressed==3: #print('\b\b') print('\b ', end="", flush=True) sys.stdout.write('\010') sleep(1) keypressed = False keyreleased = True if key_pressed > 3: #if key == key_pressed : while num_press <= (max_press[key_pressed]) and keyreleased==False: #average three readings to get a more stable one channeldata_1 = read_mcp3002(0) # get CH0 input sleep(0.001) channeldata_2 = read_mcp3002(0) # get CH0 input sleep(0.001) channeldata_3 = read_mcp3002(0) # get CH0 input channeldata = (channeldata_1+channeldata_2+channeldata_3)/3 # # Voltage = (CHX data * (V-ref [= 3300 mV] * 2 [= 1:2 input divider]) / 1024 [= 10bit resolution] voltage = int(round(((channeldata*vref*2)/resolution),0))+ calibration if DEBUG : print("Data (bin) {0:010b}".format(channeldata)) if ( voltage < 4000) : #key is released print("voltage < 4000") keyreleased = True keypressed = False sys.stdout.write('\033[1C') char=sensor[key_pressed][num_press] message.append(char) # here is the append. num_press=0 #else : #keypressed = True #keyreleased = False if num_press <= max_press[key_pressed] and keyreleased == False: top.Text1.insert("end", sensor[key_pressed][num_press] + '\n') print(sensor[key_pressed][num_press]) #text_widget.insert(INSERT, sensor[key_pressed][num_press]) #Text1.insert(INSERT, sensor[key_pressed][num_press]) sys.stdout.write('\010') num_press=num_press+1 time.sleep(0.5) if num_press == max_press[key_pressed] : #num_press=0 keyreleased = True keypressed = False #top.Text1.insert("end", sensor[key_pressed][num_press]) if x == 16 : x=0 key = key_pressed print(message) if keyreleased: break it gets the values from this set of tables : sensor16=['1','-','\\','/','*'] sensor15=['4','G','H','I'] sensor14=['7','P','Q','R','S'] sensor13=['*'] sensor12=['2','A','B','C'] sensor11=['5','J','K','L'] sensor10=['8','T','U','V'] sensor09=['0',' '] sensor08=['3','D','E','F'] sensor07=['6','M','N','O'] sensor06=['9','W','X','Y','Z'] sensor05=['#','|'] sensor04=['BACKSPACE'] sensor03=['DELETE ALL'] sensor02=['READ'] sensor01=['TRANSMITE'] sensor=[sensor01,sensor02,sensor03,sensor04, sensor05, sensor06, sensor07, sensor08, sensor09, sensor10, sensor11, sensor12, sensor13, sensor14, sensor15, sensor16] #the maximum number of times each sensor can be pressed #before it rols back to the first character. max_press=[1,1,1,1,2,5,4,4,2,4,4,4,1,5,4,5] i have a class created with buttons and everything, i have managed to make it work with real presses of mouse on the buttons but that only works for one roll, when it gets to the seccond one everything goes wild. so i am trying to to create a def that runs every 100 millisecs and check if any of those pressure sensors has passed the threshold and if yes to invoke the apropreate button and do what is all ready been doing, but from the other hand the rooling is not working great either. i pass the entire code, while i am lost here ! the code is not clean while i have a lot of things that are left there after some test and i have no idea if they supposed to leave or not. so any ideas are more than welcome while i am completly lost here . #! /usr/bin/env python # -*- coding: utf-8 -*- # # GUI module generated by PAGE version 4.19 # in conjunction with Tcl version 8.6 # Dec 27, 2018 08:20:37 PM IST platform: Windows NT import sys try: import Tkinter as tk except ImportError: import tkinter as tk try: import ttk py3 = False except ImportError: import tkinter.ttk as ttk py3 = True import time #import uinput import RPi.GPIO as GPIO import spidev # import the SPI driver from time import sleep from array import * import os import subprocess import random import time from threading import Timer from itertools import groupby import threading #initial constants here DEBUG = False vref = 3.3 * 1000 # V-Ref in mV (Vref = VDD for the MCP3002) resolution = 2**10 # for 10 bits of resolution calibration = 38 # in mV, to make up for the precision of the components GPIO.setmode(GPIO.BOARD) GPIO.setwarnings(False) #for the channels of the 4067 multiplexor 16 to 1 #change the channels and pipe from the output of the multiplexer #the analog readings to the 0 channel of the MCP3002 ADC GPIO.setup(5, GPIO.OUT) GPIO.setup(12, GPIO.OUT) GPIO.setup(13, GPIO.OUT) GPIO.setup(26, GPIO.OUT) #start_time=time.time() #elapsed_time=time.time() # MCP3002 Control bits # # 7 6 5 4 3 2 1 0 # X 1 S O M X X X # # bit 6 = Start Bit # S = SGL or \DIFF SGL = 1 = Single Channel, 0 = \DIFF is pseudo differential # O = ODD or \SIGN # in Single Ended Mode (SGL = 1) # ODD 0 = CH0 = + GND = - (read CH0) # 1 = CH1 = + GND = - (read CH1) # in Pseudo Diff Mode (SGL = 0) # ODD 0 = CH0 = IN+, CH1 = IN- # 1 = CH0 = IN-, CH1 = IN+ # # M = MSBF # MSBF = 1 = LSB first format # 0 = MSB first format # ------------------------------ # SPI setup spi_max_speed = 1000000 # 1 MHz (1.2MHz = max for 2V7 ref/supply) # reason is that the ADC input cap needs time to get charged to the input level. CE = 0 # CE0 | CE1, selection of the SPI device spi = spidev.SpiDev() spi.open(0,CE) # Open up the communication to the device spi.max_speed_hz = spi_max_speed # # create a function that sets the configuration parameters and gets the results # from the MCP3002 # # key presses values key0=['0',' '] key1=['1','-','\\','/','*'] key2=['2','A','B','C'] key3=['3','D','E','F'] key4=['4','G','H','I'] key5=['5','J','K','L'] key6=['6','M','N','O'] key7=['7','P','Q','R','S'] key8=['8','T','U','V'] key9=['9','W','X','Y','Z'] key10=['*'] key11=['#','|'] keyArray = [key0,key1,key2,key3,key4,key5,key6,key7,key8,key9,key10,key11] key_max_press = [2,5,4,4,4,4,4,5,4,5,1,2] #Each analog sensor has some characters to roll sensor16=['1','-','\\','/','*'] sensor15=['4','G','H','I'] sensor14=['7','P','Q','R','S'] sensor13=['*'] sensor12=['2','A','B','C'] sensor11=['5','J','K','L'] sensor10=['8','T','U','V'] sensor09=['0',' '] sensor08=['3','D','E','F'] sensor07=['6','M','N','O'] sensor06=['9','W','X','Y','Z'] sensor05=['#','|'] sensor04=['BACKSPACE'] sensor03=['DELETE ALL'] sensor02=['READ'] sensor01=['TRANSMITE'] sensor=[sensor01,sensor02,sensor03,sensor04, sensor05, sensor06, sensor07, sensor08, sensor09, sensor10, sensor11, sensor12, sensor13, sensor14, sensor15, sensor16] #the maximum number of times each sensor can be pressed #before it rols back to the first character. max_press=[1,1,1,1,2,5,4,4,2,4,4,4,1,5,4,5] message=[] ## # main functions start here ## # read sensor data def read_mcp3002(channel): # see datasheet for more information # 8 bit control : # X, Strt, SGL|!DIFF, ODD|!SIGN, MSBF, X, X, X # 0, 1, 1=SGL, 0 = CH0 , 0 , 0, 0, 0 = 96d # 0, 1, 1=SGL, 1 = CH1 , 0 , 0, 0, 0 = 112d if channel == 0: cmd = 0b01100000 else: cmd = 0b01110000 if DEBUG : print("cmd = ", cmd) spi_data = spi.xfer2([cmd,0]) # send hi_byte, low_byte; receive hi_byte, low_byte if DEBUG : print("Raw ADC (hi-byte, low_byte) = {}".format(spi_data)) # receive data range: 000..3FF (10 bits) # MSB first: (set control bit in cmd for LSB first) # spidata[0] = X, X, X, X, X, 0, B9, B8 # spidata[1] = B7, B6, B5, B4, B3, B2, B1, B0 # LSB: mask all but B9 & B8, shift to left and add to the MSB adc_data = ((spi_data[0] & 3) << 8) + spi_data[1] return adc_data # function to transmite message def transmite_message(): messageArray = [] messageString = top.Text1.get("1.0","end") if len(messageString) > 0 : for char in messageString: messageArray.append(char) # here is the append. #print(messageArray) a = ''.join(messageArray) print(a) p1 = subprocess.Popen(["minimodem" , '--tx' , '25'], stdin=subprocess.PIPE) p1.stdin.write(bytes(a, 'UTF-8')) p1.stdin.flush() #The transmiting function def transmite(minima): a = ''.join(minima) print(a) p1 = subprocess.Popen(["minimodem" , '--tx' , '25'], stdin=subprocess.PIPE) p1.stdin.write(bytes(a, 'UTF-8')) p1.stdin.flush() # close root window def close_window(): root.destroy() # delete character def delete_char(): tempString = top.Text2.get("1.0","end") if len(tempString) > 0 : groups = groupby(tempString) result = [(label, sum(1 for _ in group)) for label, group in groups] #print (len(result)) # [('6', 2), ('#', 1), ('6', 1), ('\n', 1)] if len(result) > 1: tempValue = result[len(result)-2][0] tempCounter = result[len(result)-2][1] + 1 print(tempValue) print(tempCounter) tempString = tempString[:-tempCounter] top.Text2.delete('1.0', "end") top.Text2.insert("end", tempString) # append temporary character in invisible string def print_char(key): process(key) top.Text2.insert("end", sensor[key][0]) inputString = top.Text2.get("1.0","end") print('now i am here') # rolling character one by one def print_rolling_char(): threading.Timer(0.5, print_rolling_char).start() inputString = top.Text2.get("1.0","end") if len(inputString.rstrip()) < 1: top.Text1.delete('1.0', "end") if len(inputString) > 0 : groups = groupby(inputString) result = [(label, sum(1 for _ in group)) for label, group in groups] #print (len(result)) # [('6', 2), ('#', 1), ('6', 1), ('\n', 1)] if len(result) > 1: print('i am in len result >1 ') top.Text1.delete('1.0', "end") for x in result: tempValue = x[0] tempCounter = x[1] if tempValue != '\n' and tempValue != '|': # if tempCounter > key_max_press[int(tempCounter)]: while tempCounter > key_max_press[int(tempCounter)]: tempCounter = tempCounter - key_max_press[int(tempCounter)] print('tempCounter is ', tempCounter) print('key_max_press is ', key_max_press[int(tempCounter)]) if tempValue != '*' and tempValue != '#': charNew = keyArray[int(tempValue)][tempCounter-1] else: if tempValue == '*': charNew = keyArray[10][tempCounter-1] else: charNew = keyArray[11][tempCounter-1] if charNew != '|': top.Text1.insert("end", charNew) #message.append(charNew) # here is the append. # else: # tempCounter = x[1] # read sensors data each second def read_sensor_data(): threading.Timer(1.0, read_sensor_data).start() file = open("sensor_1.txt", 'r') #txt = file.read() lineList = file.readlines() file.close() top.Label2.config(text = lineList[-1]) file = open("sensor_2.txt", 'r') #txt = file.read() lineList = file.readlines() file.close() top.Label3.config(text = lineList[-1]) file = open("sensor_3.txt", 'r') #txt = file.read() lineList = file.readlines() file.close() top.Label4.config(text = lineList[-1]) file = open("sensor_4.txt", 'r') #txt = file.read() lineList = file.readlines() file.close() top.Label5.config(text = lineList[-1]) file = open("compass.txt", 'r') #txt = file.read() lineList = file.readlines() file.close() top.Label1.config(text = lineList[-1]) # add separator in between same character def add_separator(self): top.Text2.insert("end", '|') # clear text area def clear_message(self): top.Text2.delete('1.0', "end") # dummy click in every 1 sec def loop_process(): threading.Timer(1.0, loop_process).start() process_for_loop() # main function to render UI screen def vp_start_gui(): '''Starting point when module is the main routine.''' global val, w, root, top root = tk.Tk() root.attributes("-fullscreen", False) top = Toplevel1 (root) print_rolling_char() loop_process() read_sensor_data() root.mainloop() w = None def create_Toplevel1(root, *args, **kwargs): '''Starting point when module is imported by another program.''' global w, w_win, rt rt = root w = tk.Toplevel (root) top = Toplevel1 (w) #unknown_support.init(w, top, *args, **kwargs) return (w, top) def destroy_Toplevel1(): global w w.destroy() w = None # main process loop def process_for_loop(): global keypressed, keyreleased, key_pressed num_press = 0 #message=[] #this table gets the chars. After the roll is finished the last char is appented to it. eventually this table is piped to minimodem. steps = 0 i = 0 for x in range(0,16): # threading.Timer(0.5, loop_process).start() key_pressed=x #proceedInLoop = True binary_x="{0:04b}".format(x) GPIO.output(26, int(binary_x[0])) GPIO.output(13, int(binary_x[1])) GPIO.output(12, int(binary_x[2])) GPIO.output(5, int(binary_x[3])) # average three readings to get a more stable one channeldata_1 = read_mcp3002(0) # get CH0 input sleep(0.001) channeldata_2 = read_mcp3002(0) # get CH0 input sleep(0.001) channeldata_3 = read_mcp3002(0) # get CH0 input channeldata = (channeldata_1+channeldata_2+channeldata_3)/3 # # Voltage = (CHX data * (V-ref [= 3300 mV] * 2 [= 1:2 input divider]) / 1024 [= 10bit resolution] # voltage = int(round(((channeldata * vref * 2) / resolution),0))+ calibration #voltage = 6000 # temporary voltage for testing #print(voltage) if DEBUG : print("Data (bin) {0:010b}".format(channeldata)) #key_pressed=x if ( voltage < 4000) : #key is released keypressed = False keyreleased = True x=x+1 if ( voltage >= 4001) : #key is pressed keypressed = True keyreleased = False key_pressed=x#define which key is pressed # print(i) if key_pressed==0: transmite(message) x=x+1 sleep(0.01) keypressed = False keyreleased = True if key_pressed==1: print('read') keypressed = False keyreleased = True if key_pressed==2: sys.stdout.write('\033[2K]') sys.stdout.write('\033[1G]') keypressed = False keyreleased = True if key_pressed==3: #print('\b\b') print('\b ', end="", flush=True) sys.stdout.write('\010') sleep(1) keypressed = False keyreleased = True if key_pressed > 3: #if key == key_pressed : while num_press <= (max_press[key_pressed]) and keyreleased==False: #average three readings to get a more stable one channeldata_1 = read_mcp3002(0) # get CH0 input sleep(0.001) channeldata_2 = read_mcp3002(0) # get CH0 input sleep(0.001) channeldata_3 = read_mcp3002(0) # get CH0 input channeldata = (channeldata_1+channeldata_2+channeldata_3)/3 # # Voltage = (CHX data * (V-ref [= 3300 mV] * 2 [= 1:2 input divider]) / 1024 [= 10bit resolution] voltage = int(round(((channeldata*vref*2)/resolution),0))+ calibration if DEBUG : print("Data (bin) {0:010b}".format(channeldata)) if ( voltage < 4000) : #key is released print("voltage < 4000") keyreleased = True keypressed = False sys.stdout.write('\033[1C') char=sensor[key_pressed][num_press] message.append(char) # here is the append. num_press=0 #else : #keypressed = True #keyreleased = False if num_press <= max_press[key_pressed] and keyreleased == False: top.Text1.insert("end", sensor[key_pressed][num_press] + '\n') print(sensor[key_pressed][num_press]) #text_widget.insert(INSERT, sensor[key_pressed][num_press]) #Text1.insert(INSERT, sensor[key_pressed][num_press]) sys.stdout.write('\010') num_press=num_press+1 time.sleep(0.5) if num_press == max_press[key_pressed] : num_press=0 keyreleased = True keypressed = False #top.Text1.insert("end", sensor[key_pressed][num_press]) key = key_pressed print(message) if keyreleased: break # open read message screen def open_reading_screen(): close_window() os.system('python3 messageread.py') #open sensor reading screen def open_sensor_reading(): close_window() os.system('python3 onescreentorule.py') # loop def process(value): global keypressed, keyreleased num_press=0 #message=[] #this table gets the chars. After the roll is finished the last char is appented to it. eventually this table is piped to minimodem. steps=0 i=0 x=int(value) key_pressed=x #proceedInLoop = True while True: binary_x="{0:04b}".format(x) #get the binary of x and set each 0 and 1 to the appropreate GPIO GPIO.output(26, int(binary_x[0])) GPIO.output(13, int(binary_x[1])) GPIO.output(12, int(binary_x[2])) GPIO.output(5, int(binary_x[3])) # average three readings to get a more stable one channeldata_1 = read_mcp3002(0) # get CH0 input sleep(0.001) channeldata_2 = read_mcp3002(0) # get CH0 input sleep(0.001) channeldata_3 = read_mcp3002(0) # get CH0 input channeldata = (channeldata_1+channeldata_2+channeldata_3)/3 # # Voltage = (CHX data * (V-ref [= 3300 mV] * 2 [= 1:2 input divider]) / 1024 [= 10bit resolution] # voltage = int(round(((channeldata * vref * 2) / resolution),0))+ calibration #voltage = 6000 # temporary voltage for testing print(voltage) if DEBUG : print("Data (bin) {0:010b}".format(channeldata)) key_pressed=x if ( voltage < 4000) : #key is released keypressed = False keyreleased = True x=x+1 if ( voltage >= 4001) : #key is pressed keypressed = True keyreleased = False key_pressed=x#define which key is pressed # print(i) if key_pressed==0: transmite(message) x=x+1 sleep(0.01) keypressed = False keyreleased = True if key_pressed==1: print('read') keypressed = False keyreleased = True if key_pressed==2: sys.stdout.write('\033[2K]') sys.stdout.write('\033[1G]') keypressed = False keyreleased = True if key_pressed==3: #print('\b\b') print('\b ', end="", flush=True) sys.stdout.write('\010') sleep(1) keypressed = False keyreleased = True if key_pressed > 3: #if key == key_pressed : while num_press <= (max_press[key_pressed]) and keyreleased==False: #average three readings to get a more stable one channeldata_1 = read_mcp3002(0) # get CH0 input sleep(0.001) channeldata_2 = read_mcp3002(0) # get CH0 input sleep(0.001) channeldata_3 = read_mcp3002(0) # get CH0 input channeldata = (channeldata_1+channeldata_2+channeldata_3)/3 # # Voltage = (CHX data * (V-ref [= 3300 mV] * 2 [= 1:2 input divider]) / 1024 [= 10bit resolution] voltage = int(round(((channeldata*vref*2)/resolution),0))+ calibration if DEBUG : print("Data (bin) {0:010b}".format(channeldata)) if ( voltage < 4000) : #key is released print("voltage < 4000") keyreleased = True keypressed = False sys.stdout.write('\033[1C') char=sensor[key_pressed][num_press] message.append(char) # here is the append. num_press=0 #else : #keypressed = True #keyreleased = False if num_press <= max_press[key_pressed] and keyreleased == False: top.Text1.insert("end", sensor[key_pressed][num_press] + '\n') print(sensor[key_pressed][num_press]) #text_widget.insert(INSERT, sensor[key_pressed][num_press]) #Text1.insert(INSERT, sensor[key_pressed][num_press]) sys.stdout.write('\010') num_press=num_press+1 time.sleep(0.5) if num_press == max_press[key_pressed] : #num_press=0 keyreleased = True keypressed = False #top.Text1.insert("end", sensor[key_pressed][num_press]) if x == 16 : x=0 key = key_pressed print(message) if keyreleased: break #proceedInLoop = False class Toplevel1: def __init__(self, top=None): '''This class configures and populates the toplevel window. top is the toplevel containing window.''' _bgcolor = '#d9d9d9' # X11 color: 'gray85' _fgcolor = '#000000' # X11 color: 'black' _compcolor = '#d9d9d9' # X11 color: 'gray85' _ana1color = '#d9d9d9' # X11 color: 'gray85' _ana2color = '#ececec' # Closest X11 color: 'gray92' top.geometry("600x450+579+181") top.title("New Toplevel") top.configure(background="#d9d9d9") top.configure(highlightbackground="#d9d9d9") top.configure(highlightcolor="black") self.Frame1 = tk.Frame(top) self.Frame1.place(relx=0.033, rely=0.067, relheight=0.9, relwidth=0.942) self.Frame1.configure(relief='groove') self.Frame1.configure(borderwidth="2") self.Frame1.configure(relief='groove') self.Frame1.configure(background="#d9d9d9") self.Frame1.configure(highlightbackground="#d9d9d9") self.Frame1.configure(highlightcolor="black") self.Frame1.configure(width=565) self.Text1 = tk.Text(self.Frame1) self.Text1.place(relx=0.124, rely=0.148, relheight=0.281, relwidth=0.786) self.Text1.configure(background="white") self.Text1.configure(font="TkTextFont") self.Text1.configure(foreground="black") self.Text1.configure(highlightbackground="#d9d9d9") self.Text1.configure(highlightcolor="black") self.Text1.configure(insertbackground="black") self.Text1.configure(selectbackground="#c4c4c4") self.Text1.configure(selectforeground="black") self.Text1.configure(width=444) self.Text1.configure(wrap='word') self.Text2 = tk.Text(self.Frame1) self.Text2.place(relx=0.118, rely=0.287, relheight=0, relwidth=0) self.Text2.configure(background="white") self.Text2.configure(font="TkTextFont") self.Text2.configure(foreground="black") self.Text2.configure(highlightbackground="#d9d9d9") self.Text2.configure(highlightcolor="black") self.Text2.configure(insertbackground="black") self.Text2.configure(selectbackground="#c4c4c4") self.Text2.configure(selectforeground="black") self.Text2.configure(width=374) self.Text2.configure(wrap='word') #self.Text2.insert("1.0", "Hello") self.Label1 = tk.Label(self.Frame1) self.Label1.place(relx=0.035, rely=0.025, height=41, width=107) self.Label1.configure(activebackground="#f9f9f9") self.Label1.configure(activeforeground="black") self.Label1.configure(background="#d9d9d9") self.Label1.configure(disabledforeground="#a3a3a3") self.Label1.configure(foreground="#000000") self.Label1.configure(highlightbackground="#d9d9d9") self.Label1.configure(highlightcolor="black") self.Label1.configure(text='''Compass Value''') self.Label1.configure(width=107) self.Label2 = tk.Label(self.Frame1) self.Label2.place(relx=0.23, rely=0.049, height=31, width=74) self.Label2.configure(activebackground="#f9f9f9") self.Label2.configure(activeforeground="black") self.Label2.configure(background="#d9d9d9") self.Label2.configure(disabledforeground="#a3a3a3") self.Label2.configure(foreground="#000000") self.Label2.configure(highlightbackground="#d9d9d9") self.Label2.configure(highlightcolor="black") self.Label2.configure(text='''Sensor1''') self.Label3 = tk.Label(self.Frame1) self.Label3.place(relx=0.372, rely=0.049, height=31, width=104) self.Label3.configure(activebackground="#f9f9f9") self.Label3.configure(activeforeground="black") self.Label3.configure(background="#d9d9d9") self.Label3.configure(disabledforeground="#a3a3a3") self.Label3.configure(foreground="#000000") self.Label3.configure(highlightbackground="#d9d9d9") self.Label3.configure(highlightcolor="black") self.Label3.configure(text='''Sensor2''') self.Label4 = tk.Label(self.Frame1) self.Label4.place(relx=0.566, rely=0.049, height=31, width=74) self.Label4.configure(activebackground="#f9f9f9") self.Label4.configure(activeforeground="black") self.Label4.configure(background="#d9d9d9") self.Label4.configure(disabledforeground="#a3a3a3") self.Label4.configure(foreground="#000000") self.Label4.configure(highlightbackground="#d9d9d9") self.Label4.configure(highlightcolor="black") self.Label4.configure(text='''Sensor3''') self.Label5 = tk.Label(self.Frame1) self.Label5.place(relx=0.743, rely=0.049, height=31, width=74) self.Label5.configure(activebackground="#f9f9f9") self.Label5.configure(activeforeground="black") self.Label5.configure(background="#d9d9d9") self.Label5.configure(disabledforeground="#a3a3a3") self.Label5.configure(foreground="#000000") self.Label5.configure(highlightbackground="#d9d9d9") self.Label5.configure(highlightcolor="black") self.Label5.configure(text='''Sensor_4''') self.Button1 = tk.Button(self.Frame1) self.Button1.place(relx=0.142, rely=0.444, height=44, width=77) self.Button1.configure(activebackground="#ececec") self.Button1.configure(activeforeground="#000000") self.Button1.configure(background="#d9d9d9") self.Button1.configure(disabledforeground="#a3a3a3") self.Button1.configure(foreground="#000000") self.Button1.configure(highlightbackground="#d9d9d9") self.Button1.configure(highlightcolor="black") self.Button1.configure(pady="0") self.Button1.configure(text='''1 Special char''') self.Button1.configure(width=77) #self.Button1.configure(command=lambda: process(15)) self.Button1.configure(command=lambda: print_char(15)) self.Button2 = tk.Button(self.Frame1) self.Button2.place(relx=0.319, rely=0.444, height=39, width=64) self.Button2.configure(activebackground="#ececec") self.Button2.configure(activeforeground="#000000") self.Button2.configure(background="#d9d9d9") self.Button2.configure(disabledforeground="#a3a3a3") self.Button2.configure(foreground="#000000") self.Button2.configure(highlightbackground="#d9d9d9") self.Button2.configure(highlightcolor="black") self.Button2.configure(pady="0") self.Button2.configure(text='''2 ABC''') #self.Button2.configure(command=lambda: process(11), repeatdelay=500, repeatinterval=100) #self.Button2.bind('<ButtonPress-1>',start_process) #self.Button2.bind('<ButtonRelease-1>',stop_process) #self.Button2.configure(command=lambda: print_char()) self.Button2.configure(command=lambda: print_char(11)) self.Button3 = tk.Button(self.Frame1) self.Button3.place(relx=0.478, rely=0.444, height=39, width=67) self.Button3.configure(activebackground="#ececec") self.Button3.configure(activeforeground="#000000") self.Button3.configure(background="#d9d9d9") self.Button3.configure(disabledforeground="#a3a3a3") self.Button3.configure(foreground="#000000") self.Button3.configure(highlightbackground="#d9d9d9") self.Button3.configure(highlightcolor="black") self.Button3.configure(pady="0") self.Button3.configure(text='''3 DEF''') self.Button3.configure(width=67) self.Button3.configure(command=lambda: print_char(7)) self.Button4 = tk.Button(self.Frame1) self.Button4.place(relx=0.637, rely=0.444, height=44, width=147) self.Button4.configure(activebackground="#ececec") self.Button4.configure(activeforeground="#000000") self.Button4.configure(background="#d9d9d9") self.Button4.configure(disabledforeground="#a3a3a3") self.Button4.configure(foreground="#000000") self.Button4.configure(highlightbackground="#d9d9d9") self.Button4.configure(highlightcolor="black") self.Button4.configure(pady="0") self.Button4.configure(text='''BACK SPACE / CLEAR ALL''') #self.Button4.configure(command=lambda: process(3)) #self.Button4.configure(command=lambda: print_char(3)) self.Button4.bind('<Double-1>',clear_message) self.Button4.configure(command=lambda: delete_char()) self.Button5 = tk.Button(self.Frame1) self.Button5.place(relx=0.637, rely=0.568, height=44, width=147) self.Button5.configure(activebackground="#ececec") self.Button5.configure(activeforeground="#000000") self.Button5.configure(background="#d9d9d9") self.Button5.configure(disabledforeground="#a3a3a3") self.Button5.configure(foreground="#000000") self.Button5.configure(highlightbackground="#d9d9d9") self.Button5.configure(highlightcolor="black") self.Button5.configure(pady="0") self.Button5.configure(text='''SENSOR READING''') self.Button5.configure(command=lambda: open_sensor_reading()) self.Button6 = tk.Button(self.Frame1) self.Button6.place(relx=0.637, rely=0.691, height=44, width=147) self.Button6.configure(activebackground="#ececec") self.Button6.configure(activeforeground="#000000") self.Button6.configure(background="#d9d9d9") self.Button6.configure(disabledforeground="#a3a3a3") self.Button6.configure(foreground="#000000") self.Button6.configure(highlightbackground="#d9d9d9") self.Button6.configure(highlightcolor="black") self.Button6.configure(pady="0") self.Button6.configure(text='''READ MESSAGES''') self.Button6.configure(command=lambda: open_reading_screen()) self.Button7 = tk.Button(self.Frame1) self.Button7.place(relx=0.637, rely=0.815, height=34, width=147) self.Button7.configure(activebackground="#ececec") self.Button7.configure(activeforeground="#000000") self.Button7.configure(background="#d9d9d9") self.Button7.configure(disabledforeground="#a3a3a3") self.Button7.configure(foreground="#000000") self.Button7.configure(highlightbackground="#d9d9d9") self.Button7.configure(highlightcolor="black") self.Button7.configure(pady="0") self.Button7.configure(text='''TRANSMITE''') #self.Button7.configure(command=lambda: process(0)) self.Button7.configure(command=lambda: transmite_message()) self.Button8 = tk.Button(self.Frame1) self.Button8.place(relx=0.142, rely=0.568, height=39, width=74) self.Button8.configure(activebackground="#ececec") self.Button8.configure(activeforeground="#000000") self.Button8.configure(background="#d9d9d9") self.Button8.configure(disabledforeground="#a3a3a3") self.Button8.configure(foreground="#000000") self.Button8.configure(highlightbackground="#d9d9d9") self.Button8.configure(highlightcolor="black") self.Button8.configure(pady="0") self.Button8.configure(text='''4 GHI''') self.Button8.configure(width=74) #self.Button8.configure(command=lambda: process(14)) self.Button8.configure(command=lambda: print_char(14)) self.Button9 = tk.Button(self.Frame1) self.Button9.place(relx=0.319, rely=0.568, height=39, width=61) self.Button9.configure(activebackground="#ececec") self.Button9.configure(activeforeground="#000000") self.Button9.configure(background="#d9d9d9") self.Button9.configure(disabledforeground="#a3a3a3") self.Button9.configure(foreground="#000000") self.Button9.configure(highlightbackground="#d9d9d9") self.Button9.configure(highlightcolor="black") self.Button9.configure(pady="0") self.Button9.configure(text='''5 JKL''') self.Button9.configure(width=61) #self.Button9.configure(command=lambda: process(10)) self.Button9.configure(command=lambda: print_char(10)) self.Button10 = tk.Button(self.Frame1) self.Button10.place(relx=0.478, rely=0.568, height=39, width=63) self.Button10.configure(activebackground="#ececec") self.Button10.configure(activeforeground="#000000") self.Button10.configure(background="#d9d9d9") self.Button10.configure(disabledforeground="#a3a3a3") self.Button10.configure(foreground="#000000") self.Button10.configure(highlightbackground="#d9d9d9") self.Button10.configure(highlightcolor="black") self.Button10.configure(pady="0") self.Button10.configure(text='''6 MNO''') self.Button10.configure(width=63) #self.Button10.configure(command=lambda: print_char(6)) self.Button10.configure(command=lambda: print_char(6)) self.Button11 = tk.Button(self.Frame1) self.Button11.place(relx=0.142, rely=0.691, height=39, width=77) self.Button11.configure(activebackground="#ececec") self.Button11.configure(activeforeground="#000000") self.Button11.configure(background="#d9d9d9") self.Button11.configure(disabledforeground="#a3a3a3") self.Button11.configure(foreground="#000000") self.Button11.configure(highlightbackground="#d9d9d9") self.Button11.configure(highlightcolor="black") self.Button11.configure(pady="0") self.Button11.configure(text='''7 PQR''') self.Button11.configure(width=77) #self.Button11.configure(command=lambda: process(13)) self.Button11.configure(command=lambda: print_char(13)) self.Button12 = tk.Button(self.Frame1) self.Button12.place(relx=0.319, rely=0.691, height=39, width=62) self.Button12.configure(activebackground="#ececec") self.Button12.configure(activeforeground="#000000") self.Button12.configure(background="#d9d9d9") self.Button12.configure(disabledforeground="#a3a3a3") self.Button12.configure(foreground="#000000") self.Button12.configure(highlightbackground="#d9d9d9") self.Button12.configure(highlightcolor="black") self.Button12.configure(pady="0") self.Button12.configure(text='''8 STUV''') #self.Button12.configure(command=lambda: process(9)) self.Button12.configure(command=lambda: print_char(9)) self.Button13 = tk.Button(self.Frame1) self.Button13.place(relx=0.478, rely=0.691, height=39, width=66) self.Button13.configure(activebackground="#ececec") self.Button13.configure(activeforeground="#000000") self.Button13.configure(background="#d9d9d9") self.Button13.configure(disabledforeground="#a3a3a3") self.Button13.configure(foreground="#000000") self.Button13.configure(highlightbackground="#d9d9d9") self.Button13.configure(highlightcolor="black") self.Button13.configure(pady="0") self.Button13.configure(text='''9 WXYZ''') self.Button13.configure(width=66) #self.Button13.configure(command=lambda: process(5)) self.Button13.configure(command=lambda: print_char(5)) self.Button14 = tk.Button(self.Frame1) self.Button14.place(relx=0.142, rely=0.815, height=34, width=82) self.Button14.configure(activebackground="#ececec") self.Button14.configure(activeforeground="#000000") self.Button14.configure(background="#d9d9d9") self.Button14.configure(disabledforeground="#a3a3a3") self.Button14.configure(foreground="#000000") self.Button14.configure(highlightbackground="#d9d9d9") self.Button14.configure(highlightcolor="black") self.Button14.configure(pady="0") self.Button14.configure(text='''*''') self.Button14.configure(width=82) #self.Button14.configure(command=close_window) #self.Button14.configure(command=lambda: process(12)) self.Button14.configure(command=lambda: print_char(12)) self.Button15 = tk.Button(self.Frame1) self.Button15.place(relx=0.319, rely=0.815, height=39, width=66) self.Button15.configure(activebackground="#ececec") self.Button15.configure(activeforeground="#000000") self.Button15.configure(background="#d9d9d9") self.Button15.configure(disabledforeground="#a3a3a3") self.Button15.configure(foreground="#000000") self.Button15.configure(highlightbackground="#d9d9d9") self.Button15.configure(highlightcolor="black") self.Button15.configure(pady="0") self.Button15.configure(text='''0 SPACE''') self.Button15.configure(width=66) #self.Button15.configure(command=lambda: process(8)) self.Button15.configure(command=lambda: print_char(8)) self.Button16 = tk.Button(self.Frame1) self.Button16.place(relx=0.478, rely=0.815, height=34, width=58) self.Button16.configure(activebackground="#ececec") self.Button16.configure(activeforeground="#000000") self.Button16.configure(background="#d9d9d9") self.Button16.configure(disabledforeground="#a3a3a3") self.Button16.configure(foreground="#000000") self.Button16.configure(highlightbackground="#d9d9d9") self.Button16.configure(highlightcolor="black") self.Button16.configure(pady="0") self.Button16.configure(text='''# >''') self.Button16.configure(width=58) #self.Button16.bind('<Double-1>',add_separator) self.Button16.configure(command=lambda: print_char(4)) #self.Button16.configure(command=lambda: process(4)) num_press=0 message=[] steps=0 i=0 x=0 key_pressed=x #message_string=" #print(message_string) #p1 = subprocess.Popen(["minimodem" , '--tx' , '300'], stdin=subprocess.PIPE) #p1.stdin.write(bytes(message_ if __name__ == '__main__': vp_start_gui() please help ! -- https://mail.python.org/mailman/listinfo/python-list