Cleanup. And fixes #148.

This commit is contained in:
Juan Pablo Caram
2015-09-11 14:45:08 -04:00
parent 71aca80603
commit 22119072d3
6 changed files with 49 additions and 32 deletions

View File

@@ -1,7 +1,10 @@
from PyQt4 import QtGui, QtCore
from copy import copy
import FlatCAMApp
#import FlatCAMApp
import re
import logging
log = logging.getLogger('base')
class RadioSet(QtGui.QWidget):
@@ -37,7 +40,7 @@ class RadioSet(QtGui.QWidget):
self.group_toggle_fn = lambda: None
def on_toggle(self):
FlatCAMApp.App.log.debug("Radio toggled")
log.debug("Radio toggled")
radio = self.sender()
if radio.isChecked():
self.group_toggle_fn()
@@ -47,7 +50,7 @@ class RadioSet(QtGui.QWidget):
for choice in self.choices:
if choice['radio'].isChecked():
return choice['value']
FlatCAMApp.App.log.error("No button was toggled in RadioSet.")
log.error("No button was toggled in RadioSet.")
return None
def set_value(self, val):
@@ -55,7 +58,7 @@ class RadioSet(QtGui.QWidget):
if choice['value'] == val:
choice['radio'].setChecked(True)
return
FlatCAMApp.App.log.error("Value given is not part of this RadioSet: %s" % str(val))
log.error("Value given is not part of this RadioSet: %s" % str(val))
class LengthEntry(QtGui.QLineEdit):
@@ -78,7 +81,7 @@ class LengthEntry(QtGui.QLineEdit):
if val is not None:
self.set_text(QtCore.QString(str(val)))
else:
FlatCAMApp.App.log.warning("Could not interpret entry: %s" % self.get_text())
log.warning("Could not interpret entry: %s" % self.get_text())
def get_value(self):
raw = str(self.text()).strip(' ')
@@ -92,7 +95,7 @@ class LengthEntry(QtGui.QLineEdit):
else:
return float(eval(match.group(1)))
except:
FlatCAMApp.App.log.warning("Could not parse value in entry: %s" % str(raw))
log.warning("Could not parse value in entry: %s" % str(raw))
return None
def set_value(self, val):
@@ -108,14 +111,14 @@ class FloatEntry(QtGui.QLineEdit):
if val is not None:
self.set_text(QtCore.QString(str(val)))
else:
FlatCAMApp.App.log.warning("Could not interpret entry: %s" % self.text())
log.warning("Could not interpret entry: %s" % self.text())
def get_value(self):
raw = str(self.text()).strip(' ')
try:
evaled = eval(raw)
except:
FlatCAMApp.App.log.error("Could not evaluate: %s" % str(raw))
log.error("Could not evaluate: %s" % str(raw))
return None
return float(evaled)
@@ -168,14 +171,14 @@ class EvalEntry(QtGui.QLineEdit):
if val is not None:
self.setText(QtCore.QString(str(val)))
else:
FlatCAMApp.App.log.warning("Could not interpret entry: %s" % self.get_text())
log.warning("Could not interpret entry: %s" % self.get_text())
def get_value(self):
raw = str(self.text()).strip(' ')
try:
return eval(raw)
except:
FlatCAMApp.App.log.error("Could not evaluate: %s" % str(raw))
log.error("Could not evaluate: %s" % str(raw))
return None
def set_value(self, val):
@@ -226,19 +229,19 @@ class VerticalScrollArea(QtGui.QScrollArea):
:return:
"""
if event.type() == QtCore.QEvent.Resize and source == self.widget():
# FlatCAMApp.App.log.debug("VerticalScrollArea: Widget resized:")
# FlatCAMApp.App.log.debug(" minimumSizeHint().width() = %d" % self.widget().minimumSizeHint().width())
# FlatCAMApp.App.log.debug(" verticalScrollBar().width() = %d" % self.verticalScrollBar().width())
# log.debug("VerticalScrollArea: Widget resized:")
# log.debug(" minimumSizeHint().width() = %d" % self.widget().minimumSizeHint().width())
# log.debug(" verticalScrollBar().width() = %d" % self.verticalScrollBar().width())
self.setMinimumWidth(self.widget().sizeHint().width() +
self.verticalScrollBar().sizeHint().width())
# if self.verticalScrollBar().isVisible():
# FlatCAMApp.App.log.debug(" Scroll bar visible")
# log.debug(" Scroll bar visible")
# self.setMinimumWidth(self.widget().minimumSizeHint().width() +
# self.verticalScrollBar().width())
# else:
# FlatCAMApp.App.log.debug(" Scroll bar hidden")
# log.debug(" Scroll bar hidden")
# self.setMinimumWidth(self.widget().minimumSizeHint().width())
return QtGui.QWidget.eventFilter(self, source, event)