Improved error handling

This commit is contained in:
Patrick F
2020-04-11 19:27:37 +02:00
parent 901d2f90aa
commit cb293618cf
2 changed files with 46 additions and 12 deletions

View File

@@ -75,6 +75,9 @@
<height>32</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Rename Tool Table&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string/>
</property>
@@ -92,6 +95,9 @@
<height>32</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Add New Tool Table&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string/>
</property>
@@ -109,6 +115,9 @@
<height>32</height>
</size>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Remove Tool Table from Disc&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string/>
</property>
@@ -161,6 +170,19 @@
</item>
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="addToolController">
<property name="text">
@@ -173,13 +195,16 @@
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<width>14</width>
<height>20</height>
</size>
</property>

View File

@@ -39,7 +39,7 @@ import json
import os
import traceback
import uuid as UUID
import glob
from functools import partial
#PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
#PathLog.trackModule(PathLog.thisModule())
@@ -149,6 +149,7 @@ class ToolBitLibrary(object):
self.libraryLoad(path)
self.form.addToolController.setEnabled(False)
self.form.ButtonRemoveToolTable.setEnabled(False)
def _toolAdd(self, nr, tool, path):
toolNr = PySide.QtGui.QStandardItem()
@@ -233,8 +234,8 @@ class ToolBitLibrary(object):
sel = len(self.toolTableView.selectedIndexes()) > 0
self.form.toolDelete.setEnabled(sel)
addTCSelectedText = translate("PathToolLibraryManager", "Add SELECTED as Tool Controllers in the Job")
addTCAllText = translate("PathToolLibraryManager", "Add ALL as Tool Controllers in the Job")
#addTCSelectedText = translate("PathToolLibraryManager", "Add SELECTED as Tool Controllers in the Job")
#addTCAllText = translate("PathToolLibraryManager", "Add ALL as Tool Controllers in the Job")
if sel:
self.form.addToolController.setEnabled(True)
@@ -245,16 +246,13 @@ class ToolBitLibrary(object):
''' loads the tools for the selected tool table '''
name = self.form.TableList.itemWidget(self.form.TableList.itemFromIndex(index)).getTableName()
self.libraryLoad(PathPreferences.lastPathToolLibrary() + '/' + name)
self.form.ButtonRemoveToolTable.setEnabled(True)
def open(self, path=None, dialog=False):
'''open(path=None, dialog=False) ... load library stored in path and bring up ui.
Returns 1 if user pressed OK, 0 otherwise.'''
if path:
fullPath = PathToolBit.findLibrary(path)
if fullPath:
self.libraryLoad(fullPath)
else:
self.libraryOpen()
self.libraryOpen(False)
elif dialog:
self.libraryOpen()
return self.form.exec_()
@@ -266,7 +264,9 @@ class ToolBitLibrary(object):
self.form.librarySave.setEnabled(False)
def libraryOpen(self, filedialog=True):
import glob
PathLog.track()
if filedialog:
path = PySide.QtGui.QFileDialog.getExistingDirectory(self.form, 'Tool Library Path', PathPreferences.lastPathToolLibrary(), 1)
if len(path) > 0:
@@ -295,9 +295,19 @@ class ToolBitLibrary(object):
self.form.TableList.addItem(listWidgetItem)
self.form.TableList.setItemWidget(listWidgetItem, listItem)
self.path = []
self.form.ButtonRemoveToolTable.setEnabled(False)
self.toolTableView.setUpdatesEnabled(False)
self.model.clear()
self.model.setHorizontalHeaderLabels(self.columnNames())
self.toolTableView.resizeColumnsToContents()
self.toolTableView.setUpdatesEnabled(True)
if len(self.LibFiles) > 0:
self.libraryLoad(self.LibFiles[0])
self.form.TableList.setCurrentRow(0)
self.form.ButtonRemoveToolTable.setEnabled(True)
def libraryLoad(self, path):
self.toolTableView.setUpdatesEnabled(False)
@@ -305,7 +315,6 @@ class ToolBitLibrary(object):
self.model.setHorizontalHeaderLabels(self.columnNames())
if path:
#print(f"Path: {path}")
with open(path) as fp:
library = json.load(fp)
@@ -476,7 +485,7 @@ class ToolBitLibrary(object):
self.form.ButtonRenameToolTable.clicked.connect(self.renameLibrary)
#self.form.libraryNew.clicked.connect(self.libraryNew)
self.form.libraryOpen.clicked.connect(self.libraryOpen)
self.form.libraryOpen.clicked.connect(partial(self.libraryOpen, True))
self.form.librarySave.clicked.connect(self.librarySave)
self.form.librarySaveAs.clicked.connect(self.librarySaveAs)
self.form.libraryCancel.clicked.connect(self.libraryCancel)