Ejemplo n.º 1
0
def Create(name='PropertyBag'):
    '''Create(name = 'PropertyBag') ... creates a new setup sheet'''
    FreeCAD.ActiveDocument.openTransaction(
        translate("PathPropertyBag", "Create PropertyBag"))
    pcont = PathPropertyBag.Create(name)
    PathIconViewProvider.Attach(pcont.ViewObject, name)
    return pcont
Ejemplo n.º 2
0
 def test02(self):
     """refreshCustomPropertyGroups deletes empty groups"""
     bag = PathPropertyBag.Create()
     proxy = bag.Proxy
     proxy.addCustomProperty("App::PropertyString", "Title", "Address",
                             "Some description")
     bag.Title = "Madame"
     bag.removeProperty("Title")
     proxy.refreshCustomPropertyGroups()
     self.assertEqual(bag.Proxy.getCustomProperties(), [])
     self.assertEqual(bag.CustomPropertyGroups, [])
Ejemplo n.º 3
0
 def test01(self):
     """adding properties to a PropertyBag is tracked properly"""
     bag = PathPropertyBag.Create()
     proxy = bag.Proxy
     proxy.addCustomProperty("App::PropertyString", "Title", "Address",
                             "Some description")
     self.assertTrue(hasattr(bag, "Title"))
     bag.Title = "Madame"
     self.assertEqual(bag.Title, "Madame")
     self.assertEqual(bag.Proxy.getCustomProperties(), ["Title"])
     self.assertEqual(bag.CustomPropertyGroups, ["Address"])
Ejemplo n.º 4
0
 def test02(self):
     '''refreshCustomPropertyGroups deletes empty groups'''
     bag = PathPropertyBag.Create()
     proxy = bag.Proxy
     proxy.addCustomProperty('App::PropertyString', 'Title', 'Address',
                             'Some description')
     bag.Title = 'Madame'
     bag.removeProperty('Title')
     proxy.refreshCustomPropertyGroups()
     self.assertEqual(bag.Proxy.getCustomProperties(), [])
     self.assertEqual(bag.CustomPropertyGroups, [])
Ejemplo n.º 5
0
 def test01(self):
     '''adding properties to a PropertyBag is tracked properly'''
     bag = PathPropertyBag.Create()
     proxy = bag.Proxy
     proxy.addCustomProperty('App::PropertyString', 'Title', 'Address',
                             'Some description')
     self.assertTrue(hasattr(bag, 'Title'))
     bag.Title = 'Madame'
     self.assertEqual(bag.Title, 'Madame')
     self.assertEqual(bag.Proxy.getCustomProperties(), ['Title'])
     self.assertEqual(bag.CustomPropertyGroups, ['Address'])
Ejemplo n.º 6
0
 def test03(self):
     """refreshCustomPropertyGroups does not delete non-empty groups"""
     bag = PathPropertyBag.Create()
     proxy = bag.Proxy
     proxy.addCustomProperty("App::PropertyString", "Title", "Address",
                             "Some description")
     proxy.addCustomProperty("App::PropertyString", "Gender", "Attributes")
     bag.Title = "Madame"
     bag.Gender = "Female"
     bag.removeProperty("Gender")
     proxy.refreshCustomPropertyGroups()
     self.assertEqual(bag.Proxy.getCustomProperties(), ["Title"])
     self.assertEqual(bag.CustomPropertyGroups, ["Address"])
Ejemplo n.º 7
0
 def test03(self):
     '''refreshCustomPropertyGroups does not delete non-empty groups'''
     bag = PathPropertyBag.Create()
     proxy = bag.Proxy
     proxy.addCustomProperty('App::PropertyString', 'Title', 'Address',
                             'Some description')
     proxy.addCustomProperty('App::PropertyString', 'Gender', 'Attributes')
     bag.Title = 'Madame'
     bag.Gender = 'Female'
     bag.removeProperty('Gender')
     proxy.refreshCustomPropertyGroups()
     self.assertEqual(bag.Proxy.getCustomProperties(), ['Title'])
     self.assertEqual(bag.CustomPropertyGroups, ['Address'])
Ejemplo n.º 8
0
def Create(name="PropertyBag"):
    """Create(name = 'PropertyBag') ... creates a new setup sheet"""
    FreeCAD.ActiveDocument.openTransaction("Create PropertyBag")
    pcont = PathPropertyBag.Create(name)
    PathIconViewProvider.Attach(pcont.ViewObject, name)
    return pcont
Ejemplo n.º 9
0
 def test00(self):
     """basic PropertyBag creation and access test"""
     bag = PathPropertyBag.Create()
     self.assertTrue(hasattr(bag, "Proxy"))
     self.assertEqual(bag.Proxy.getCustomProperties(), [])
     self.assertEqual(bag.CustomPropertyGroups, [])