in fact for each project in my job i fill a paper doc, with the owner name, contact , project name, tel… area of surfaces of the project, and a lot of chekbox… so i think eto is a good solution, but it’s really difficult for me, because i descover class, and argument… with “self” that i’m not sure too understand…
yes thank you, but since this morning i’m in this doc…
i try with 2 Textbox and 1 combobox, to get userdocumenttext, modify it in the window, but when i validate i don’t manage to get the new values to set userdocumenttext…
# Imports
import Rhino
import scriptcontext as sc
import Rhino.UI
import Eto.Drawing as drawing
import Eto.Forms as forms
import rhinoscriptsyntax as rs
################################################################################
# Class to hold PROJECT arguments
################################################################################
class ProjArg():
# Initializer
def __init__(self):
self.Client = 'client'
self.Projet = 'projet'
################################################################################
# Project dialog class
################################################################################
class Projforms(forms.Dialog[bool]):
# Initializer
def __init__(self, args):
self.Args = args
# Initialize dialog box
self.Title = 'Remplissage FORMULAIRE PROJET'
self.Padding = drawing.Padding(5)
# Create layout
layout = forms.DynamicLayout()
layout.Padding = drawing.Padding(5)
layout.Spacing = drawing.Size(5, 5)
layout.AddRow(self.CreateClient())
layout.AddRow(None) # spacer
layout.AddRow(self.Prest())
layout.AddRow(None) # spacer
layout.AddRow(self.CreateButtons())
# Set the dialog content
self.Content = layout
#CLIENT & PROJET
def CreateClient(self):
label1 = forms.Label(Text = 'Cient:')
textbox1 = forms.TextBox(SelectedText=self.Args.Client)
label2=forms.Label(Text = 'Projet:')
textbox2= forms.TextBox(SelectedText=self.Args.Projet)
layout = forms.DynamicLayout()
layout.Spacing = drawing.Size(5, 5)
layout.AddRow(label1,textbox1,label2,textbox2)
return layout
def Prest(self):
prest_label='Prestation'
m_combobox = forms.ComboBox()
m_combobox.DataStore = ['2D', '3D', 'Mixte 2D-3D']
layout = forms.DynamicLayout()
layout.Spacing = drawing.Size(5, 5)
layout.AddRow(None,prest_label,m_combobox,None)
return layout
# Create the dialog buttons
def CreateButtons(self):
# Create the validate button
self.ValidateButton=forms.Button(Text = 'Validate!')
self.ValidateButton.Click += self.OnValidateButtonClick
# Create the abort button
self.AbortButton = forms.Button(Text = 'Close')
self.AbortButton.Click += self.OnCloseButtonClick
# Create button layout
button_layout = forms.DynamicLayout()
button_layout.Spacing = drawing.Size(5, 5)
button_layout.AddRow(None, self.ValidateButton, self.AbortButton, None)
return button_layout
# Close button click handler
def OnCloseButtonClick(self, sender, e):
self.Close(False)
#Validate Button click handler
def OnValidateButtonClick(self,sender,e):
self.Close(True)
def ApplyModif(self):
pass
rs.SetDocumentUserText('Client',self.textbox1.Text)
rs.SetDocumentUserText('Projet',self.textbox2.Text)
rs.SetDocumentUserText('Prestation',self.m_combobox.Text)
def TestEtoform():
args = ProjArg()
args.Client = rs.GetDocumentUserText('Client')
args.Projet = rs.GetDocumentUserText('Projet')
dialog = Projforms(args);
rc = dialog.ShowModal(Rhino.UI.RhinoEtoApp.MainWindow)
if rc:
dialog.ApplyModif()
if __name__ == "__main__":
TestEtoform()