forked from mrehqe/pyneje
-
Notifications
You must be signed in to change notification settings - Fork 2
/
pyneje.py
41 lines (31 loc) · 1.12 KB
/
pyneje.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
import Tkinter
import os
import platform
import subprocess
import time
import hal.engraver
import ui_widgets.serialdialog
# Hack from stackoverflow to raise the window on most platforms.
from pyneje_gui.main import GUI
def raise_app(root_tk):
root_tk.attributes("-topmost", True)
if platform.system() == 'Darwin':
tmpl = 'tell application "System Events" to set frontmost of every process whose unix id is {} to true'
script = tmpl.format(os.getpid())
output = subprocess.check_call(['/usr/bin/osascript', '-e', script])
root_tk.after(0, lambda: root_tk.attributes("-topmost", False))
if __name__ == "__main__":
root = Tkinter.Tk()
raise_app(root)
root.update()
if False:
ui = GUI(root, None).run()
else:
serialPort = ui_widgets.serialdialog.SerialSelection(root, hal.engraver.get_serial_ports()).returnValue
if serialPort is None:
print "Can't operate without a valid serial port"
exit(1)
device = hal.engraver.Engraver(serialPort)
device.reset()
ui = GUI(root, device).run()
device.disconnect()