Skip to content

Commit

Permalink
Merge pull request #2924 from eslickj/fix_model_viewer
Browse files Browse the repository at this point in the history
Fix model viewer
  • Loading branch information
blnicho authored Aug 1, 2023
2 parents 2f84f84 + 62722e0 commit cffefdd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
7 changes: 3 additions & 4 deletions pyomo/contrib/viewer/model_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,16 @@ def setModelData(self, editor, model, index):


class ModelBrowser(_ModelBrowser, _ModelBrowserUI):
def __init__(self, ui_data, parent=None, standard="Var"):
def __init__(self, ui_data, standard="Var"):
"""
Create a dock widdget with a QTreeView of a Pyomo model.
Create a dock widget with a QTreeView of a Pyomo model.
Args:
parent: parent widget
ui_data: Contains model and ui information
standard: A standard setup for different types of model components
{"Var", "Constraint", "Param", "Expression"}
"""
super().__init__(parent=parent)
super().__init__()
self.setupUi(self)
# The default int and double spin boxes are not good for this
# application. So just use regular line edits.
Expand Down
4 changes: 2 additions & 2 deletions pyomo/contrib/viewer/model_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class _ModelSelect(object):


class ModelSelect(_ModelSelect, _ModelSelectUI):
def __init__(self, ui_data, parent=None):
super().__init__(parent=parent)
def __init__(self, parent, ui_data):
super().__init__(parent)
self.setupUi(self)
self.ui_data = ui_data
self.closeButton.clicked.connect(self.close)
Expand Down
14 changes: 5 additions & 9 deletions pyomo/contrib/viewer/pyomo_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from pyomo.scripting.pyomo_parser import add_subparser
import pyomo.contrib.viewer.qt as myqt

qtconsole_app, qtconsole_available = attempt_import('qtconsole.qtconsoleapp')
qtconsole_app, qtconsole_available = attempt_import("qtconsole.qtconsoleapp")


class QtApp(
Expand Down Expand Up @@ -97,13 +97,9 @@ def kernel_pyomo_init(self, kc):
def init_qt_elements(self):
super().init_qt_elements()
self.kernel_pyomo_init(self.widget.kernel_client)
self.run_script_act = myqt.QtWidgets.QAction("&Run Script...", self.window)
self.show_ui_act = myqt.QtWidgets.QAction(
"&Show Pyomo Model Viewer", self.window
)
self.hide_ui_act = myqt.QtWidgets.QAction(
"&Hide Pyomo Model Viewer", self.window
)
self.run_script_act = myqt.QAction("&Run Script...", self.window)
self.show_ui_act = myqt.QAction("&Show Pyomo Model Viewer", self.window)
self.hide_ui_act = myqt.QAction("&Hide Pyomo Model Viewer", self.window)
self.window.file_menu.addSeparator()
self.window.file_menu.addAction(self.run_script_act)
self.window.view_menu.addSeparator()
Expand All @@ -125,7 +121,7 @@ def main(*args):
errors = list(myqt.import_errors)
if not qtconsole_available:
errors.append(qtconsole_app._moduleunavailable_message())
print("qt not available\n " + '\n '.join(errors))
print("qt not available\n " + "\n ".join(errors))
return
QtApp.launch_instance()

Expand Down
4 changes: 2 additions & 2 deletions pyomo/contrib/viewer/residual_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ class _ResidualTable(object):


class ResidualTable(_ResidualTable, _ResidualTableUI):
def __init__(self, ui_data, parent=None):
super().__init__(parent=parent)
def __init__(self, ui_data):
super().__init__()
self.setupUi(self)
self.ui_data = ui_data
datmodel = ResidualDataModel(parent=self, ui_data=ui_data)
Expand Down

0 comments on commit cffefdd

Please sign in to comment.