Skip to content

Commit

Permalink
Fix bug with handling of UserWarning exceptions; change the way the "…
Browse files Browse the repository at this point in the history
…No CAD model definitions" warning works from raising a UserWarning to using its own function.
  • Loading branch information
ssilburn committed Mar 18, 2018
1 parent 14309ce commit ea1aa9a
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions calcam/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def show_exception_box(self,excep_type,excep_value,tb):
dialog.setStandardButtons(qt.QMessageBox.Ok)
dialog.setTextFormat(qt.Qt.RichText)
dialog.setWindowTitle('Calcam')
dialog.setText(excep_value.message)
dialog.setText(str(excep_value))
dialog.setIcon(qt.QMessageBox.Information)
dialog.exec_()
# Check if we've run out of memory:
Expand All @@ -121,6 +121,17 @@ def show_exception_box(self,excep_type,excep_value,tb):
dialog.setIcon(qt.QMessageBox.Warning)
dialog.exec_()


def warn_no_models(self):
dialog = qt.QMessageBox(self)
dialog.setStandardButtons(qt.QMessageBox.Ok)
dialog.setTextFormat(qt.Qt.RichText)
dialog.setWindowTitle('Calcam - No CAD Models')
dialog.setText('No CAD model definitions were found. To define some, see the example at:<br><br>{:s}\Example.py'.format(paths.machine_geometry))
dialog.setIcon(qt.QMessageBox.Information)
dialog.exec_()


# We start off with some functions which are common to the various GUIs
def init_viewports_list(self):

Expand Down Expand Up @@ -327,7 +338,7 @@ def __init__(self, app, parent = None):

# Warn the user if we don't have any CAD models
if self.model_list == {}:
raise UserWarning('No machine CAD model definitions were found. To define some, see the example in:<br>' + paths.machine_geometry)
warn_no_models(self)


def change_cad_view(self,view_item,init=False):
Expand Down Expand Up @@ -926,8 +937,7 @@ def __init__(self, app, parent = None):

# Warn the user if we don't have any CAD models
if self.model_list == {}:
raise UserWarning('No machine CAD model definitions were found. To define some, see the example in:<br>' + paths.machine_geometry)

warn_no_models(self)


def change_cad_view(self,view_item,init=False):
Expand Down Expand Up @@ -2920,7 +2930,7 @@ def __init__(self, app, parent = None):

# Warn the user if we don't have any CAD models
if self.model_list == {}:
raise UserWarning('No machine CAD model definitions were found. To define some, see the example in:<br>' + paths.machine_geometry)
warn_no_models(self)


def change_cad_view(self,view_index,init=False):
Expand Down Expand Up @@ -3397,7 +3407,7 @@ def __init__(self, app, parent = None):

# Warn the user if we don't have any CAD models
if self.model_list == {}:
raise UserWarning('No machine CAD model definitions were found. To define some, see the example in:<br>' + paths.machine_geometry)
warn_no_models(self)

def toggle_real_pixel_size(self,real_pixel_size):
self.focal_length_box.blockSignals(True)
Expand Down Expand Up @@ -4241,7 +4251,7 @@ def __init__(self, app, parent = None):

# Warn the user if we don't have any CAD models
if self.model_list == {}:
raise UserWarning('No machine CAD model definitions were found. To define some, see the example in:<br>' + paths.machine_geometry)
warn_no_models(self)


def update_position_info(self,coords_2d,coords_3d,visible):
Expand Down

0 comments on commit ea1aa9a

Please sign in to comment.