33from MAPIT .GUI import IOWizard , GeneralOps , StyleOps , GUIComponents
44import os
55from platformdirs import user_config_dir , user_data_dir
6+ import uuid
67
78
89def launchIOWindow (self , AnalysisData , GUIparams ):
@@ -22,6 +23,8 @@ def launchIOWindow(self, AnalysisData, GUIparams):
2223
2324
2425
26+
27+
2528class ViewErrorTabs (QtWidgets .QDialog ):
2629 """
2730 This function displays the contribution
@@ -475,3 +478,130 @@ def closeEvent(self, event):
475478 settings .setValue ("dataPathDefault" ,self .dirtext .text ())
476479
477480
481+ class dataTypeSelector (QtWidgets .QWidget ):
482+ def __init__ (self , text , colordict ):
483+ super ().__init__ ()
484+
485+ self .layout = QtWidgets .QVBoxLayout ()
486+ self .setLayout (self .layout )
487+
488+ self .gb = QtWidgets .QGroupBox (text )
489+ self .layout .addWidget (self .gb )
490+ self .gb_layout = QtWidgets .QVBoxLayout ()
491+ self .gb .setLayout (self .gb_layout )
492+ self .gb .setObjectName (str (uuid .uuid4 ()))
493+ StyleOps .update_aniGBoxSmall_styleSheet (colordict , self .gb , isactive = 1 )
494+
495+ self .rb_type_cont = QtWidgets .QRadioButton ("Continuous" )
496+ self .rb_type_disc = QtWidgets .QRadioButton ("Discrete" )
497+ self .rb_type_cont .setChecked (True )
498+
499+ self .gb_layout .addWidget (self .rb_type_cont )
500+ self .gb_layout .addWidget (self .rb_type_disc )
501+
502+
503+ def get_type (self ):
504+ if self .rb_type_cont .isChecked ():
505+ return "continuous"
506+ else :
507+ return "discrete"
508+
509+
510+ class getImportDataTypeDlg (QtWidgets .QDialog ):
511+ def __init__ (self , entries , colordict ):
512+ super ().__init__ ()
513+
514+ self .entries = entries
515+ self .entry_widgets = []
516+
517+ self .scroll_area = QtWidgets .QScrollArea ()
518+ self .scroll_area .setWidgetResizable (True )
519+
520+
521+
522+ self .container = QtWidgets .QFrame ()
523+ self .scroll_area .setWidget (self .container )
524+
525+ StyleOps .update_scrollObjStype (self .scroll_area , self .container , colordict )
526+
527+ self .layout = QtWidgets .QVBoxLayout ()
528+ self .container .setLayout (self .layout )
529+
530+ for entry in self .entries :
531+ widget = dataTypeSelector (entry , colordict )
532+ self .entry_widgets .append (widget )
533+ self .layout .addWidget (widget )
534+
535+ #self.button_box = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel)
536+ #self.button_box.accepted.connect(self.accept)
537+ #self.button_box.rejected.connect(self.reject)
538+
539+ self .loadbtn = GUIComponents .AniButton (None )
540+ self .loadbtn .setText ("Load" )
541+
542+ self .savebtn = GUIComponents .AniButton (None )
543+ self .savebtn .setText ("Save" )
544+
545+ self .donebtn = GUIComponents .AniButton (None )
546+ self .donebtn .setText ("Done" )
547+
548+ tlw = QtWidgets .QApplication .topLevelWidgets ()
549+ for w in tlw :
550+ if hasattr (w ,'colordict' ):
551+ mw = w
552+
553+ StyleOps .enable_ani_button (button_obj = self .loadbtn , guiobj = mw )
554+ StyleOps .enable_ani_button (button_obj = self .savebtn , guiobj = mw )
555+ StyleOps .enable_ani_button (button_obj = self .donebtn , guiobj = mw )
556+
557+
558+ self .main_layout = QtWidgets .QVBoxLayout ()
559+ self .main_layout .addWidget (self .scroll_area )
560+ #self.main_layout.addWidget(self.button_box)
561+
562+ self .subwidget = QtWidgets .QWidget ()
563+ self .sublayout = QtWidgets .QGridLayout ()
564+ self .subwidget .setLayout (self .sublayout )
565+
566+ self .sublayout .addWidget (self .loadbtn , 0 , 0 )
567+ self .sublayout .addWidget (self .savebtn , 0 , 1 )
568+ self .sublayout .addWidget (self .donebtn , 1 , 0 , 1 , 2 )
569+ self .donebtn .clicked .connect (self .accept )
570+ self .loadbtn .clicked .connect (self .load_data )
571+ self .savebtn .clicked .connect (self .save_data )
572+
573+
574+ self .main_layout .addWidget (self .subwidget )
575+
576+ self .setLayout (self .main_layout )
577+
578+
579+ def get_types (self ):
580+ return [widget .get_type () for widget in self .entry_widgets ]
581+
582+ def set_option (self , options ):
583+ for i , option in enumerate (options ):
584+ if option == 'continuous' :
585+ self .entry_widgets [i ].rb_type_cont .setChecked (True )
586+ elif option == 'discrete' :
587+ self .entry_widgets [i ].rb_type_disc .setChecked (True )
588+ else :
589+ print ("error" )
590+
591+ def save_data (self ):
592+ dat = self .get_types ()
593+
594+ outdir = os .path .join (user_config_dir ('MAPIT' ,False ), 'DatTypeConfig.txt' )
595+
596+ with open (outdir , 'w' ) as f :
597+ for item in dat :
598+ f .write ("%s\n " % item )
599+
600+
601+ def load_data (self ):
602+ outdir = os .path .join (user_config_dir ('MAPIT' ,False ), 'DatTypeConfig.txt' )
603+
604+ with open (outdir , 'r' ) as f :
605+ x = f .read ().splitlines ()
606+
607+ self .set_option (x )
0 commit comments