Ticket #1015 (closed defect: fixed)

Opened 2 years ago

Last modified 2 years ago

Problem adding "exit" bitmapbutton

Reported by: lalong1@bellsouth.net Assigned to: somebody
Priority: major Milestone: 1.0
Component: ui Version:
Keywords: bitmapbutton Cc:

Description (Last modified by paul)

I am trying to build a simple toolbar, but when I add the "exit" bitmapbutton the class stop working. I think it may be because something that parses the xml file may not like the text "exit" showing up(??). The reason I think so is if I change the same object to use another bitmap button it starts working after I exit and re-enter dabo. Can someone verify the issue? Below is a copy of the cdxml file. To duplicate, load the file and run it first. It should run. Then change the "copy" button to the "exit" and re-try.

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<dPanel classID="47331504" BorderColor="(0, 0, 0)" sizerInfo="{}" Name="dPanel" Buffered="False" Top="0" Enabled="True" ToolTipText="None" Height="173" Width="392" ForeColor="(0, 0, 0)" designerClass="path://bcToolbar.cdxml" savedClass="True" BackColor="(236, 233, 216)" BorderStyle="Default" Left="0" BorderLineStyle="Solid" BorderWidth="0">
	<dSizer classID="47331504-44770320" Orientation="Vertical" DefaultBorderTop="False" DefaultBorderRight="False" DefaultBorderBottom="False" DefaultBorder="0" DefaultBorderLeft="False" designerClass="LayoutSizer" SlotCount="3">
		<dPanel classID="47331504-47947120" Spacing="3" sizerInfo="{'BorderSides': ['All'], 'Proportion': 0, 'HAlign': 'Left', 'VAlign': 'Top', 'Border': 0, 'Expand': True}" designerClass="LayoutSpacerPanel"></dPanel>
		<dSizer classID="47331504-47769296" sizerInfo="{'BorderSides': ['All'], 'Proportion': 0, 'HAlign': 'Left', 'VAlign': 'Top', 'Border': 0, 'Expand': True}" Orientation="Horizontal" DefaultBorderTop="False" DefaultBorderRight="False" DefaultBorderBottom="False" DefaultBorder="0" DefaultBorderLeft="False" designerClass="LayoutSizer" SlotCount="10">
			<dPanel classID="47331504-48526672" Spacing="3" sizerInfo="{'BorderSides': ['All'], 'Proportion': 0, 'HAlign': 'Left', 'VAlign': 'Top', 'Border': 0, 'Expand': True}" designerClass="LayoutSpacerPanel"></dPanel>
			<dBitmapButton classID="47331504-49087184" BorderColor="(0, 0, 0)" sizerInfo="{'BorderSides': ['All'], 'Proportion': 0, 'HAlign': 'Center', 'VAlign': 'Middle', 'Border': 0, 'Expand': False}" Name="dBitmapButton" Picture="save" Enabled="True" ForeColor="(0, 0, 0)" designerClass="controlMix" BorderWidth="0" BackColor="(236, 233, 216)" BorderStyle="Default" BorderLineStyle="Solid" ToolTipText="None"></dBitmapButton>
			<dPanel classID="47331504-48527216" Visible="True" sizerInfo="{'BorderSides': ['All'], 'Proportion': 1, 'HAlign': 'Left', 'VAlign': 'Top', 'Border': 0, 'Expand': True}" designerClass="LayoutPanel"></dPanel>
			<dPanel classID="47331504-48527376" Visible="True" sizerInfo="{'BorderSides': ['All'], 'Proportion': 1, 'HAlign': 'Left', 'VAlign': 'Top', 'Border': 0, 'Expand': True}" designerClass="LayoutPanel"></dPanel>
			<dPanel classID="47331504-48527600" Visible="True" sizerInfo="{'BorderSides': ['All'], 'Proportion': 1, 'HAlign': 'Left', 'VAlign': 'Top', 'Border': 0, 'Expand': True}" designerClass="LayoutPanel"></dPanel>
			<dPanel classID="47331504-48527760" Visible="True" sizerInfo="{'BorderSides': ['All'], 'Proportion': 1, 'HAlign': 'Left', 'VAlign': 'Top', 'Border': 0, 'Expand': True}" designerClass="LayoutPanel"></dPanel>
			<dPanel classID="47331504-48527920" Visible="True" sizerInfo="{'BorderSides': ['All'], 'Proportion': 1, 'HAlign': 'Left', 'VAlign': 'Top', 'Border': 0, 'Expand': True}" designerClass="LayoutPanel"></dPanel>
			<dPanel classID="47331504-48528080" Visible="True" sizerInfo="{'BorderSides': ['All'], 'Proportion': 1, 'HAlign': 'Left', 'VAlign': 'Top', 'Border': 0, 'Expand': True}" designerClass="LayoutPanel"></dPanel>
			<dBitmapButton classID="47331504-43816784" BorderColor="(0, 0, 0)" sizerInfo="{'BorderSides': ['All'], 'Proportion': 1, 'HAlign': 'Left', 'VAlign': 'Top', 'Border': 0, 'Expand': True}" Name="dBitmapButton1" Picture="copy" Enabled="True" ForeColor="(0, 0, 0)" designerClass="controlMix" BorderWidth="0" BackColor="(236, 233, 216)" BorderStyle="Default" BorderLineStyle="Solid" ToolTipText="None"></dBitmapButton>
			<dPanel classID="47331504-49024272" Spacing="3" sizerInfo="{'BorderSides': ['All'], 'Proportion': 0, 'HAlign': 'Left', 'VAlign': 'Top', 'Border': 0, 'Expand': True}" designerClass="LayoutSpacerPanel"></dPanel>
		</dSizer>
		<dPanel classID="47331504-48383760" Spacing="3" sizerInfo="{'BorderSides': ['All'], 'Proportion': 0, 'HAlign': 'Left', 'VAlign': 'Top', 'Border': 0, 'Expand': True}" designerClass="LayoutSpacerPanel"></dPanel>
	</dSizer>
