Skip to content

Commit 0a98f47

Browse files
firmware update callable from menu
1 parent c40a953 commit 0a98f47

File tree

3 files changed

+42
-4
lines changed

3 files changed

+42
-4
lines changed

ups2_FW_Upd_GUI.py

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import PySimpleGUI as sg
2+
import ups2_update
3+
4+
''' Select binary firmware file and update via bootloader. '''
5+
6+
def GetFileDialog():
7+
success = False
8+
sg.SetOptions(auto_size_buttons=True, font='Helvetica 11')
9+
10+
layout = [[sg.Text('Select Firmware Version')],
11+
[sg.Text('File', size=(15, 1)), sg.InputText(key='_file_'),
12+
sg.FileBrowse(button_text = '...' , initial_folder = './', file_types=(("UPS-2 Firmware", "*.bin"),))],
13+
[sg.Button('Update', key = '_btn_upd_', disabled = True), sg.Button('Cancel')]]
14+
15+
window = sg.Window('Select UPS-2 Firmware Update',layout)
16+
while True:
17+
event, values = window.Read(timeout=200)
18+
if(values['_file_'] != ''):
19+
window['_btn_upd_'].update(disabled = False)
20+
21+
if event in (None, 'Cancel'):
22+
window.close()
23+
return('')
24+
elif event == '_btn_upd_':
25+
success = ''
26+
newFile = values['_file_']
27+
if(newFile != ''):
28+
success = ups2_update.ecUpdateUPS(newFile, True)
29+
window.close()
30+
return newFile
31+
32+
if __name__ == "__main__":
33+
newFile = GetFileDialog()
34+
print(newFile)
35+
36+
37+
38+
File renamed without changes.

ups2_GUI.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@
1515
import PySimpleGUI as sg
1616
import os
1717
import ups2_Interface as ups
18-
import ups2_FirmwareUpd as FW_upd
18+
import ups2_FW_Upd_GUI as FW_upd
1919

20-
GUI_Version = 'UPS GUI V0.8 '
20+
GUI_Version = 'GUI V0.8 '
2121

2222
# ------ Menu Definition ------ #
2323
menu_def = [['File ', ['Quit',]],
2424
['PowerControl ', ['Power OFF', 'Restart', 'Standby']],
25-
['About ', ['UPS-2 GUI', 'UPS-2 Firmware', 'PySimpleGUI']],
25+
['About ', ['UPS-2 GUI', 'UPS-2 Firmware']],
2626
['Firmware_Update', ['Browse...']]]
2727

28-
2928
print('PySimpleGUI Version', sg.version)
3029

30+
# ------- Format User Interface ------ #
3131
sg.theme('lightGreen')
3232
sg.SetOptions(button_element_size=(9,1), auto_size_buttons=False, font='Helvetica 11')
3333
ser = ups.ecInitSerial()

0 commit comments

Comments
 (0)