Skip to content

Commit d0ed8dd

Browse files
committed
update config panel
1 parent 04dbe88 commit d0ed8dd

14 files changed

Lines changed: 195 additions & 316 deletions

images/nmeaconfig_widget.png

-51.3 KB
Loading

images/ubxconfig_widget.png

-42.2 KB
Loading

src/pygpsclient/dynamic_config_frame.py

Lines changed: 25 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
END,
2424
EW,
2525
LEFT,
26+
NE,
2627
NSEW,
2728
NW,
2829
VERTICAL,
@@ -40,7 +41,6 @@
4041
W,
4142
)
4243

43-
from PIL import Image, ImageTk
4444
from pynmeagps import (
4545
NMEA_MSGIDS_PROP,
4646
NMEA_PAYLOADS_POLL_PROP,
@@ -63,12 +63,6 @@
6363

6464
from pygpsclient.globals import (
6565
ERRCOL,
66-
ICON_CONFIRMED,
67-
ICON_PENDING,
68-
ICON_REDRAW,
69-
ICON_SEND,
70-
ICON_UNKNOWN,
71-
ICON_WARNING,
7266
INFOCOL,
7367
NMEA_CFGOTHER,
7468
OKCOL,
@@ -175,12 +169,6 @@ def __init__(self, app: Frame, parent: Frame, *args, **kwargs):
175169

176170
super().__init__(parent.container, *args, **kwargs)
177171

178-
self._img_send = ImageTk.PhotoImage(Image.open(ICON_SEND))
179-
self._img_pending = ImageTk.PhotoImage(Image.open(ICON_PENDING))
180-
self._img_confirmed = ImageTk.PhotoImage(Image.open(ICON_CONFIRMED))
181-
self._img_warn = ImageTk.PhotoImage(Image.open(ICON_WARNING))
182-
self._img_unknown = ImageTk.PhotoImage(Image.open(ICON_UNKNOWN))
183-
self._img_refresh = ImageTk.PhotoImage(Image.open(ICON_REDRAW))
184172
self._cfg_id = "" # identity of selected CFG command
185173
self._cfg_atts = {} # this holds the attributes of the selected CFG command
186174
self._expected_response = None
@@ -212,18 +200,18 @@ def _body(self):
212200
self, orient=VERTICAL, command=self._lbx_cfg_cmd.yview
213201
)
214202
self._lbx_cfg_cmd.config(yscrollcommand=self._scr_cfg_cmd.set)
215-
self._lbl_send_command = Label(self, image=self._img_pending)
203+
self._lbl_send_command = Label(self, image=self.__container.img_none)
216204
self._btn_send_command = Button(
217205
self,
218-
image=self._img_send,
206+
image=self.__container.img_send,
219207
width=50,
220208
command=self._on_set_cfg,
221209
font=self.__app.font_md,
222210
)
223211
self._btn_refresh = Button(
224212
self,
225-
image=self._img_refresh,
226-
width=50,
213+
image=self.__container.img_redraw,
214+
width=40,
227215
command=self._on_refresh,
228216
font=self.__app.font_md,
229217
)
@@ -248,45 +236,29 @@ def _do_layout(self):
248236
Layout widgets.
249237
"""
250238

251-
self._lbl_cfg_dyn.grid(column=0, row=0, columnspan=3, padx=3, pady=3, sticky=EW)
252-
self._lbx_cfg_cmd.grid(
253-
column=0, row=1, columnspan=1, rowspan=10, padx=3, pady=3, sticky=EW
254-
)
255-
self._scr_cfg_cmd.grid(column=1, row=1, rowspan=10, sticky=(N, S, W))
256-
self._btn_send_command.grid(
257-
column=2, row=1, ipadx=3, ipady=3, padx=3, pady=3, sticky=W
258-
)
259-
self._lbl_send_command.grid(
260-
column=2, row=2, ipadx=3, ipady=3, padx=3, pady=3, sticky=W
261-
)
262-
self._btn_refresh.grid(
263-
column=2, row=3, ipadx=3, ipady=3, padx=3, pady=3, sticky=W
264-
)
265-
self._lbl_command.grid(
266-
column=0, row=11, columnspan=3, padx=3, pady=3, sticky=EW
267-
)
239+
self._lbl_cfg_dyn.grid(column=0, row=0, columnspan=3, sticky=EW)
240+
self._lbx_cfg_cmd.grid(column=0, row=1, columnspan=1, sticky=EW)
241+
self._scr_cfg_cmd.grid(column=1, row=1, sticky=(N, S, W))
242+
self._btn_send_command.grid(column=2, row=1, ipadx=3, ipady=3, sticky=NE)
243+
self._lbl_send_command.grid(column=3, row=1, ipadx=3, ipady=3, sticky=NE)
244+
self._btn_refresh.grid(column=4, row=1, ipadx=3, ipady=3, sticky=NE)
245+
self._lbl_command.grid(column=0, row=2, columnspan=5, sticky=EW)
268246
self._frm_container.grid(
269247
column=0,
270-
row=12,
271-
columnspan=3,
272-
rowspan=15,
273-
padx=3,
274-
pady=3,
248+
row=3,
249+
columnspan=5,
250+
rowspan=1,
275251
sticky=NSEW,
276252
)
277253
self._can_container.grid(
278254
column=0,
279255
row=0,
280-
columnspan=3,
281-
rowspan=15,
282-
padx=3,
283-
pady=3,
256+
columnspan=5,
257+
rowspan=1,
284258
sticky=NSEW,
285259
)
286-
self._scr_container_ver.grid(column=3, row=0, rowspan=15, sticky=(N, S, W))
287-
self._scr_container_hor.grid(
288-
column=0, row=15, columnspan=3, rowspan=15, sticky=EW
289-
)
260+
self._scr_container_ver.grid(column=5, row=0, sticky=(N, S, W))
261+
self._scr_container_hor.grid(column=0, row=2, columnspan=5, sticky=EW)
290262
self.option_add("*Font", self.__app.font_sm)
291263

292264
def _attach_events(self):
@@ -313,7 +285,7 @@ def reset(self):
313285
self._lbx_cfg_cmd.insert(i, cmd)
314286

315287
self._clear_widgets()
316-
self._lbl_send_command.config(image=self._img_unknown)
288+
self._lbl_send_command.config(image=self.__container.img_unknown)
317289

318290
def _setscroll(self, event): # pylint: disable=unused-argument
319291
"""
@@ -395,7 +367,7 @@ def _on_set_cfg(self, *args, **kwargs): # pylint: disable=unused-argument
395367

396368
# send message, update status and await response
397369
self.__container.send_command(msg)
398-
self._lbl_send_command.config(image=self._img_pending)
370+
self._lbl_send_command.config(image=self.__container.img_pending)
399371
self.__container.status_label = f"P{self._cfg_id} SET message sent"
400372
for msgid in pendcfg:
401373
self.__container.set_pending(msgid, penddlg)
@@ -444,13 +416,13 @@ def _do_poll_cfg(self, *args, **kwargs): # pylint: disable=unused-argument
444416
if msg is not None:
445417
self.__container.send_command(msg)
446418
self.__container.status_label = f"{cp}{cfg_id} POLL message sent"
447-
self._lbl_send_command.config(image=self._img_pending)
419+
self._lbl_send_command.config(image=self.__container.img_pending)
448420
for msgid in pendcfg:
449421
self.__container.set_pending(msgid, penddlg)
450422
self._expected_response = POLL
451423
else: # CFG cannot be POLLed
452424
self.__container.status_label = f"{cp}{cfg_id} No POLL available"
453-
self._lbl_send_command.config(image=self._img_unknown)
425+
self._lbl_send_command.config(image=self.__container.img_unknown)
454426

455427
def _do_poll_args(self, cfg_id: str) -> dict:
456428
"""
@@ -532,10 +504,10 @@ def update_status(self, msg: NMEAMessage | UBXMessage):
532504
f"{cfg_id} message acknowledged",
533505
OKCOL,
534506
)
535-
self._lbl_send_command.config(image=self._img_confirmed)
507+
self._lbl_send_command.config(image=self.__container.img_confirmed)
536508
else:
537509
self.__container.status_label = (f"{cfg_id} message rejected", ERRCOL)
538-
self._lbl_send_command.config(image=self._img_warn)
510+
self._lbl_send_command.config(image=self.__container.img_warn)
539511
self.update()
540512

541513
def _clear_widgets(self):

src/pygpsclient/hardware_info_frame.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,16 @@ def _do_layout(self):
7777
Layout widgets.
7878
"""
7979

80-
self._lbl_hwverl.grid(column=0, row=0, padx=3, pady=3, sticky=W)
81-
self._lbl_hwver.grid(column=1, row=0, columnspan=2, padx=3, pady=3, sticky=EW)
82-
self._lbl_swverl.grid(column=3, row=0, padx=3, pady=3, sticky=W)
83-
self._lbl_swver.grid(column=4, row=0, columnspan=2, padx=3, pady=3, sticky=EW)
84-
self._lbl_fwverl.grid(column=0, row=1, padx=3, pady=3, sticky=W)
85-
self._lbl_fwver.grid(column=1, row=1, columnspan=2, padx=3, pady=3, sticky=EW)
86-
self._lbl_romverl.grid(column=3, row=1, padx=3, pady=3, sticky=W)
87-
self._lbl_romver.grid(column=4, row=1, columnspan=2, padx=3, pady=3, sticky=EW)
88-
self._lbl_gnssl.grid(column=0, row=2, columnspan=1, padx=3, pady=3, sticky=W)
89-
self._lbl_gnss.grid(column=1, row=2, columnspan=4, padx=3, pady=3, sticky=EW)
80+
self._lbl_hwverl.grid(column=0, row=0, padx=3, sticky=W)
81+
self._lbl_hwver.grid(column=1, row=0, columnspan=2, padx=3, sticky=EW)
82+
self._lbl_swverl.grid(column=3, row=0, padx=3, sticky=W)
83+
self._lbl_swver.grid(column=4, row=0, columnspan=2, padx=3, sticky=EW)
84+
self._lbl_fwverl.grid(column=0, row=1, padx=3, sticky=W)
85+
self._lbl_fwver.grid(column=1, row=1, columnspan=2, padx=3, sticky=EW)
86+
self._lbl_romverl.grid(column=3, row=1, padx=3, sticky=W)
87+
self._lbl_romver.grid(column=4, row=1, columnspan=2, padx=3, sticky=EW)
88+
self._lbl_gnssl.grid(column=0, row=2, padx=3, sticky=W)
89+
self._lbl_gnss.grid(column=1, row=2, columnspan=4, padx=3, sticky=EW)
9090

9191
def _attach_events(self):
9292
"""

src/pygpsclient/nmea_config_dialog.py

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -86,33 +86,22 @@ def _do_layout(self):
8686
Position widgets in frame.
8787
"""
8888

89-
# top of grid
90-
col = 0
91-
row = 0
92-
# left column of grid
93-
for frm in (self.frm_device_info, self._frm_preset):
94-
colsp, rowsp = frm.grid_size()
95-
frm.grid(
96-
column=col,
97-
row=row,
98-
columnspan=colsp,
99-
rowspan=rowsp,
100-
sticky=NSEW,
101-
)
102-
row += rowsp
103-
# right column of grid
104-
row = 0
105-
col += colsp
106-
for frm in (self._frm_config_dynamic,):
107-
colsp, rowsp = frm.grid_size()
108-
frm.grid(
109-
column=col,
110-
row=row,
111-
columnspan=colsp,
112-
rowspan=rowsp,
113-
sticky=NSEW,
114-
)
115-
row += rowsp
89+
self.frm_device_info.grid(column=0, row=0, columnspan=2, sticky=NSEW)
90+
self._frm_preset.grid(column=0, row=1, sticky=NSEW)
91+
self._frm_config_dynamic.grid(column=1, row=1, sticky=NSEW)
92+
93+
self.container.grid_columnconfigure(0, weight=1)
94+
self.container.grid_columnconfigure(1, weight=1)
95+
self.container.grid_rowconfigure(1, weight=1)
96+
colsp, rowsp = self._frm_preset.grid_size()
97+
for col in range(colsp - 2):
98+
self._frm_preset.grid_columnconfigure(col, weight=1)
99+
self._frm_preset.grid_rowconfigure(2, weight=1)
100+
colsp, rowsp = self._frm_config_dynamic.grid_size()
101+
for col in range(colsp):
102+
self._frm_config_dynamic.grid_columnconfigure(col, weight=1)
103+
for row in range(1, rowsp):
104+
self._frm_config_dynamic.grid_rowconfigure(row, weight=1)
116105

117106
def _reset(self):
118107
"""

src/pygpsclient/nmea_preset_frame.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
EW,
1616
HORIZONTAL,
1717
LEFT,
18+
NE,
19+
NSEW,
1820
VERTICAL,
1921
Button,
2022
E,
@@ -105,15 +107,15 @@ def _body(self):
105107
self,
106108
textvariable=self._command,
107109
relief="sunken",
108-
width=55,
110+
width=40,
109111
)
110112
self._lbl_presets = Label(self, text=LBLNMEAPRESET, anchor=W)
111113
self._lbx_preset = Listbox(
112114
self,
113115
border=2,
114116
relief="sunken",
115117
height=20,
116-
width=55,
118+
width=40,
117119
justify=LEFT,
118120
exportselection=False,
119121
)
@@ -123,7 +125,7 @@ def _body(self):
123125
self._lbx_preset.config(xscrollcommand=self._scr_preseth.set)
124126
self._scr_presetv.config(command=self._lbx_preset.yview)
125127
self._scr_preseth.config(command=self._lbx_preset.xview)
126-
self._lbl_send_command = Label(self)
128+
self._lbl_send_command = Label(self, image=self.__container.img_none)
127129
self._btn_send_command = Button(
128130
self,
129131
image=self._img_send,
@@ -136,16 +138,18 @@ def _do_layout(self):
136138
Layout widgets.
137139
"""
138140

139-
self._lbl_command.grid(column=0, row=0, padx=3, sticky=W)
140-
self._ent_command.grid(column=1, row=0, columnspan=3, padx=3, sticky=EW)
141-
self._lbl_presets.grid(column=0, row=1, columnspan=4, padx=3, sticky=EW)
142-
self._lbx_preset.grid(
143-
column=0, row=2, columnspan=2, rowspan=20, padx=3, pady=3, sticky=EW
141+
self._lbl_command.grid(column=0, row=0, sticky=W)
142+
self._ent_command.grid(column=1, row=0, columnspan=4, sticky=EW)
143+
self._lbl_presets.grid(column=0, row=1, columnspan=5, sticky=EW)
144+
self._lbx_preset.grid(column=0, row=2, columnspan=3, sticky=NSEW)
145+
self._scr_presetv.grid(column=2, row=2, sticky=(N, S, E))
146+
self._scr_preseth.grid(column=0, row=3, columnspan=3, sticky=EW)
147+
self._btn_send_command.grid(
148+
column=3, row=2, padx=3, ipadx=3, ipady=3, sticky=NE
149+
)
150+
self._lbl_send_command.grid(
151+
column=4, row=2, padx=3, ipadx=3, ipady=3, sticky=NE
144152
)
145-
self._scr_presetv.grid(column=2, row=2, rowspan=20, sticky=(N, S, E))
146-
self._scr_preseth.grid(column=0, row=22, columnspan=2, sticky=EW)
147-
self._btn_send_command.grid(column=3, row=2, padx=3, ipadx=3, ipady=3, sticky=W)
148-
self._lbl_send_command.grid(column=3, row=3, padx=3, ipadx=3, ipady=3, sticky=W)
149153
self.option_add("*Font", self.__app.font_sm)
150154

151155
def _attach_events(self):

src/pygpsclient/toplevel_dialog.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
ICON_REDRAW,
4848
ICON_SEND,
4949
ICON_START,
50+
ICON_UNKNOWN,
5051
ICON_WARNING,
5152
INFOCOL,
5253
RESIZE,
@@ -99,6 +100,7 @@ def __init__(self, app, dlgname: str, *args, **kwargs):
99100
self.img_send = ImageTk.PhotoImage(Image.open(ICON_SEND))
100101
self.img_start = ImageTk.PhotoImage(Image.open(ICON_START))
101102
self.img_warn = ImageTk.PhotoImage(Image.open(ICON_WARNING))
103+
self.img_unknown = ImageTk.PhotoImage(Image.open(ICON_UNKNOWN))
102104

103105
self._con_body(self._resizable)
104106

src/pygpsclient/tty_preset_dialog.py

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def _body(self):
142142
self._lbx_preset.config(xscrollcommand=self._scr_preseth.set)
143143
self._scr_presetv.config(command=self._lbx_preset.yview)
144144
self._scr_preseth.config(command=self._lbx_preset.xview)
145-
self._lbl_send_command = Label(self._frm_body)
145+
self._lbl_send_command = Label(self._frm_body, image=self.img_none)
146146
self._btn_send_command = Button(
147147
self._frm_body,
148148
image=self.img_send,
@@ -157,40 +157,34 @@ def _do_layout(self):
157157

158158
self.frm_device_info.grid(column=0, row=0, sticky=EW)
159159
self._frm_body.grid(column=0, row=1, sticky=NSEW)
160-
self._lbl_command.grid(column=0, row=0, padx=3, sticky=W)
161-
self._ent_command.grid(column=1, row=0, columnspan=3, padx=3, sticky=EW)
162-
self._chk_crlf.grid(column=0, row=1, padx=3, sticky=W)
163-
self._chk_echo.grid(column=1, row=1, padx=3, sticky=W)
164-
self._chk_delay.grid(column=2, row=1, padx=3, sticky=W)
165-
ttk.Separator(self._frm_body).grid(
166-
column=0, row=2, columnspan=4, padx=2, pady=2, sticky=EW
167-
)
168-
self._lbl_presets.grid(column=0, row=3, columnspan=3, padx=3, sticky=EW)
160+
self._lbl_command.grid(column=0, row=0, sticky=W)
161+
self._ent_command.grid(column=1, row=0, columnspan=4, sticky=EW)
162+
self._chk_crlf.grid(column=0, row=1, sticky=W)
163+
self._chk_echo.grid(column=1, row=1, sticky=W)
164+
self._chk_delay.grid(column=2, row=1, sticky=W)
165+
ttk.Separator(self._frm_body).grid(column=0, row=2, columnspan=5, sticky=EW)
166+
self._lbl_presets.grid(column=0, row=3, columnspan=4, sticky=EW)
169167
self._lbx_preset.grid(
170168
column=0,
171169
row=4,
172170
columnspan=3,
173-
rowspan=20,
174-
padx=3,
175-
pady=3,
176171
sticky=NSEW,
177172
)
178-
self._scr_presetv.grid(column=2, row=4, rowspan=20, sticky=(N, S, E))
179-
self._scr_preseth.grid(column=0, row=24, columnspan=3, sticky=EW)
173+
self._scr_presetv.grid(column=2, row=4, sticky=(N, S, E))
174+
self._scr_preseth.grid(column=0, row=5, columnspan=4, sticky=EW)
180175
self._btn_send_command.grid(
181176
column=3, row=4, padx=3, ipadx=3, ipady=3, sticky=NE
182177
)
183178
self._lbl_send_command.grid(
184-
column=3, row=5, padx=3, ipadx=3, ipady=3, sticky=EW
179+
column=4, row=4, padx=3, ipadx=3, ipady=3, sticky=NE
185180
)
186181

187182
self.container.grid_columnconfigure(0, weight=1)
188183
self.container.grid_rowconfigure(1, weight=1)
189-
colsp, rowsp = self._frm_body.grid_size()
190-
for col in range(colsp - 1):
184+
colsp, _ = self._frm_body.grid_size()
185+
for col in range(colsp - 2):
191186
self._frm_body.grid_columnconfigure(col, weight=1)
192-
for row in range(3, rowsp):
193-
self._frm_body.grid_rowconfigure(row, weight=1)
187+
self._frm_body.grid_rowconfigure(4, weight=1)
194188

195189
def _attach_events(self):
196190
"""

0 commit comments

Comments
 (0)