PhysiCell-Tools / PhysiCell-Studio

PhysiCell Studio is a graphical tool to allow easy editing of a (XML) model, create initial positions of cells, run a simulation, and visualize results. To contribute, fork and make PRs to the development branch.
GNU General Public License v3.0
19 stars 11 forks source link

QSpinBox missing textChanged for some Anaconda PyQt5 #227

Open rheiland opened 4 weeks ago

rheiland commented 4 weeks ago

In case we want to avoid the QSpinBox textChanged crash (in config_tab.py) for some Anaconda distros, any thoughts on this? Can test using a valid distro by using a dummy function instead of textChanged.

        self.day_spin_box = QSpinBox()
        self.spinners_valid = 'textChanged' in dir(self.day_spin_box)
        if not self.spinners_valid:
            print("""\n\n
                    ------------------------------------------------------
                      Your PyQt5 library does not fully support QSpinBox.
                      The Studio will not contain day|hour|min widgets.
                    ------------------------------------------------------\n\n""")
        else:
            self.day_spin_box.setMinimum(0)
            self.day_spin_box.setMaximum(int(1e6))

            self.day_spin_box.setSuffix(" d")
            self.day_spin_box.setSingleStep(1)  # Or e.g. 0.5 for QDoubleSpinBox
            self.day_spin_box.textChanged.connect(self.day_value_changed_str)

            self.config_tab_layout.addWidget(self.day_spin_box,idx_row,3,1,1)

            self.hour_spin_box = QSpinBox()

            self.hour_spin_box.setMinimum(-1) # allow it to roll over to a new day
            self.hour_spin_box.setMaximum(24) # allow it to roll over to a new day

            self.hour_spin_box.setSuffix(" h")
            self.hour_spin_box.setSingleStep(1)  # Or e.g. 0.5 for QDoubleSpinBox
            self.hour_spin_box.textChanged.connect(self.hour_value_changed_str)

            self.config_tab_layout.addWidget(self.hour_spin_box,idx_row,4,1,1)

            self.minute_spin_box = QSpinBox()

            self.minute_spin_box.setMinimum(-1)
            self.minute_spin_box.setMaximum(60)

            self.minute_spin_box.setSuffix(" min")
            self.minute_spin_box.setSingleStep(1)  # Or e.g. 0.5 for QDoubleSpinBox
            self.minute_spin_box.textChanged.connect(self.minute_value_changed_str)

            self.config_tab_layout.addWidget(self.minute_spin_box,idx_row,5,1,1)

            self.minute_fraction_spin_box = QDoubleSpinBox()

            self.minute_fraction_spin_box.setMinimum(-1)
            self.minute_fraction_spin_box.setMaximum(1)

            self.minute_fraction_spin_box.setDecimals(2) # set to 2 by default, but listen to diffusion_dt

            self.minute_fraction_spin_box.setSuffix(" min")
            self.minute_fraction_spin_box.setSingleStep(0.01)  # Or e.g. 0.5 for QDoubleSpinBox
            self.minute_fraction_spin_box.textChanged.connect(self.minute_fraction_value_changed_str)

            self.config_tab_layout.addWidget(self.minute_fraction_spin_box,idx_row,6,1,1)

... in max_time_changed_cb():

        if self.spinners_valid:
            self.minute_fraction_spin_box.setValue(fraction_minutes)
            self.minute_spin_box.setValue(minutes)
            self.hour_spin_box.setValue(hours)
            self.day_spin_box.setValue(days)

and also:

    def diffusion_dt_changed_cb(self):
        if not self.spinners_valid:
            return
        try:
         ...