Is there a minimum Eto textbox size?

I can’t make these boxes smaller:

Hi @Asterisk,

Can you post the code that creates this?

– Dale

import Rhino
import Rhino.UI
import scriptcontext as sc
import System.Drawing as sd
import Eto.Drawing as drawing
import Eto.Forms as forms

if not sc.doc.Strings.GetValue("Extrusion Label"): sc.doc.Strings.SetString("Extrusion Label", "C")
if not sc.doc.Strings.GetValue("Flange Size"): sc.doc.Strings.SetString("Flange Size", "29/32")
if not sc.doc.Strings.GetValue("Pilot Hole spacing"): sc.doc.Strings.SetString("Pilot Hole spacing", "16")
if not sc.doc.Strings.GetValue("Weep Hole spacing"): sc.doc.Strings.SetString("Weep Hole spacing", "32")

class EdgeConditionDialog(forms.Dialog[bool]):
    def __init__(self):
        exm = sc.doc.Strings.GetValue("Extrusion Label")
        fsz = sc.doc.Strings.GetValue("Flange Size")
        phs = sc.doc.Strings.GetValue("Pilot Hole spacing")
        whs = sc.doc.Strings.GetValue("Weep Hole spacing")
        self.Title = "Edge Condition Properties"
        self.ClientSize = drawing.Size(270, 238)
        self.Padding = drawing.Padding(10)
        self.Resizable = False
        self.exm_label = forms.Label(Text = "Extrusion", ToolTip = "Leave blank to omit extrusion marker")
        cb = forms.ComboBox()
        cb.DataStore = [
            "A", "B", "C", "D", "H", "K", "J", "S", "Q", "800", "26",
            "A6", "B6", "H6", "K6", "W", "B75", "B76",
            "NC", "NH", "Nc", "Na"]
        cb.Text = exm
        cb.Enabled = True
        cb.MouseWheel += self.OnWheel
        self.exm_combobox = cb
        self.fsz_label = forms.Label(Text = "Flange size", ToolTip = "Enter 0 for no flange\nUse space between whole number and fraction")
        self.fsz_textbox = forms.TextBox(Text = fsz)
        self.phs_label = forms.Label(Text = "Pilot Hole spacing", ToolTip = "Enter 0 for no pilot holes,\nEnter negative spacing to omit only corner clip holes")
        self.phs_textbox = forms.TextBox(Text = phs)
        self.whs_label = forms.Label(Text = "Weep Hole spacing", ToolTip = "Enter 0 for no weep holes")
        self.whs_textbox = forms.TextBox(Text = whs)
        self.DefaultButton = forms.Button(Text = "Accept")
        self.DefaultButton.Click += self.OnOKButtonClick
        layout = forms.DynamicLayout()
        layout.Spacing = drawing.Size(10, 10)
        layout.AddRow(self.exm_label, self.exm_combobox)
        layout.AddRow(self.fsz_label, self.fsz_textbox)
        layout.AddRow(self.phs_label, self.phs_textbox)
        layout.AddRow(self.whs_label, self.whs_textbox)
        layout.AddRow(None, self.DefaultButton)
        self.Content = layout
    def OnOKButtonClick(self, sender, e):
        if not self.exm_combobox.Text: self.exm_combobox.Text = "None"
        sc.doc.Strings.SetString("Extrusion Label", str(self.exm_combobox.Text))
        if not self.fsz_textbox.Text: self.fsz_textbox.Text = "0"
        sc.doc.Strings.SetString("Flange Size", self.fsz_textbox.Text)
        if not self.phs_textbox.Text: self.phs_textbox.Text = "0"
        sc.doc.Strings.SetString("Pilot Hole spacing", self.phs_textbox.Text)
        if not self.whs_textbox.Text: self.whs_textbox.Text = "0"
        sc.doc.Strings.SetString("Weep Hole spacing", self.whs_textbox.Text)
    def OnWheel(self, sender, e):
        next = min(len(self.exm_combobox.DataStore) - 1, max(0, self.exm_combobox.SelectedIndex))
        self.exm_combobox.SelectedIndex = next

def LabelFormat(x):
    x.Font = drawing.Font("ISOCPEUR", 16)
    x.TextAlignment = forms.TextAlignment.Right

def TextBoxFormat(x):
    x.Font = drawing.Font("ISOCPEUR", 16)
    x.Width = 1

def main():
    dialog = EdgeConditionDialog()
    rc = dialog.ShowModal(Rhino.UI.RhinoEtoApp.MainWindow)
    if rc:
        dotTx = EdgeConditionDialog().exm_combobox.Text
        try: flangesize = float(EdgeConditionDialog().fsz_textbox.Text)
        except ValueError: flangesize = FracToFloat(EdgeConditionDialog().fsz_textbox.Text)
        PHspacing = int(EdgeConditionDialog().phs_textbox.Text)
        WHspacing = int(EdgeConditionDialog().whs_textbox.Text)
        print "\nGAME OVER"

def FracToFloat(fraction):
    if not fraction: return 0
    num = 0
    mult = 1
    if fraction[:1] == "-":
        fraction = fraction[1:]     
        mult = -1
    if " " in fraction:
        a = fraction.split(" ")
        num = float(a[0])
        toSplit = a[1]
        toSplit = fraction
    frac = toSplit.split("/")
    num += float(frac[0]) / float(frac[1])
    return num * mult

if __name__ == "__main__": main()

On a side note, is there a py script that converts fraction text into int already?

Hi @Asterisk, the size this element gets is the remaining size of the dialog after your label text has been added to the row. To control it, you could set the size of the label to be larger eg:

def LabelFormat(x):
    x.Font = drawing.Font("ISOCPEUR", 16)
    x.TextAlignment = forms.TextAlignment.Right
    x.Size = drawing.Size(165,30)

One note to your main function, you’re creating new instances of the dialog. Is this intended ?

You might take a look here and here


I don’t know how to make that dialog box work any other way. I’ve only started to dabble in python last year and Eto last month. Scavenging this forum for code snippets and trying to work out what does what. I still have no clue what some of Eto code lines do. There’s no primer for Eto like there is for Python. I don’t even know python as well as I need to.

This actually changes nothing output wise. And I’ve tried 30, 240, 100 instead of 165. Height works, width doesn’t…

In just glancing at your dialog and you code I would say that your Button is likely establishing the minimum width of the controls in that DynamicTables column.

1 Like

Dam! That’s right.

1 Like