bimtester: small code improvements in gui

This commit is contained in:
Bernd Hahnebach
2020-11-30 07:49:03 +01:00
committed by Dion Moult
parent 7b7f756506
commit 24c542e33a
2 changed files with 33 additions and 19 deletions
+1 -1
View File
@@ -2,4 +2,4 @@ from os.path import dirname
from os.path import realpath from os.path import realpath
code_bimtester_path = dirname(realpath(__file__)) package_path = dirname(realpath(__file__))
+32 -18
View File
@@ -20,16 +20,20 @@ class GuiWidgetBimTester(QtWidgets.QWidget):
): ):
super(GuiWidgetBimTester, self).__init__() super(GuiWidgetBimTester, self).__init__()
# get some initial values # get features dir
user_path = os.path.expanduser("~") user_path = os.path.expanduser("~")
print(features) # print(features)
self.initial_featurespath = features self.initial_featurespath = features
if not os.path.isdir(self.initial_featurespath): if not os.path.isdir(self.initial_featurespath):
self.initial_featurespath = user_path self.initial_featurespath = user_path
print(ifcfile) print(self.initial_featurespath)
# get ifc file
# print(ifcfile)
self.initial_ifcfile = ifcfile self.initial_ifcfile = ifcfile
if not os.path.isfile(self.initial_ifcfile): if not os.path.isfile(self.initial_ifcfile):
self.initial_ifcfile = user_path self.initial_ifcfile = user_path
print(self.initial_ifcfile)
# init ui # init ui
self._setup_ui() self._setup_ui()
@@ -58,7 +62,10 @@ class GuiWidgetBimTester(QtWidgets.QWidget):
theicon = QtSvg.QSvgWidget(iconpath) theicon = QtSvg.QSvgWidget(iconpath)
# none works ... # none works ...
#theicon.setGeometry(20,20,200,200) #theicon.setGeometry(20,20,200,200)
#theicon.setSizePolicy(QtGui.QSizePolicy.Policy.Maximum, QtGui.QSizePolicy.Policy.Maximum) #theicon.setSizePolicy(
# QtGui.QSizePolicy.Policy.Maximum,
# QtGui.QSizePolicy.Policy.Maximum
#)
#theicon.sizeHint() #theicon.sizeHint()
""" """
# as pixmap # as pixmap
@@ -79,8 +86,7 @@ class GuiWidgetBimTester(QtWidgets.QWidget):
# use a layout with a frame and a title, see solver framework tp # use a layout with a frame and a title, see solver framework tp
# beside button # beside button
ffifc_str = ( ffifc_str = (
"Feature files beside IFC file. " "Feature files in a directory 'features' beside the IFC file."
"Feature files in directory features."
) )
featuredirfromifc_label = QtWidgets.QLabel(ffifc_str, self) featuredirfromifc_label = QtWidgets.QLabel(ffifc_str, self)
self.featuredirfromifc_cb = QtWidgets.QCheckBox(self) self.featuredirfromifc_cb = QtWidgets.QCheckBox(self)
@@ -91,7 +97,7 @@ class GuiWidgetBimTester(QtWidgets.QWidget):
# path browser and line edit # path browser and line edit
_ffdir_str = ( _ffdir_str = (
"Feature files directory. " "Feature files directory. "
"Feature files in directory features." "'features' directory has to be in there."
) )
_featurefilesdir_label = QtWidgets.QLabel(_ffdir_str, self) _featurefilesdir_label = QtWidgets.QLabel(_ffdir_str, self)
self.featurefilesdir_text = QtWidgets.QLineEdit() self.featurefilesdir_text = QtWidgets.QLineEdit()
@@ -118,14 +124,18 @@ class GuiWidgetBimTester(QtWidgets.QWidget):
# Layout: # Layout:
layout = QtWidgets.QGridLayout() layout = QtWidgets.QGridLayout()
layout.addWidget(theicon, 1, 0, alignment=QtCore.Qt.AlignRight) layout.addWidget(theicon, 1, 0, alignment=QtCore.Qt.AlignRight)
layout.addWidget(_ifcfile_label, 2, 0)
layout.addWidget(self.ifcfile_text, 3, 0) layout.addWidget(featuredirfromifc_label, 2, 0)
layout.addWidget(_ifcfile_browse_btn, 3, 1) layout.addWidget(self.featuredirfromifc_cb, 2, 1)
layout.addWidget(_featurefilesdir_label, 4, 0)
layout.addWidget(self.featurefilesdir_text, 5, 0) layout.addWidget(_featurefilesdir_label, 3, 0)
layout.addWidget(self.feafilesdir_browse_btn, 5, 1) layout.addWidget(self.featurefilesdir_text, 4, 0)
layout.addWidget(featuredirfromifc_label, 6, 0) layout.addWidget(self.feafilesdir_browse_btn, 4, 1)
layout.addWidget(self.featuredirfromifc_cb, 6, 1)
layout.addWidget(_ifcfile_label, 5, 0)
layout.addWidget(self.ifcfile_text, 6, 0)
layout.addWidget(_ifcfile_browse_btn, 6, 1)
layout.addLayout(_buttons, 7, 0) layout.addLayout(_buttons, 7, 0)
# row stretches by 10 compared to the others, std is 0 # row stretches by 10 compared to the others, std is 0
# first parameter is the row number # first parameter is the row number
@@ -186,17 +196,21 @@ class GuiWidgetBimTester(QtWidgets.QWidget):
print("Run BIMTester") print("Run BIMTester")
QtWidgets.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor) QtWidgets.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
# get input values # get features dir
if self.featuredirfromifc_cb.isChecked() is True: if self.featuredirfromifc_cb.isChecked() is True:
the_features_path = the_ifcfile_path the_features_path = os.path.dirname(os.path.realpath(
self.get_ifcfile()
))
print( print(
"Make sure the feature files are beside " "Make sure the feature files are beside "
"the ifc file in a directory named 'features'." "the ifc file in a directory named 'features'."
) )
else: else:
the_features_path = self.get_featurefilesdir() the_features_path = self.get_featurefilesdir()
the_ifcfile = self.get_ifcfile()
print(the_features_path) print(the_features_path)
# get ifc file
the_ifcfile = self.get_ifcfile()
print(the_ifcfile) print(the_ifcfile)
# run bimtester # run bimtester