</dPanel>

Change History

(in reply to: ↑ description ) 03/10/2007 08:13:12 PM changed by ed leafe

Replying to lalong1@bellsouth.net:

I am trying to build a simple toolbar, but when I add the "exit" bitmapbutton the class stop working. I think it may be because something that parses the xml file may not like the text "exit" showing up(??). The reason I think so is if I change the same object to use another bitmap button it starts working after I exit and re-enter dabo. Can someone verify the issue? Below is a copy of the cdxml file. To duplicate, load the file and run it first. It should run. Then change the "copy" button to the "exit" and re-try.

Can you post that as an attachment? The wiki formatting messes it up too much to test.

03/26/2007 01:01:33 PM changed by Jussi Salmela

My Environment is:

Platform: Win Python Version: 2.5 on win32 Dabo Version: Version 0.7.2s; Revision 2719 UI Version: 2.8.1.1 on wxMSW Dabo IDE version 0.7.1s (Revision 755)

It looks like the problem has got nothing to do wit the toolbar. I start the ClassDesigner?, insert one bitmapbutton there, rename it to be 'exit' and run. Here's the result:

===================================================== Traceback (most recent call last):

File "c:\python25\lib\site-packages\Dabo-0.7.2s-py2.5.egg\dabo\lib\eventMixin.

py", line 97, in raiseEvent

bindingFunction(event)

File "C:\Python\Dabo\daboide\ClassDesigner?.py", line 1294, in onRunDesign

self.currentForm.onRunDesign(evt)

File "C:\Python\Dabo\daboide\ClassDesignerFormMixin?.py", line 493, in onRunDes

ign

frm = dui.createForm(self._classFile)

File "c:\python25\lib\site-packages\Dabo-0.7.2s-py2.5.egg\dabo\ui\uiwx\init_

_.py", line 836, in createForm

frm = cls()

File "", line 35, in init File "", line 53, in init File "c:\python25\lib\site-packages\Dabo-0.7.2s-py2.5.egg\dabo\ui\uiwx\dBitmap

Button.py", line 39, in init

cm.dControlMixin.init(self, preClass, parent, properties, *args, **kwarg

s)

File "c:\python25\lib\site-packages\Dabo-0.7.2s-py2.5.egg\dabo\ui\uiwx\dPemMix

in.py", line 175, in init

self._setProperties(properties)

File "c:\python25\lib\site-packages\Dabo-0.7.2s-py2.5.egg\dabo\ui\uiwx\dPemMix

in.py", line 208, in _setProperties

self.setProperties(properties)

File "c:\python25\lib\site-packages\Dabo-0.7.2s-py2.5.egg\dabo\lib\propertyHel

perMixin.py", line 186, in setProperties

_setProps(propDict)

File "c:\python25\lib\site-packages\Dabo-0.7.2s-py2.5.egg\dabo\lib\propertyHel

perMixin.py", line 176, in _setProps

setter(self, _propDict[prop])

File "c:\python25\lib\site-packages\Dabo-0.7.2s-py2.5.egg\dabo\ui\uiwx\dPemMix

in.py", line 1912, in _setNameBase

self._setName(val, False)

File "c:\python25\lib\site-packages\Dabo-0.7.2s-py2.5.egg\dabo\ui\uiwx\dPemMix

in.py", line 1852, in _setName

nameError = hasattr(parent, candidate) \

TypeError?: hasattr(): attribute name must be string =====================================================

If I change the name to be 'copy' and run, I get a dialog saying:

===================================================== Could not set property 'Name' to value 'copy'. Reason: 'Name 'copy' is already in use.' ===================================================== Maybe version differences are enough to explain the behaviour differences with 'copy' compared to the original error report.

I don't understand anything about the situation but that doesn't keep me from making a suggestion;): if certain names cause unwanted behaviour, let's just ban those names. You know: world's full of names and if the supply runs out, we all can easily invent a few thousand new ones!

Besides: copy as a name for a button is not a good one anyway: it's too general and unspecific. Better ones are copyBtn, copyRecord, doCopy etc.

Well, this was just my 2 cents' worth,

Cheers, Jussi

03/26/2007 01:33:20 PM changed by ed

You can't name an object the same as any other object in the same parent container, because the parent has to be able to resolve those names. Likewise, if you try to name an object 'copy', 'exit', or any other existing attribute or method of the parent, it will likewise reject that, since that 'name' is already taken in the parent object's namespace.

You're always better off not using common words, but using specific names, such as 'btnExit' for your controls.

03/27/2007 05:47:27 AM changed by paul

  • description changed.

03/27/2007 10:04:36 AM changed by ed

OK, I tracked down the problem. 'exit' is a method in the builtins module, and so eval('exit') is being called when assigning the attribute to the object. That's causing all of the problems.

I need to track down all the places where this is happening to make sure that this and any of the other built-in names don't cause similar problems.

03/27/2007 10:47:27 AM changed by ed

  • status changed from new to closed.
  • resolution set to fixed.

Fixed with changeset [2989]