Python生成随机数原创
金蝶云社区-Login255
Login255
3人赞赏了该文章 950次浏览 未经作者许可,禁止转载编辑于2021年09月21日 18:41:04

#以生成随机颜色演示

#表单插件,By张印东(2021-9-21)

#Python测试->变更颜色:随机生成RGB颜色值并应用到“单据类型”字段

#本插件仅演示了改变背景色,前景色固定为白色

#注册为表单插件,通过菜单按钮调用;

#直接拷贝/粘贴会导致缩进格式问题,请下载附件


from System import Random   #因为星空Python不支持引入第三方包,所以这里使用.NET系统的Random类生成随机数

def BarItemClick(e):

  if e.BarItemKey == "ora_tbButton_9": #按钮ID

  color = Random();

  bgcolor = str(color.Next(80,150)) + ',' + str(color.Next(80,150)) + ',' + str(color.Next(80,150)); #可根据需要修改Next参数

  #this.View.Model.SetValue("F_ora_Text1", "单据类型字段,背景色:" + bgcolor + "  前景色:" + forecolor);

  this.View.GetControl("FBillTypeID").SetCustomPropertyValue("backcolor", bgcolor); #需根据需要修改字段标识

  forecolor =  "255,255,255";

  this.View.GetControl("FBillTypeID").SetCustomPropertyValue("forecolor", forecolor);


赞 3