Here is my code and the result. I gave the button an image attribute and a path. The code does not show an error, but the button does not show an image
#prvb.Imager = ed.Bitmap(image_path)
import scriptcontext as sc
import rhinoscriptsyntax as rs
import Rhino
from Rhino.UI import RhinoEtoApp, EtoExtensions
import Eto.Forms as ef
import Eto.Drawing as ed
image_path = r"J:\assets\SLOGO\JCAD\curve.png"
#RhinoEtoApp.MainWindowForDocument(sc.doc)
#SampleTransparentEtoForm(Eto.Forms.Form):
parent = RhinoEtoApp.MainWindowForDocument(sc.doc)
table_layout = ef.TableLayout()
table_layout.Padding = ed.Padding(8)
table_layout.Spacing = ed.Size(4, 4)
ceshi_label = ef.Label()
ceshi_label.Text = "测试:"
sil_0 = ef.Slider()
sil_0.Text = ""
sil_0.MaxValue = 10
sil_0.MinValue = 0
sil_0.Value = 3
m_numeric_updown = ef.NumericUpDown()
m_numeric_updown.DecimalPlaces = 2
m_numeric_updown.Increment = 1
m_numeric_updown.MaxValue = 10.0
m_numeric_updown.MinValue = 0.0
m_numeric_updown.Value = 3.0
prvb = ef.Button()
prvb.Imager = ed.Bitmap(image_path)
#J:\assets\SLOGO\JCAD\curve.png
#prvb.Text = "测试"
m_numeric_updown.ValueBinding.Bind(sil_0, "Value", ef.DualBindingMode.TwoWay)
row_0 = ef.TableRow()
row_0.Cells.Add(ef.TableCell(sil_0))
row_0.Cells.Add(ef.TableCell(m_numeric_updown))
row_1 = ef.TableRow()
row_1.Cells.Add(ef.TableCell(prvb))
#row_1.Cells.Add(ef.TableCell(ceshi_label))
#row_N = ef.TableRow()
#row_N.Cells.Add(ef.TableCell(controls))
table_layout.Rows.Add(row_0)
table_layout.Rows.Add(row_1)
#table_layout.Rows.Add(row_N)
def on_print(s, e):
#object_id = rs.GetObject("测试")
se = sil_0.Value
#ceshi_label.Text = rs.ObjectName(object_id, name=None)
print(se)
prvb.Click += on_print
dialog = ef.Dialog()
dialog.Content = table_layout
#dialog.Width = 200
#dialog.Height =300
dialog.Resizable = True
dialog.Title = "测试"
EtoExtensions.ShowSemiModal(dialog, sc.doc, parent)
4 posts - 2 participants
