当我从列表中选择第二个按钮时,Windows.Forms.RadioButton崩溃 [英] Windows.Forms.RadioButton crashes when I select the second button from a list

查看:60
本文介绍了当我从列表中选择第二个按钮时,Windows.Forms.RadioButton崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的Windows,



我在主机应用程序(Revit)中运行此代码(位于底部)。该代码可以从Windows命令行(python radios.py)完美运行。行为应该是"当检查另一个单选按钮时,所有其他单选按钮未被检查",并且在Revit内部,
当我检查第二个按钮时我得到了这个崩溃。



Dear Windows,

I run this code (at the bottom) from within a host application (Revit). The code works perfectly from a windows command line (python radios.py). The behavior should be "when another radiobutton is checked, all others are uncheked", and inside of Revit, as I check the second button I get this crash.

Unhandled exception has occurred in a component in your application. If you click Continue, the application will ignore this error and attempt to continue.





Absolute path information is required.



" Details":$


"Details":

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.ArgumentException: Absolute path information is required.
   at System.Security.Util.StringExpressionSet.CreateListFromExpressions(String[] str, Boolean needFullPath)
   at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)
   at System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String path)
   at System.Windows.Forms.Control.ControlVersionInfo.GetFileVersionInfo()
   at System.Windows.Forms.Control.ControlVersionInfo.get_CompanyName()
   at IronPython.NewTypes.System.Windows.Forms.RadioButton_22$22.#base#get_CompanyName()
   at Microsoft.Scripting.Interpreter.FuncCallInstruction`2.Run(InterpretedFrame frame)
   at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
   at Microsoft.Scripting.Interpreter.LightLambda.Run3[T0,T1,T2,TRet](T0 arg0, T1 arg1, T2 arg2)
   at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
   at Microsoft.Scripting.Interpreter.FuncCallInstruction`5.Run(InterpretedFrame frame)
   at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
   at Microsoft.Scripting.Interpreter.LightLambda.Run3[T0,T1,T2,TRet](T0 arg0, T1 arg1, T2 arg2)
   at IronPython.Runtime.Types.BuiltinFunction.Call0(CodeContext context, SiteLocalStorage`1 storage, Object instance)
   at IronPython.Runtime.Types.ReflectedProperty.CallGetter(CodeContext context, PythonType owner, SiteLocalStorage`1 storage, Object instance)
   at IronPython.Runtime.Types.ReflectedProperty.TryGetValue(CodeContext context, Object instance, PythonType owner, Object& value)
   at IronPython.Runtime.Types.PythonType.TryGetNonCustomMember(CodeContext context, Object instance, String name, Object& value)
   at IronPython.Runtime.Operations.PythonOps.ObjectGetAttribute(CodeContext context, Object o, String name)
   at IronPython.Runtime.Operations.CustomTypeDescHelpers.GetPropertiesImpl(Object self, Attribute[] attributes)
   at IronPython.Runtime.Operations.CustomTypeDescHelpers.GetProperties(Object self)
   at System.ComponentModel.TypeDescriptor.MergedTypeDescriptor.System.ComponentModel.ICustomTypeDescriptor.GetProperties()
   at System.ComponentModel.TypeDescriptor.GetPropertiesImpl(Object component, Attribute[] attributes, Boolean noCustomTypeDesc, Boolean noAttributes)
   at System.Windows.Forms.RadioButton.PerformAutoUpdates(Boolean tabbedInto)
   at System.Windows.Forms.RadioButton.set_Checked(Boolean value)
   at IronPython.NewTypes.System.Windows.Forms.RadioButton_22$22.OnClick(EventArgs e)
   at System.Windows.Forms.RadioButton.OnMouseUp(MouseEventArgs mevent)
   at IronPython.NewTypes.System.Windows.Forms.RadioButton_22$22.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at IronPython.NewTypes.System.Windows.Forms.RadioButton_22$22.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)










radios.py




radios.py

# Windows utilities and IronPython stuff
import clr
clr.AddReference("System.Drawing")
import System.Drawing as wdrawing
clr.AddReference("System.Windows.Forms")
import System.Windows.Forms as wforms


class RoadRadioButton(wforms.RadioButton):

    def __init__(self, name, radios_collection):

        self.radios_collection = radios_collection
        
        self.Text = name
        self.MouseHover += self.onMouseHover
        self.MouseLeave += self.onMouseLeave
        self.CheckedChanged += self.checkedChanged
        print("init %s" % self.Text)

    def onMouseHover(self, sender, args):
        print("onMouseHover %s " % self.Text)

    def onMouseLeave(self, sender, args):
        print("onMouseLeave %s " % self.Text)

    def checkedChanged(self, sender, args):
        print("checkedChanged %s " % self.Text)
        for cb in self.radios_collection:
            if cb.Checked and cb != self:
                cb.Checked = False
        self.Checked = True



class RadiosForm(wforms.Form):
    
    def __init__(self, *args, **kwargs):

        self.Text = "" if "title" not in kwargs else kwargs["title"]
        self.num = 1 if "num" not in kwargs else int(kwargs["num"])

        self.AutoSize = True
        #self.Location = wdrawing.Point(20,20)

        print("init %s " % self.Text)

        # creation of a title
        l = wforms.Label()
        l.Text = "Init radio form: list of buttons:"
        l.AutoSize = True
        l.Location = wdrawing.Point(10, 10)
        self.lab_intro = l
        self.Controls.Add(self.lab_intro)


        # addition of all radios with events 
        self.radios = list()
        self.groupbox = wforms.GroupBox()
        lineno, height = 20, 25
        for i in range(1, self.num+1):
            rbname = "radio %d" % i
            print("\t\tprocessing %s" % rbname)
            rb = RoadRadioButton(rbname, self.radios)
            rb.Location = wdrawing.Point(30, lineno + height)
            rb.AutoCheck = True
            rb.AutoSize = True
            #self.radios.append(rb)
            self.groupbox.Controls.Add(rb)
            #self.Controls.Add(self.radios[len(self.radios)-1])
            lineno += height
        self.Controls.Add(self.groupbox)

        # cancel button
        b = wforms.Button()
        b.Text = "Cancel"
        b.Height = 30
        b.Width = 100
        b.Location = wdrawing.Point(170,310)
        b.Click += self.close
        self.btn_cancel = b
        self.Controls.Add(self.btn_cancel)

    def close(self, sender=None, args=None):
        print(">>> closing %s" % self.Text)
        self.Dispose()


f = RadiosForm(title="Radios Form", num=5)
f.ShowDialog()







推荐答案

嗨angelo.mastro,

Hi angelo.mastro,

此论坛 d 使用c#使用Windows窗体控件和功能进行客户端应用程序开发,您的问题与
Iron Python,我建议您可以在以下链接上发布您的反馈。

https://ironpython.net/sup port /

祝你好运,

Kyle


这篇关于当我从列表中选择第二个按钮时,Windows.Forms.RadioButton崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