-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDocked_UI.py
41 lines (32 loc) · 1.2 KB
/
Docked_UI.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from tkinter import *
from robolink import *
import threading
# Create a new window
window = tkinter.Tk()
# Close the window
def onClose():
window.destroy()
quit(0)
# Trigger Select button
# IMPORTANT: We need to run the action on a separate thread because
# (otherwise, if we want to interact with RoboDK window it will freeze)
def on_btnSelect():
def thread_btnSelect():
# Run button action (example to select an item and display its name)
RDK = Robolink()
item = RDK.ItemUserPick('Select an item')
if item.Valid():
RDK.ShowMessage("You selected the item: " + item.Name())
threading.Thread(target=thread_btnSelect).start()
# Set the window title (must be unique for the docking to work, try to be creative)
window_title = 'RoboDK API Docked Window'
window.title(window_title)
# Delete the window when we close it
window.protocol("WM_DELETE_WINDOW", onClose)
# Add a button
btnSelect = Button(window, text='Trigger on_btnSelect', height=5, width=60, command=on_btnSelect)
btnSelect.pack(fill=X)
# Embed the window
EmbedWindow(window_title)
# Run the window event loop. This is like an app and will block until we close the window
window.mainloop()