Changeset b3e8629 in sasview for src/sas/qtgui/Utilities/GuiUtils.py
- Timestamp:
- Nov 9, 2017 8:41:54 AM (7 years ago)
- Branches:
- ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- cee5c78
- Parents:
- 749b715
- git-author:
- Piotr Rozyczko <rozyczko@…> (10/26/17 03:13:05)
- git-committer:
- Piotr Rozyczko <rozyczko@…> (11/09/17 08:41:54)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Utilities/GuiUtils.py
- Property mode changed from 100644 to 100755
r88e1f57 rb3e8629 9 9 import warnings 10 10 import webbrowser 11 import url parse11 import urllib.parse 12 12 13 13 warnings.simplefilter("ignore") … … 86 86 #logging.error("Error loading %s/%s: %s" % (path, confg_file, sys.exc_value)) 87 87 except ValueError: 88 print "Value error"88 print("Value error") 89 89 pass 90 90 finally: … … 242 242 """ 243 243 assert isinstance(item, QtGui.QStandardItem) 244 assert isinstance(update_data, QtCore.QVariant) 245 py_update_data = update_data.toPyObject() 244 #assert isinstance(update_data, QtCore.QVariant) 245 #py_update_data = update_data.toPyObject() 246 py_update_data = update_data 246 247 247 248 # Check if data with the same ID is already present … … 249 250 plot_item = item.child(index) 250 251 if plot_item.isCheckable(): 251 plot_data = plot_item.child(0).data() .toPyObject()252 plot_data = plot_item.child(0).data() #.toPyObject() 252 253 if plot_data.id is not None and plot_data.id == py_update_data.id: 253 254 # replace data section in item … … 270 271 Adds QVariant 'update_data' to that row. 271 272 """ 272 assert isinstance(update_data, QtCore.QVariant) 273 py_update_data = update_data.toPyObject() 273 #assert isinstance(update_data, QtCore.QVariant) 274 #py_update_data = update_data.toPyObject() 275 py_update_data = update_data 274 276 275 277 checkbox_item = QtGui.QStandardItem() … … 309 311 object_item = QtGui.QStandardItem() 310 312 object_item.setText(name) 311 object_item.setData(QtCore.QVariant(update_data)) 313 #object_item.setData(QtCore.QVariant(update_data)) 314 object_item.setData(update_data) 312 315 313 316 # Append the new row to the main item … … 319 322 """ 320 323 assert isinstance(model_item, QtGui.QStandardItemModel) 321 assert isinstance(filename, basestring)324 assert isinstance(filename, str) 322 325 323 326 # Iterate over model looking for named items 324 item = list(filter(lambda i: str(i.text()) == filename, 325 [model_item.item(index) for index in range(model_item.rowCount())])) 327 item = list([i for i in [model_item.item(index) for index in range(model_item.rowCount())] if str(i.text()) == filename]) 326 328 return item[0] if len(item)>0 else None 327 329 … … 331 333 """ 332 334 assert isinstance(model_item, QtGui.QStandardItemModel) 333 assert isinstance(filename, basestring)335 assert isinstance(filename, str) 334 336 335 337 plot_data = [] … … 339 341 if str(item.text()) == filename: 340 342 # TODO: assure item type is correct (either data1/2D or Plotter) 341 plot_data.append(item.child(0).data() .toPyObject())343 plot_data.append(item.child(0).data()) #.toPyObject()) 342 344 # Going 1 level deeper only 343 345 for index_2 in range(item.rowCount()): … … 345 347 if item_2 and item_2.isCheckable(): 346 348 # TODO: assure item type is correct (either data1/2D or Plotter) 347 plot_data.append(item_2.child(0).data() .toPyObject())349 plot_data.append(item_2.child(0).data()) #.toPyObject()) 348 350 349 351 return plot_data … … 361 363 if item.isCheckable() and item.checkState() == QtCore.Qt.Checked: 362 364 # TODO: assure item type is correct (either data1/2D or Plotter) 363 plot_data.append((item, item.child(0).data() .toPyObject()))365 plot_data.append((item, item.child(0).data())) #.toPyObject())) 364 366 # Going 1 level deeper only 365 367 for index_2 in range(item.rowCount()): … … 367 369 if item_2 and item_2.isCheckable() and item_2.checkState() == QtCore.Qt.Checked: 368 370 # TODO: assure item type is correct (either data1/2D or Plotter) 369 plot_data.append((item_2, item_2.child(0).data() .toPyObject()))371 plot_data.append((item_2, item_2.child(0).data())) #.toPyObject())) 370 372 371 373 return plot_data … … 419 421 Check the URL first, though. 420 422 """ 421 parsed_url = url parse.urlparse(url)423 parsed_url = urllib.parse.urlparse(url) 422 424 if parsed_url.scheme: 423 425 webbrowser.open(url) 424 426 else: 425 427 msg = "Attempt at opening an invalid URL" 426 raise AttributeError , msg428 raise AttributeError(msg) 427 429 428 430 def retrieveData1d(data): … … 433 435 if not isinstance(data, Data1D): 434 436 msg = "Incorrect type passed to retrieveData1d" 435 raise AttributeError , msg437 raise AttributeError(msg) 436 438 try: 437 439 xmin = min(data.x) … … 441 443 data.filename 442 444 #logging.error(msg) 443 raise ValueError , msg445 raise ValueError(msg) 444 446 445 447 text = data.__str__() … … 485 487 if not isinstance(data, Data2D): 486 488 msg = "Incorrect type passed to retrieveData2d" 487 raise AttributeError , msg489 raise AttributeError(msg) 488 490 489 491 text = data.__str__() … … 499 501 dy_val = 0.0 500 502 len_data = len(data.qx_data) 501 for index in xrange(0, len_data):503 for index in range(0, len_data): 502 504 x_val = data.qx_data[index] 503 505 y_val = data.qy_data[index] … … 756 758 The assumption - data stored in SasView standard, in child 0 757 759 """ 758 return item.child(0).data() .toPyObject()760 return item.child(0).data() #.toPyObject() 759 761 760 762 def formatNumber(value, high=False):
Note: See TracChangeset
for help on using the changeset viewer.