RoboDK Forum
non-blocking pop up- Printable Version

+- RoboDK Forum (//www.sinclairbody.com/forum)
+-- Forum: RoboDK (EN) (//www.sinclairbody.com/forum/Forum-RoboDK-EN)
+--- Forum: RoboDK API (//www.sinclairbody.com/forum/Forum-RoboDK-API)
+--- Thread: non-blocking pop up (/ Thread-non-blocking-pop -up)



non-blocking pop up-Vincent-03-09-2020

is there a way to create a non-blocking pop up inside an app, to instruct a user abaut what to do next?


RE: non-blocking pop up-Albert-03-10-2020

Hi Vincent,

Yes this is possible. I recommend you to use Python's tkinter to do so. The code below shows 3 useful ways to implement popups. This will block the code in your app, not RoboDK. If you need to run code while your user interface is blocked you can run it on a separate thread.

Albert

Code:
if sys.version_info[0] < 3: # Python 2.X only:
import Tkinter as tk
import tkMessageBox as messagebox
else: # Python 3.x only
import tkinter as tk
from tkinter import messagebox

def ShowMessage(msg, title=None):
print(msg)
if title is None:
title = msg

root = tk.Tk()
root.overrideredirect (1)
root.withdraw()
root.attributes("-topmost", True)
result = messagebox.showinfo(title, msg) #, icon='warning')#, parent=texto)
root.destroy()
return result

def ShowMessageYesNo(msg, title=None):
print(msg)
if title is None:
title = msg

root = tk.Tk()
root.overrideredirect (1)
root.withdraw()
root.attributes("-topmost", True)
result = messagebox.askyesno(title, msg) #, icon='warning')#, parent=texto)
root.destroy()
return result

def ShowMessageYesNoCancel(msg, title=None):
print(msg)
if title is None:
title = msg

root = tk.Tk()
root.overrideredirect (1)
root.withdraw()
root.attributes("-topmost", True)
result = messagebox.askyesnocancel(title, msg)#, icon='warning')#, parent=texto)
root.destroy()
return result