indipygui 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- indipygui-0.0.1/LICENSE +21 -0
- indipygui-0.0.1/PKG-INFO +120 -0
- indipygui-0.0.1/README.md +102 -0
- indipygui-0.0.1/indipygui/__init__.py +4 -0
- indipygui-0.0.1/indipygui/__main__.py +43 -0
- indipygui-0.0.1/indipygui/devicesc.py +173 -0
- indipygui-0.0.1/indipygui/igui.py +216 -0
- indipygui-0.0.1/indipygui/startsc.py +290 -0
- indipygui-0.0.1/indipygui/vectorsc.py +709 -0
- indipygui-0.0.1/pyproject.toml +21 -0
indipygui-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 bernie-skipole
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
indipygui-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: indipygui
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A GUI client which can be used to control remote instruments using the INDI protocol.
|
|
5
|
+
Keywords: indi,client,astronomy,instrument
|
|
6
|
+
Author-email: Bernard Czenkusz <bernie@skipole.co.uk>
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Topic :: Scientific/Engineering :: Astronomy
|
|
11
|
+
Classifier: Topic :: Scientific/Engineering :: Interface Engine/Protocol Translator
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: indipyclient>=0.8.6
|
|
14
|
+
Requires-Dist: customtkinter>=6.0.0
|
|
15
|
+
Project-URL: Source, https://github.com/bernie-skipole/indipygui
|
|
16
|
+
Import-Name: indipygui
|
|
17
|
+
|
|
18
|
+
# indipygui
|
|
19
|
+
|
|
20
|
+
GUI client to connect to an INDI service
|
|
21
|
+
|
|
22
|
+
INDI defines a protocol for the remote control of instruments.
|
|
23
|
+
|
|
24
|
+
INDI - Instrument Neutral Distributed Interface.
|
|
25
|
+
|
|
26
|
+
See https://en.wikipedia.org/wiki/Instrument_Neutral_Distributed_Interface
|
|
27
|
+
|
|
28
|
+
The INDI protocol defines the format of the data sent, such as light, number, text, switch or BLOB (Binary Large Object). The client is general purpose, taking the format of switches, numbers etc., from the protocol.
|
|
29
|
+
|
|
30
|
+
indipygui uses the tkinter package, which most Python distributions include, but some, such as Debian do not. As it is a system package it cannot be installed from PyPI. If using Debian, or Debian derived distributions you may need to install tkinter with:
|
|
31
|
+
|
|
32
|
+
sudo apt install python3-tk
|
|
33
|
+
|
|
34
|
+
indipygui can be installed from Pypi:
|
|
35
|
+
|
|
36
|
+
https://pypi.org/project/indipygui
|
|
37
|
+
|
|
38
|
+
The client is typically run from a virtual environment with
|
|
39
|
+
|
|
40
|
+
python -m indipygui
|
|
41
|
+
|
|
42
|
+
Or if you use uv, it can be loaded and run with:
|
|
43
|
+
|
|
44
|
+
uvx indipygui
|
|
45
|
+
|
|
46
|
+
The package help is:
|
|
47
|
+
|
|
48
|
+
usage: indipygui [options]
|
|
49
|
+
|
|
50
|
+
Client to communicate to an INDI service.
|
|
51
|
+
|
|
52
|
+
options:
|
|
53
|
+
-h, --help show this help message and exit
|
|
54
|
+
--port PORT Port of the INDI server (default 7624).
|
|
55
|
+
--host HOST Hostname/IP of the INDI server (default localhost).
|
|
56
|
+
--blobfolder BLOBFOLDER Optional folder where BLOB's will be saved.
|
|
57
|
+
|
|
58
|
+
--version show program's version number and exit
|
|
59
|
+
|
|
60
|
+
If you want to create your own startup script, importing indipygui gives two objects:
|
|
61
|
+
|
|
62
|
+
indipygui.version
|
|
63
|
+
|
|
64
|
+
indipygui.IPyGui(host="localhost", port=7624, blobfolder=None)
|
|
65
|
+
|
|
66
|
+
If ipygui is your instance of the above class, then to run it call:
|
|
67
|
+
|
|
68
|
+
ipygui.rungui()
|
|
69
|
+
|
|
70
|
+
This is a blocking call, and will open the gui window.
|
|
71
|
+
|
|
72
|
+
This client should work with any INDI service, however associated packages by the same author are:
|
|
73
|
+
|
|
74
|
+
## indipyserver
|
|
75
|
+
|
|
76
|
+
A Python INDI server, serves INDI drivers on a port.
|
|
77
|
+
|
|
78
|
+
https://github.com/bernie-skipole/indipyserver
|
|
79
|
+
|
|
80
|
+
https://pypi.org/project/indipyserver/
|
|
81
|
+
|
|
82
|
+
https://indipyserver.readthedocs.io
|
|
83
|
+
|
|
84
|
+
## indipydriver
|
|
85
|
+
|
|
86
|
+
Package with classes used to create INDI drivers.
|
|
87
|
+
|
|
88
|
+
https://github.com/bernie-skipole/indipydriver
|
|
89
|
+
|
|
90
|
+
https://pypi.org/project/indipydriver
|
|
91
|
+
|
|
92
|
+
https://indipydriver.readthedocs.io
|
|
93
|
+
|
|
94
|
+
## indipyweb
|
|
95
|
+
|
|
96
|
+
Web server and INDI client, connects to an INDI serving port, and serves client pages for connected browsers.
|
|
97
|
+
|
|
98
|
+
https://github.com/bernie-skipole/indipyweb
|
|
99
|
+
|
|
100
|
+
https://pypi.org/project/indipyweb
|
|
101
|
+
|
|
102
|
+
## indipyterm
|
|
103
|
+
|
|
104
|
+
A terminal based INDI client, connects to an INDI serving port.
|
|
105
|
+
|
|
106
|
+
https://github.com/bernie-skipole/indipyterm
|
|
107
|
+
|
|
108
|
+
https://pypi.org/project/indipyterm/
|
|
109
|
+
|
|
110
|
+
## indipyclient
|
|
111
|
+
|
|
112
|
+
A Python package providing classes which operate client connectivity to a serving port. Used by indipygui and the above clients.
|
|
113
|
+
|
|
114
|
+
https://github.com/bernie-skipole/indipyclient
|
|
115
|
+
|
|
116
|
+
https://pypi.org/project/indipyclient
|
|
117
|
+
|
|
118
|
+
https://indipyclient.readthedocs.io
|
|
119
|
+
|
|
120
|
+
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# indipygui
|
|
2
|
+
|
|
3
|
+
GUI client to connect to an INDI service
|
|
4
|
+
|
|
5
|
+
INDI defines a protocol for the remote control of instruments.
|
|
6
|
+
|
|
7
|
+
INDI - Instrument Neutral Distributed Interface.
|
|
8
|
+
|
|
9
|
+
See https://en.wikipedia.org/wiki/Instrument_Neutral_Distributed_Interface
|
|
10
|
+
|
|
11
|
+
The INDI protocol defines the format of the data sent, such as light, number, text, switch or BLOB (Binary Large Object). The client is general purpose, taking the format of switches, numbers etc., from the protocol.
|
|
12
|
+
|
|
13
|
+
indipygui uses the tkinter package, which most Python distributions include, but some, such as Debian do not. As it is a system package it cannot be installed from PyPI. If using Debian, or Debian derived distributions you may need to install tkinter with:
|
|
14
|
+
|
|
15
|
+
sudo apt install python3-tk
|
|
16
|
+
|
|
17
|
+
indipygui can be installed from Pypi:
|
|
18
|
+
|
|
19
|
+
https://pypi.org/project/indipygui
|
|
20
|
+
|
|
21
|
+
The client is typically run from a virtual environment with
|
|
22
|
+
|
|
23
|
+
python -m indipygui
|
|
24
|
+
|
|
25
|
+
Or if you use uv, it can be loaded and run with:
|
|
26
|
+
|
|
27
|
+
uvx indipygui
|
|
28
|
+
|
|
29
|
+
The package help is:
|
|
30
|
+
|
|
31
|
+
usage: indipygui [options]
|
|
32
|
+
|
|
33
|
+
Client to communicate to an INDI service.
|
|
34
|
+
|
|
35
|
+
options:
|
|
36
|
+
-h, --help show this help message and exit
|
|
37
|
+
--port PORT Port of the INDI server (default 7624).
|
|
38
|
+
--host HOST Hostname/IP of the INDI server (default localhost).
|
|
39
|
+
--blobfolder BLOBFOLDER Optional folder where BLOB's will be saved.
|
|
40
|
+
|
|
41
|
+
--version show program's version number and exit
|
|
42
|
+
|
|
43
|
+
If you want to create your own startup script, importing indipygui gives two objects:
|
|
44
|
+
|
|
45
|
+
indipygui.version
|
|
46
|
+
|
|
47
|
+
indipygui.IPyGui(host="localhost", port=7624, blobfolder=None)
|
|
48
|
+
|
|
49
|
+
If ipygui is your instance of the above class, then to run it call:
|
|
50
|
+
|
|
51
|
+
ipygui.rungui()
|
|
52
|
+
|
|
53
|
+
This is a blocking call, and will open the gui window.
|
|
54
|
+
|
|
55
|
+
This client should work with any INDI service, however associated packages by the same author are:
|
|
56
|
+
|
|
57
|
+
## indipyserver
|
|
58
|
+
|
|
59
|
+
A Python INDI server, serves INDI drivers on a port.
|
|
60
|
+
|
|
61
|
+
https://github.com/bernie-skipole/indipyserver
|
|
62
|
+
|
|
63
|
+
https://pypi.org/project/indipyserver/
|
|
64
|
+
|
|
65
|
+
https://indipyserver.readthedocs.io
|
|
66
|
+
|
|
67
|
+
## indipydriver
|
|
68
|
+
|
|
69
|
+
Package with classes used to create INDI drivers.
|
|
70
|
+
|
|
71
|
+
https://github.com/bernie-skipole/indipydriver
|
|
72
|
+
|
|
73
|
+
https://pypi.org/project/indipydriver
|
|
74
|
+
|
|
75
|
+
https://indipydriver.readthedocs.io
|
|
76
|
+
|
|
77
|
+
## indipyweb
|
|
78
|
+
|
|
79
|
+
Web server and INDI client, connects to an INDI serving port, and serves client pages for connected browsers.
|
|
80
|
+
|
|
81
|
+
https://github.com/bernie-skipole/indipyweb
|
|
82
|
+
|
|
83
|
+
https://pypi.org/project/indipyweb
|
|
84
|
+
|
|
85
|
+
## indipyterm
|
|
86
|
+
|
|
87
|
+
A terminal based INDI client, connects to an INDI serving port.
|
|
88
|
+
|
|
89
|
+
https://github.com/bernie-skipole/indipyterm
|
|
90
|
+
|
|
91
|
+
https://pypi.org/project/indipyterm/
|
|
92
|
+
|
|
93
|
+
## indipyclient
|
|
94
|
+
|
|
95
|
+
A Python package providing classes which operate client connectivity to a serving port. Used by indipygui and the above clients.
|
|
96
|
+
|
|
97
|
+
https://github.com/bernie-skipole/indipyclient
|
|
98
|
+
|
|
99
|
+
https://pypi.org/project/indipyclient
|
|
100
|
+
|
|
101
|
+
https://indipyclient.readthedocs.io
|
|
102
|
+
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import sys, argparse, pathlib
|
|
4
|
+
|
|
5
|
+
from .igui import IPyGui, version
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
if sys.version_info < (3, 10):
|
|
9
|
+
raise ImportError('indipygui requires Python >= 3.10')
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def main():
|
|
13
|
+
"""The commandline entry point to run the client."""
|
|
14
|
+
|
|
15
|
+
parser = argparse.ArgumentParser(usage="indipygui [options]",
|
|
16
|
+
description="Client to communicate to an INDI service.")
|
|
17
|
+
parser.add_argument("--port", type=int, default=7624, help="Port of the INDI server (default 7624).")
|
|
18
|
+
parser.add_argument("--host", default="localhost", help="Hostname/IP of the INDI server (default localhost).")
|
|
19
|
+
parser.add_argument("--blobfolder", help="Optional folder where BLOB's will be saved.")
|
|
20
|
+
parser.add_argument("--version", action="version", version=version)
|
|
21
|
+
args = parser.parse_args()
|
|
22
|
+
|
|
23
|
+
if args.blobfolder:
|
|
24
|
+
try:
|
|
25
|
+
blobfolder = pathlib.Path(args.blobfolder).expanduser().resolve()
|
|
26
|
+
except Exception:
|
|
27
|
+
print("Error: If given, the BLOB's folder should be an existing directory")
|
|
28
|
+
return 1
|
|
29
|
+
else:
|
|
30
|
+
if not blobfolder.is_dir():
|
|
31
|
+
print("Error: If given, the BLOB's folder should be an existing directory")
|
|
32
|
+
return 1
|
|
33
|
+
else:
|
|
34
|
+
blobfolder = None
|
|
35
|
+
|
|
36
|
+
# create the IPyGui object
|
|
37
|
+
ipygui = IPyGui(host=args.host, port=args.port, blobfolder=blobfolder)
|
|
38
|
+
# and run it
|
|
39
|
+
ipygui.rungui()
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
if __name__ == "__main__":
|
|
43
|
+
sys.exit(main())
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
|
|
2
|
+
import collections, functools
|
|
3
|
+
|
|
4
|
+
import customtkinter
|
|
5
|
+
|
|
6
|
+
from .vectorsc import LightPane, SwitchPane, TextPane, NumberPane, BLOBPane
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def localtimestring(t):
|
|
10
|
+
"Return a string of the local time (not date)"
|
|
11
|
+
localtime = t.astimezone(tz=None)
|
|
12
|
+
# convert microsecond to integer between 0 and 100
|
|
13
|
+
ms = localtime.microsecond//10000
|
|
14
|
+
return f"{localtime.strftime('%H:%M:%S')}.{ms:0>2d}"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class DeviceScreen:
|
|
20
|
+
|
|
21
|
+
def __init__(self, ipygui, devicename):
|
|
22
|
+
"""A Device screen, opens a CTkToplevel when user picks a device."""
|
|
23
|
+
self.ipygui = ipygui
|
|
24
|
+
self.devicename = devicename
|
|
25
|
+
self.devicewin = customtkinter.CTkToplevel(ipygui.app)
|
|
26
|
+
# call made when user closes a devicewin
|
|
27
|
+
closecommand = functools.partial(self.ipygui._on_close_devicesc, devicename)
|
|
28
|
+
self.devicewin.protocol("WM_DELETE_WINDOW", closecommand)
|
|
29
|
+
self.devicewin.geometry("1000x800")
|
|
30
|
+
self.devicewin.title("Device : " + devicename)
|
|
31
|
+
self.devicewin.grid_columnconfigure(0, weight=1)
|
|
32
|
+
self.devicewin.grid_rowconfigure(1, weight=1)
|
|
33
|
+
|
|
34
|
+
# create two frames, a messages frame holding device messages
|
|
35
|
+
# a frame to hold the tabbed device contents
|
|
36
|
+
|
|
37
|
+
self.devicemessagepane = DeviceMessagePane(self.ipygui, self.devicewin, self.devicename)
|
|
38
|
+
|
|
39
|
+
self.main_frame = customtkinter.CTkScrollableFrame(self.devicewin)
|
|
40
|
+
self.main_frame.grid(row=1, column=0, padx=4, pady=4, sticky="nswe")
|
|
41
|
+
self.main_frame.grid_columnconfigure(0, weight=1)
|
|
42
|
+
|
|
43
|
+
# Set a tabview into self.main_frame
|
|
44
|
+
self.grouptabview = customtkinter.CTkTabview(self.main_frame, anchor="nw")
|
|
45
|
+
self.grouptabview.grid(row=0, column=0, padx=4, sticky="nswe")
|
|
46
|
+
groupset = set(vector.group for vector in self.ipygui.snapshot[devicename].values() if vector.enable)
|
|
47
|
+
groups = list(groupset)
|
|
48
|
+
groups.sort()
|
|
49
|
+
self.grouptabs = {} # name:tab
|
|
50
|
+
for group in groups:
|
|
51
|
+
gtab = self.grouptabview.add(group)
|
|
52
|
+
gtab.grid_columnconfigure(0, weight=1)
|
|
53
|
+
self.grouptabs[group] = gtab
|
|
54
|
+
|
|
55
|
+
# create a vector frame, set in dictionary of name:vectorpane object
|
|
56
|
+
self.vectorframes = {}
|
|
57
|
+
# vector_row - the grid row of each vector frame
|
|
58
|
+
self.vector_row = 0
|
|
59
|
+
|
|
60
|
+
# add vectors to the gtabs
|
|
61
|
+
for vectorname in self.ipygui.snapshot[devicename].keys():
|
|
62
|
+
self.add_vector(vectorname)
|
|
63
|
+
|
|
64
|
+
def add_message(self, message):
|
|
65
|
+
self.devicemessagepane.add_message(message)
|
|
66
|
+
|
|
67
|
+
def add_vector(self, vectorname):
|
|
68
|
+
"Called when a define vector is called, if this vector not already known about, it is added"
|
|
69
|
+
if vectorname in self.vectorframes:
|
|
70
|
+
# must update the frame here since defines can include up to date values
|
|
71
|
+
self.set_vector(vectorname)
|
|
72
|
+
return
|
|
73
|
+
# get the vector
|
|
74
|
+
vector = self.ipygui.snapshot[self.devicename][vectorname]
|
|
75
|
+
if vector.group not in self.grouptabs:
|
|
76
|
+
groups = list(self.grouptabs.keys())
|
|
77
|
+
groups.append(vector.group)
|
|
78
|
+
groups.sort()
|
|
79
|
+
index = groups.index(vector.group)
|
|
80
|
+
gtab = self.grouptabview.insert(index, vector.group)
|
|
81
|
+
gtab.grid_columnconfigure(0, weight=1)
|
|
82
|
+
self.grouptabs[vector.group] = gtab
|
|
83
|
+
else:
|
|
84
|
+
gtab = self.grouptabs[vector.group]
|
|
85
|
+
# make vector object which creates the frame
|
|
86
|
+
if vector.vectortype == "LightVector":
|
|
87
|
+
self.vectorframes[vectorname] = LightPane(self.ipygui, gtab, vector, self.vector_row)
|
|
88
|
+
elif vector.vectortype == "SwitchVector":
|
|
89
|
+
self.vectorframes[vectorname] = SwitchPane(self.ipygui, gtab, vector, self.vector_row)
|
|
90
|
+
elif vector.vectortype == "TextVector":
|
|
91
|
+
self.vectorframes[vectorname] = TextPane(self.ipygui, gtab, vector, self.vector_row)
|
|
92
|
+
elif vector.vectortype == "NumberVector":
|
|
93
|
+
self.vectorframes[vectorname] = NumberPane(self.ipygui, gtab, vector, self.vector_row)
|
|
94
|
+
elif vector.vectortype == "BLOBVector":
|
|
95
|
+
self.vectorframes[vectorname] = BLOBPane(self.ipygui, gtab, vector, self.vector_row)
|
|
96
|
+
|
|
97
|
+
self.vector_row += 1
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def set_vector(self, vectorname):
|
|
101
|
+
"Called when a set vector is called"
|
|
102
|
+
if vectorname not in self.vectorframes:
|
|
103
|
+
# No need to update the frame, as it is not known about
|
|
104
|
+
return
|
|
105
|
+
# get the vector
|
|
106
|
+
vector = self.ipygui.snapshot[self.devicename][vectorname]
|
|
107
|
+
if not vector.enable:
|
|
108
|
+
return
|
|
109
|
+
# get the vector pane and call its set_vector method
|
|
110
|
+
vectorpane = self.vectorframes[vectorname]
|
|
111
|
+
vectorpane.set_vector(vector)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def del_vector(self, vectorname):
|
|
115
|
+
"A delete event has been received, vector deleted"
|
|
116
|
+
if vectorname not in self.ipygui.snapshot[self.devicename]:
|
|
117
|
+
return
|
|
118
|
+
vector = self.ipygui.snapshot[self.devicename][vectorname]
|
|
119
|
+
if vectorname not in self.vectorframes:
|
|
120
|
+
return
|
|
121
|
+
# delete the vector frame
|
|
122
|
+
self.vectorframes[vectorname].vector_frame.destroy()
|
|
123
|
+
del self.vectorframes[vectorname]
|
|
124
|
+
group = vector.group
|
|
125
|
+
# check if any vectors are left in this group
|
|
126
|
+
vectorsleft = False
|
|
127
|
+
for vctr in self.ipygui.snapshot[self.devicename].values():
|
|
128
|
+
if vctr.group == group and vctr.enable:
|
|
129
|
+
vectorsleft = True
|
|
130
|
+
if not vectorsleft:
|
|
131
|
+
# delete this group
|
|
132
|
+
self.grouptabview.delete(group)
|
|
133
|
+
del self.grouptabs[group]
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
class DeviceMessagePane:
|
|
138
|
+
|
|
139
|
+
def __init__(self, ipygui, devicewin, devicename):
|
|
140
|
+
self.ipygui = ipygui
|
|
141
|
+
self.devicewin = devicewin
|
|
142
|
+
self.devicename = devicename
|
|
143
|
+
|
|
144
|
+
self.device_message_frame = customtkinter.CTkFrame(self.devicewin)
|
|
145
|
+
self.device_message_frame.grid(row=0, column=0, padx=4, pady=4, sticky="nswe")
|
|
146
|
+
self.device_message_frame.grid_columnconfigure(0, weight=1)
|
|
147
|
+
|
|
148
|
+
self.textbox = customtkinter.CTkTextbox(self.device_message_frame, corner_radius=0, fg_color="transparent", height=120, wrap="none")
|
|
149
|
+
self.textbox.grid(row=0, column=0, sticky="nsew")
|
|
150
|
+
|
|
151
|
+
# self.textlist is a deque of messages
|
|
152
|
+
self.textlist = collections.deque(maxlen=4)
|
|
153
|
+
|
|
154
|
+
self.add_message(f"Messages from {self.devicename} will appear here")
|
|
155
|
+
# add messages
|
|
156
|
+
messagelist = list(self.ipygui.snapshot[devicename].messages)
|
|
157
|
+
for message in reversed(messagelist):
|
|
158
|
+
self.add_message(message)
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def add_message(self, message):
|
|
162
|
+
"Adds latest message to MessagePane, and limits the number of messages to 4"
|
|
163
|
+
if isinstance(message, str):
|
|
164
|
+
self.textlist.append(message)
|
|
165
|
+
else:
|
|
166
|
+
self.textlist.append(localtimestring(message[0]) + " " + message[1])
|
|
167
|
+
self.textbox.configure(state="normal")
|
|
168
|
+
self.textbox.delete('0.0', "end")
|
|
169
|
+
self.textbox.insert("0.0", "\n".join(list(self.textlist)) + "\n")
|
|
170
|
+
self.textbox.configure(state="disabled")
|
|
171
|
+
self.textbox.see(f"{len(self.textlist)-1}.0")
|
|
172
|
+
|
|
173
|
+
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
|
|
2
|
+
import pathlib, queue, threading, asyncio, logging
|
|
3
|
+
|
|
4
|
+
from indipyclient.queclient import QueClient
|
|
5
|
+
|
|
6
|
+
import customtkinter
|
|
7
|
+
|
|
8
|
+
from . import startsc, devicesc
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
logger = logging.getLogger()
|
|
12
|
+
logger.addHandler(logging.NullHandler())
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
version = "0.0.1"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class IPyGui():
|
|
22
|
+
"""An INDI GUI."""
|
|
23
|
+
|
|
24
|
+
def __init__(self, host="localhost", port=7624, blobfolder=None):
|
|
25
|
+
self.indihost = host
|
|
26
|
+
self.indiport = port
|
|
27
|
+
if blobfolder:
|
|
28
|
+
bf = pathlib.Path(blobfolder).expanduser().resolve()
|
|
29
|
+
if bf.is_dir():
|
|
30
|
+
self._blobfolder = bf
|
|
31
|
+
else:
|
|
32
|
+
self._blobfolder = None
|
|
33
|
+
else:
|
|
34
|
+
self._blobfolder = None
|
|
35
|
+
|
|
36
|
+
# create two queues
|
|
37
|
+
# rxque giving received data
|
|
38
|
+
self._rxque = queue.Queue(maxsize=4)
|
|
39
|
+
# txque transmit data
|
|
40
|
+
self._txque = queue.Queue(maxsize=4)
|
|
41
|
+
|
|
42
|
+
# An INDI QueClient will be created in a thread when rungui is called
|
|
43
|
+
self.qclient = None
|
|
44
|
+
self._clientthread = None
|
|
45
|
+
|
|
46
|
+
# create a tkinter app
|
|
47
|
+
self.app = customtkinter.CTk()
|
|
48
|
+
self.app.title(f"indipygui version {version}")
|
|
49
|
+
|
|
50
|
+
# self.sc will be the main startscreen, created when rungui is called
|
|
51
|
+
self.sc = None
|
|
52
|
+
|
|
53
|
+
# This dictionary will be a dictionary of devicename:devicesc, created as device windows are created
|
|
54
|
+
self.devicewindows = {}
|
|
55
|
+
|
|
56
|
+
# This is updated with the latest client snapshot
|
|
57
|
+
self.snapshot = None
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def newconnection(self):
|
|
62
|
+
"Creates a new instance of self.qclient, with a new connection"
|
|
63
|
+
|
|
64
|
+
if self._clientthread is None or not self._clientthread.is_alive():
|
|
65
|
+
self.qclient = QueClient(self._txque, self._rxque, self.indihost, self.indiport, self._blobfolder)
|
|
66
|
+
self._clientthread = threading.Thread(target=asyncio.run, args=(self.qclient.asyncrun(),))
|
|
67
|
+
self._clientthread.start()
|
|
68
|
+
self.sc.set_connected()
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def send_data(self, data):
|
|
72
|
+
"Send data down self._txque"
|
|
73
|
+
self._txque.put(data)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def closeconnection(self):
|
|
77
|
+
"Shut down the connection"
|
|
78
|
+
# Send a None value to shut down the queclient
|
|
79
|
+
self._txque.put(None)
|
|
80
|
+
# and wait for the clientthread to stop
|
|
81
|
+
if self._clientthread is not None and self._clientthread.is_alive():
|
|
82
|
+
self._clientthread.join()
|
|
83
|
+
self.qclient = None
|
|
84
|
+
self.sc.set_disconnected()
|
|
85
|
+
self.sc.add_message("Client disconnected")
|
|
86
|
+
self.sc.clear_devices()
|
|
87
|
+
for dsc in self.devicewindows.values():
|
|
88
|
+
if dsc.devicewin.winfo_exists():
|
|
89
|
+
dsc.devicewin.destroy()
|
|
90
|
+
self.devicewindows.clear()
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def _set_blobfolder(self, blobfolder):
|
|
94
|
+
self._blobfolder = blobfolder
|
|
95
|
+
if self.qclient is not None:
|
|
96
|
+
self.qclient.BLOBfolder = blobfolder
|
|
97
|
+
|
|
98
|
+
def _get_blobfolder(self):
|
|
99
|
+
return self._blobfolder
|
|
100
|
+
|
|
101
|
+
blobfolder = property(fget=_get_blobfolder, fset=_set_blobfolder)
|
|
102
|
+
|
|
103
|
+
def rungui(self):
|
|
104
|
+
"Create INDI QueClient and run it in a thread Make the StartScreen and run the gui app"
|
|
105
|
+
|
|
106
|
+
self.app.geometry("1000x600")
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
# create the startscreen
|
|
110
|
+
self.sc = startsc.StartScreen(self)
|
|
111
|
+
|
|
112
|
+
# run the queclient in its own thread
|
|
113
|
+
self.newconnection()
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
# start checking the rxque
|
|
117
|
+
self.readrxque()
|
|
118
|
+
|
|
119
|
+
self.app.mainloop()
|
|
120
|
+
|
|
121
|
+
# When the gui loop ends, close the connection
|
|
122
|
+
self._txque.put(None)
|
|
123
|
+
|
|
124
|
+
if self._clientthread is not None and self._clientthread.is_alive():
|
|
125
|
+
self._clientthread.join()
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def open_devicesc(self, devicename):
|
|
129
|
+
if devicename not in self.devicewindows or not self.devicewindows[devicename].devicewin.winfo_exists():
|
|
130
|
+
self.devicewindows[devicename] = devicesc.DeviceScreen(self, devicename)
|
|
131
|
+
else:
|
|
132
|
+
self.devicewindows[devicename].devicewin.lift()
|
|
133
|
+
self.devicewindows[devicename].devicewin.focus() # if window exists focus it
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def _on_close_devicesc(self, devicename):
|
|
137
|
+
"Called by a user closing a device screen"
|
|
138
|
+
if devicename not in self.devicewindows:
|
|
139
|
+
return
|
|
140
|
+
if self.devicewindows[devicename].devicewin.winfo_exists():
|
|
141
|
+
self.devicewindows[devicename].devicewin.destroy()
|
|
142
|
+
del self.devicewindows[devicename]
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def readrxque(self):
|
|
146
|
+
"Read rxque"
|
|
147
|
+
try:
|
|
148
|
+
event = self._rxque.get_nowait()
|
|
149
|
+
except queue.Empty:
|
|
150
|
+
# and read again after 100ms
|
|
151
|
+
self.app.after(100, self.readrxque)
|
|
152
|
+
return
|
|
153
|
+
|
|
154
|
+
self.snapshot = event.snapshot
|
|
155
|
+
|
|
156
|
+
if event.eventtype == "Message":
|
|
157
|
+
if event.devicename is None:
|
|
158
|
+
# Add client message to the startscreen
|
|
159
|
+
self.sc.add_message(self.snapshot.messages[0])
|
|
160
|
+
elif event.devicename in self.devicewindows and self.devicewindows[event.devicename].devicewin.winfo_exists():
|
|
161
|
+
dsc = self.devicewindows[event.devicename]
|
|
162
|
+
# so dsc is the displayed device screen object, update it with the new message
|
|
163
|
+
message = self.snapshot[event.devicename].messages[0]
|
|
164
|
+
dsc.add_message(message)
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
elif event.eventtype == "Define" or event.eventtype == "DefineBLOB":
|
|
168
|
+
# Define, get the devicename
|
|
169
|
+
self.sc.add_device(event.devicename)
|
|
170
|
+
if event.devicename in self.devicewindows and self.devicewindows[event.devicename].devicewin.winfo_exists():
|
|
171
|
+
dsc = self.devicewindows[event.devicename]
|
|
172
|
+
# so dsc is the displayed device screen object, update it with the new vector
|
|
173
|
+
dsc.add_vector(event.vectorname)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
elif event.eventtype == "Set" or event.eventtype == "SetBLOB":
|
|
177
|
+
if event.devicename in self.devicewindows and self.devicewindows[event.devicename].devicewin.winfo_exists():
|
|
178
|
+
dsc = self.devicewindows[event.devicename]
|
|
179
|
+
# so dsc is the displayed device screen object, update it with the new vector values
|
|
180
|
+
dsc.set_vector(event.vectorname)
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
elif event.eventtype == "Delete":
|
|
184
|
+
devicename = event.devicename
|
|
185
|
+
if devicename in self.snapshot:
|
|
186
|
+
device = self.snapshot[devicename]
|
|
187
|
+
if not device.enable:
|
|
188
|
+
# no vectors exist
|
|
189
|
+
self.sc.remove_device(devicename)
|
|
190
|
+
# and shutdown device window if openned
|
|
191
|
+
if devicename in self.devicewindows:
|
|
192
|
+
dsc = self.devicewindows[devicename]
|
|
193
|
+
if dsc.devicewin.winfo_exists():
|
|
194
|
+
dsc.devicewin.destroy()
|
|
195
|
+
del self.devicewindows[devicename]
|
|
196
|
+
elif devicename in self.devicewindows:
|
|
197
|
+
# so device still exists, it must have vectors still enabled
|
|
198
|
+
dsc = self.devicewindows[devicename]
|
|
199
|
+
if dsc.devicewin.winfo_exists():
|
|
200
|
+
# and it has a window open
|
|
201
|
+
# dsc is the displayed device screen object, update it with this event
|
|
202
|
+
dsc.del_vector(event.vectorname)
|
|
203
|
+
|
|
204
|
+
# and read again after 100ms
|
|
205
|
+
self.app.after(100, self.readrxque)
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|