Touch screen – operator confirmation of action

Machine safety considerations again… I tried to find a good way to confirm operator inputs which will lead to machine movement.

First, I had planned to use a physical button on the control panel which needs to be held down in addition to activating certain functions from the screen (cycle start, probing, etc.)… Though this would have been quite easy, it did not yet fully satisfy my „UI heart“.

Solution

In mobile applications we are already used to swiping – I think it’s a safer option compared to a simple confirmation button, as it requires an intentional move in one direction.

  • Display a popup window asking for confirmation
  • Using a slider to confirm the action
  • Close the popup and continue with the requested action

The image was again created in PowerPoint and saved as PNG.

Code

Thanks to tkinter, the code is fairly simple. Don’t forget to add your own action to the code…

UPDATE 02.07.2023: Popup is now frameless / without header bar.

from tkinter import *
  
root = Tk()

# remove title bar... nice little tweak :)
root.overrideredirect(True)
root.overrideredirect(False)
  
# Setup
root.geometry("500x290")
root.configure(bg='#3E3E3E')
  
bg = PhotoImage(file = "ico_confirm.png")

# BG image via canvas
canvas1 = Canvas( root, width = 200,
                 height = 400, highlightthickness=0)
  
canvas1.pack(fill = "both", expand = True)
  
# Logic 
def sendVal(val): 

	global slider
	global root
	
	# Check if slides reached the end
	if int(val) == 100: 
		root.destroy()
		# YOUR ACTIONS GOES HERE 



# Construct canvas and slider
canvas1.create_image( -10, -10, image = bg, anchor = "nw")
slider = Scale(root, from_=0, to=100, length=150, orient=HORIZONTAL, bd=0, bg='#3E3E3E',  	showvalue=0, fg='white', command=sendVal)
slider_canvas = canvas1.create_window( 280, 205, 
                                       anchor = "nw",
                                       window = slider)


root.mainloop()

Improvements

Small changes planned to improve usability:

  • Add a time delay, after which the slider will reset to the zero position. This is for cases where it does not hit the end (operator having second thoughts…).
  • Add a custom slider handle which is easier to grab

Schreibe einen Kommentar 0

Your email address will not be published. Required fields are marked *