Skip to content

Commit

Permalink
Switched Material module to pyside
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Jan 6, 2014
1 parent 2954d9a commit 14f2dd2
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions src/Mod/Material/MaterialEditor.py
Expand Up @@ -21,12 +21,28 @@
#***************************************************************************

import FreeCAD, os
from PyQt4 import QtCore, QtGui, uic
from PySide import QtCore, QtGui, QtUiTools

__title__="FreeCAD material editor"
__author__ = "Yorik van Havre"
__url__ = "http://www.freecadweb.org"

# pyside dynamic ui loader from
# from https://github.com/lunaryorn/snippets/blob/master/qt4/designer/pyside_dynamic.py
class UiLoader(QtUiTools.QUiLoader):
def __init__(self, baseinstance):
QtUiTools.QUiLoader.__init__(self, baseinstance)
self.baseinstance = baseinstance

def createWidget(self, class_name, parent=None, name=''):
if parent is None and self.baseinstance:
return self.baseinstance
else:
widget = QtUiTools.QUiLoader.createWidget(self, class_name, parent, name)
if self.baseinstance:
setattr(self.baseinstance, name, widget)
return widget

class MaterialEditor(QtGui.QDialog):

def __init__(self, obj = None, prop = None):
Expand All @@ -36,8 +52,12 @@ def __init__(self, obj = None, prop = None):
self.prop = prop
self.customprops = []
# load the UI file from the same directory as this script
uic.loadUi(os.path.dirname(__file__)+os.sep+"materials-editor.ui",self)
loader = UiLoader(self)
widget = loader.load(os.path.dirname(__file__)+os.sep+"materials-editor.ui")
#QtCore.QMetaObject.connectSlotsByName(widget)
self.ui = self
print self.ui
print dir(self.ui)
# additional UI fixes and tweaks
self.ButtonURL.setIcon(QtGui.QIcon(":/icons/internet-web-browser.svg"))
self.ButtonDeleteProperty.setEnabled(False)
Expand Down Expand Up @@ -85,6 +105,7 @@ def updateCards(self):

def updateContents(self,data):
"updates the contents of the editor with the given data (can be the name of a card or a dictionary)"
print type(data)
if isinstance(data,dict):
self.clearEditor()
for k,i in data.iteritems():
Expand All @@ -95,7 +116,7 @@ def updateContents(self,data):
slot.setText(1,i)
else:
self.addCustomProperty(k,i)
elif isinstance(data,QtCore.QString):
elif isinstance(data,unicode):
k = str(data)
if k:
if k in self.cards:
Expand Down

0 comments on commit 14f2dd2

Please sign in to comment.