1010import logging
1111import os
1212
13- from PySimpleGUI import *
13+ import PySimpleGUI as sg
1414
1515from .. import __version__ as toolversion
1616from ..archive import SIGMF_ARCHIVE_EXT
1717from ..sigmffile import SigMFFile , dtype_info , fromarchive
1818
1919log = logging .getLogger ()
2020
21- validate_button = Button ('Update' , bind_return_key = False , enable_events = True )
22- submit_button = Button ('Save Archive' , disabled = True , button_color = ('white' , '#D3D3D3' ))
23- load_button = Button ('Load' , key = 'Load Archive' )
24- combo_button = InputCombo ((), size = (20 , 1 ), enable_events = True , key = 'Capture Combo' )
21+ validate_button = sg . Button ('Update' , bind_return_key = False , enable_events = True )
22+ submit_button = sg . Button ('Save Archive' , disabled = True , button_color = ('white' , '#D3D3D3' ))
23+ load_button = sg . Button ('Load' , key = 'Load Archive' )
24+ combo_button = sg . InputCombo ((), size = (20 , 1 ), enable_events = True , key = 'Capture Combo' )
2525
2626
2727class Unit :
@@ -267,7 +267,7 @@ def add_sigmf_field(funct, values, field_name, *args, required=False, type=None,
267267 else :
268268 funct (* args , input )
269269 except UserWarning as w :
270- Popup ('Warning: {}' .format (repr (w )), title = 'Warning' )
270+ sg . Popup ('Warning: {}' .format (repr (w )), title = 'Warning' )
271271 except Exception as e :
272272 show_error (repr (e ))
273273 return False
@@ -278,7 +278,7 @@ def add_sigmf_field(funct, values, field_name, *args, required=False, type=None,
278278
279279
280280def show_error (message ):
281- PopupError (message , title = 'Error' , line_width = 60 )
281+ sg . PopupError (message , title = 'Error' , line_width = 60 )
282282
283283
284284def validate_data (file ):
@@ -289,7 +289,7 @@ def validate_data(file):
289289 submit_button .Update (disabled = True )
290290 return False
291291 else :
292- PopupOK ('Data is valid\n ' , file .dumps (pretty = True ), title = '' )
292+ sg . PopupOK ('Data is valid\n ' , file .dumps (pretty = True ), title = '' )
293293 return True
294294
295295
@@ -305,7 +305,7 @@ def update_capture_screen(capture_data_input, capture_text_blocks, capture_dict)
305305def update_global_screen (window_data_input , window_text_blocks , window_dict , archive ):
306306 data_type = window_dict [SigMFFile .DATATYPE_KEY ]
307307 data_info = dtype_info (data_type )
308- sample_size = 64 if '64' in datatype else 32 if '32' in data_type else 16 if '16' in data_type else 8 if '8' in data_type else None
308+ sample_size = 64 if '64' in data_type else 32 if '32' in data_type else 16 if '16' in data_type else 8 if '8' in data_type else None
309309 assert sample_size is not None
310310 window_text_blocks [WindowInput .DATA_TYPE_FIXEDPOINT ].Update (bool (data_info ['is_fixedpoint' ]))
311311 window_text_blocks [WindowInput .DATA_TYPE_UNSIGNED ].Update (bool (data_info ['is_unsigned' ]))
@@ -404,36 +404,36 @@ def main():
404404 f = SigMFFile ()
405405 capture_selector_dict = {}
406406
407- layout = [[Text ('This is the SigMF tool to archive RF datasets' , size = (80 , 1 ))],
408- [Text ('Enter your data and signal captures below. You must include' , auto_size_text = True ),
409- Text ('required' , text_color = 'red' , font = DEFAULT_FONT + ('italic' ,), auto_size_text = True ),
410- Text ('fields.' , size = (50 , 1 ), auto_size_text = True )],
411- [Text ('_' * 150 , auto_size_text = True )]]
407+ layout = [[sg . Text ('This is the SigMF tool to archive RF datasets' , size = (80 , 1 ))],
408+ [sg . Text ('Enter your data and signal captures below. You must include' , auto_size_text = True ),
409+ sg . Text ('required' , text_color = 'red' , font = sg . DEFAULT_FONT + ('italic' ,), auto_size_text = True ),
410+ sg . Text ('fields.' , size = (50 , 1 ), auto_size_text = True )],
411+ [sg . Text ('_' * 150 , auto_size_text = True )]]
412412
413- layout .append ([Text ('Global Data' , font = ('Arial' , 12 , 'bold' ))])
413+ layout .append ([sg . Text ('Global Data' , font = ('Arial' , 12 , 'bold' ))])
414414 num_components = 0
415415 line = []
416416 for el in window_input .iter_core ():
417417 size = (30 , 1 ) if len (line ) == 0 else (None , None )
418418 auto_size = True if len (line ) == 0 else (10 , 1 )
419- line .extend ([Text (el , justification = 'right' , size = size ,
419+ line .extend ([sg . Text (el , justification = 'right' , size = size ,
420420 text_color = 'red' if el in window_input .req_tags else None , auto_size_text = auto_size )])
421421 if el in window_input .el_multiline :
422- window_text_blocks .update ({el : Multiline (window_input .el_text .get (el , '' ), key = el ,
422+ window_text_blocks .update ({el : sg . Multiline (window_input .el_text .get (el , '' ), key = el ,
423423 tooltip = window_input .el_tooltips .get (el , None ), size = (30 , 2 ))})
424424 elif el in window_input .el_selector :
425- window_text_blocks .update ({el : Combo (values = window_input .el_selector [el ], key = el ,
425+ window_text_blocks .update ({el : sg . Combo (values = window_input .el_selector [el ], key = el ,
426426 size = window_input .el_size .get (el , (None , None )))})
427427 elif el in window_input .el_checkbox :
428- window_text_blocks .update ({el : Checkbox (window_input .el_text .get (el , '' ), key = el ,
428+ window_text_blocks .update ({el : sg . Checkbox (window_input .el_text .get (el , '' ), key = el ,
429429 size = window_input .el_size .get (el , (None , None )))})
430430 else :
431- window_text_blocks .update ({el : InputText (window_input .el_text .get (el , '' ), key = el ,
431+ window_text_blocks .update ({el : sg . InputText (window_input .el_text .get (el , '' ), key = el ,
432432 tooltip = window_input .el_tooltips .get (el , None ))})
433433 line .append (window_text_blocks [el ])
434434
435435 if el in window_input .el_units :
436- line .append (Text (window_input .el_units [el ]))
436+ line .append (sg . Text (window_input .el_units [el ]))
437437
438438 num_components += 1
439439 if num_components < window_input .first_line_size :
@@ -447,52 +447,52 @@ def main():
447447 if el is None :
448448 continue
449449 color = 'red' if el in window_input .req_tags else None
450- window_text_blocks .update ({el : InputText (window_input .el_text .get (el , '' ), key = el ,
450+ window_text_blocks .update ({el : sg . InputText (window_input .el_text .get (el , '' ), key = el ,
451451 tooltip = window_input .el_tooltips .get (el , None ))})
452- line .extend ([Text (el , justification = 'right' , size = (size , 1 ), text_color = color ), window_text_blocks [el ]])
452+ line .extend ([sg . Text (el , justification = 'right' , size = (size , 1 ), text_color = color ), window_text_blocks [el ]])
453453 if el in window_input .el_units :
454- line .append (Text (window_input .el_units [el ], size = (5 , 1 )))
454+ line .append (sg . Text (window_input .el_units [el ], size = (5 , 1 )))
455455 else :
456- line .append (Text ('' , size = (5 , 1 )))
456+ line .append (sg . Text ('' , size = (5 , 1 )))
457457 layout .append (line )
458458
459459 layout .extend (
460- [[Text ('_' * 150 , auto_size_text = True )],
461- [Text ('Individual Capture Data' , font = ('Arial' , 12 , 'bold' ))],
462- [Text ('Capture Selector' , auto_size_text = True ), combo_button , Text ('' , size = (10 , 1 )),
463- Button ('Add Capture' , enable_events = True ), Button ('Remove Capture' , enable_events = True , size = (15 , 1 )),
464- Button ('Clear Capture' , enable_events = True , size = (15 , 1 ))]]
460+ [[sg . Text ('_' * 150 , auto_size_text = True )],
461+ [sg . Text ('Individual Capture Data' , font = ('Arial' , 12 , 'bold' ))],
462+ [sg . Text ('Capture Selector' , auto_size_text = True ), combo_button , sg . Text ('' , size = (10 , 1 )),
463+ sg . Button ('Add Capture' , enable_events = True ), sg . Button ('Remove Capture' , enable_events = True , size = (15 , 1 )),
464+ sg . Button ('Clear Capture' , enable_events = True , size = (15 , 1 ))]]
465465 )
466466
467467 for el1 , el2 , el3 in capture_data_input .iter_x (3 ):
468468 line = []
469469 for el in [el1 , el2 , el3 ]:
470470 if el is None :
471471 continue
472- capture_text_blocks .update ({el : InputText (key = el , tooltip = capture_data_input .el_tooltips .get (el , None ))})
472+ capture_text_blocks .update ({el : sg . InputText (key = el , tooltip = capture_data_input .el_tooltips .get (el , None ))})
473473 color = 'red' if el in capture_data_input .req_tags else None
474- line .extend ([Text (el , justification = 'right' , size = (20 , 1 ), text_color = color ), capture_text_blocks [el ]])
474+ line .extend ([sg . Text (el , justification = 'right' , size = (20 , 1 ), text_color = color ), capture_text_blocks [el ]])
475475 if el in capture_data_input .el_units :
476- line .append (Text (capture_data_input .el_units [el ], size = (5 , 1 )))
476+ line .append (sg . Text (capture_data_input .el_units [el ], size = (5 , 1 )))
477477 else :
478- line .append (Text ('' , size = (5 , 1 )))
478+ line .append (sg . Text ('' , size = (5 , 1 )))
479479 layout .append (line )
480480
481481 window_text_blocks .update (
482- {WindowInput .DATA_FILE : InputText ('' , key = WindowInput .DATA_FILE )})
482+ {WindowInput .DATA_FILE : sg . InputText ('' , key = WindowInput .DATA_FILE )})
483483 layout .extend (
484- [[Text ('_' * 150 , auto_size_text = True )],
485- [Text ('Data Location' , font = ('Arial' , 12 , 'bold' ))],
486- [Text (WindowInput .DATA_FILE , size = (30 , 1 ), justification = 'right' , text_color = 'red' ),
487- window_text_blocks [WindowInput .DATA_FILE ], FileBrowse ()],
488- [Text (WindowInput .OUTPUT_FOLDER , size = (30 , 1 ), justification = 'right' ),
489- InputText ('' , key = WindowInput .OUTPUT_FOLDER ), FolderBrowse (), submit_button ],
490- [Text (WindowInput .LOAD_PATH , size = (30 , 1 ), justification = 'right' ), InputText ('' , key = WindowInput .LOAD_PATH ),
491- FileBrowse (file_types = (("Archive Files" , "*.sigmf" ),)), load_button ],
492- [validate_button , Button ('View Data' )]]
484+ [[sg . Text ('_' * 150 , auto_size_text = True )],
485+ [sg . Text ('Data Location' , font = ('Arial' , 12 , 'bold' ))],
486+ [sg . Text (WindowInput .DATA_FILE , size = (30 , 1 ), justification = 'right' , text_color = 'red' ),
487+ window_text_blocks [WindowInput .DATA_FILE ], sg . FileBrowse ()],
488+ [sg . Text (WindowInput .OUTPUT_FOLDER , size = (30 , 1 ), justification = 'right' ),
489+ sg . InputText ('' , key = WindowInput .OUTPUT_FOLDER ), sg . FolderBrowse (), submit_button ],
490+ [sg . Text (WindowInput .LOAD_PATH , size = (30 , 1 ), justification = 'right' ), sg . InputText ('' , key = WindowInput .LOAD_PATH ),
491+ sg . FileBrowse (file_types = (("Archive Files" , "*.sigmf" ),)), load_button ],
492+ [validate_button , sg . Button ('View Data' )]]
493493 )
494494
495- window = Window ('SigMF Archive Creator' ,
495+ window = sg . Window ('SigMF Archive Creator' ,
496496 auto_size_buttons = False ,
497497 default_element_size = (20 , 1 ),
498498 auto_size_text = False ,
@@ -534,7 +534,7 @@ def main():
534534 add_capture (capture_data_input , capture , capture_selector_dict , f , from_archive = True )
535535
536536 elif event == 'Data Type Help' :
537- PopupOK (
537+ sg . PopupOK (
538538 'Format: <TypeCharacters><ElementBitSize>_<Endianness>\n \n '
539539 '\t TypeCharacters:\n '
540540 '\t \t Unsigned data: \" u\" \n '
@@ -581,7 +581,7 @@ def main():
581581 continue
582582
583583 if validate_data (f ):
584- submit_button .Update (disabled = False , button_color = DEFAULT_BUTTON_COLOR )
584+ submit_button .Update (disabled = False , button_color = sg . DEFAULT_BUTTON_COLOR )
585585 elif event == 'Capture Combo' :
586586 capture_dict = capture_selector_dict [values ['Capture Combo' ]]
587587 update_capture_screen (capture_data_input , capture_text_blocks , capture_dict )
@@ -620,7 +620,7 @@ def main():
620620 elif event == 'Clear Capture' :
621621 update_capture_screen (capture_data_input , capture_text_blocks , None )
622622 elif event == 'View Data' :
623- PopupOK ('Current data:\n ' , f .dumps (pretty = True ), title = '' )
623+ sg . PopupOK ('Current data:\n ' , f .dumps (pretty = True ), title = '' )
624624 elif event == 'Save Archive' :
625625 output_folder = values [WindowInput .OUTPUT_FOLDER ]
626626 if output_folder == '' :
@@ -632,7 +632,7 @@ def main():
632632 window .Refresh ()
633633 archive_file = output_folder + '/' + os .path .basename (f .data_file ).split ('.' )[0 ] + SIGMF_ARCHIVE_EXT
634634 f .archive (archive_file )
635- PopupOK ('Saved archive as \n ' , archive_file , title = '' )
635+ sg . PopupOK ('Saved archive as \n ' , archive_file , title = '' )
636636 elif event in ['Cancel' , None , 'Exit' ]:
637637 window .Close ()
638638 break
0 commit comments