Hi Community,
Not very dynamo question but this will be a part of bigger dynamo graph. So anyway im creating a form which will allow user to type in say the right values only.
In the example below if the user forgot to type in the name, error message should pop up, which works great…the problem now is when the user closes the error message it also closes the mainform, what i want to do is close the error message, come back to mainform and try again until you get the right input? Any idea how to do that? See attached code below. Thanks in Advance.
import clr
clr.AddReference("System.Windows.Forms")
clr.AddReference("System.Drawing")
import System
from System.Windows.Forms import *
from System.Drawing import *
import clr, sys
sys.path.append(r"C:\Program Files (x86)\IronPython 2.7\Lib")
import os, System
class MainForm(Form):
def __init__(self):
self.InitializeComponent()
def InitializeComponent(self):
self._label1 = System.Windows.Forms.Label()
self._textBox1 = System.Windows.Forms.TextBox()
self._button1 = System.Windows.Forms.Button()
self.SuspendLayout()
#
# label1
#
self._label1.Location = System.Drawing.Point(12, 41)
self._label1.Name = "label1"
self._label1.Size = System.Drawing.Size(100, 23)
self._label1.TabIndex = 0
self._label1.Text = "Enter your name"
self._label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
#
# textBox1
#
self._textBox1.Location = System.Drawing.Point(120, 41)
self._textBox1.Name = "textBox1"
self._textBox1.Size = System.Drawing.Size(141, 20)
self._textBox1.TabIndex = 1
#
# button1
#
self._button1.DialogResult = System.Windows.Forms.DialogResult.OK
self._button1.Location = System.Drawing.Point(186, 87)
self._button1.Name = "button1"
self._button1.Size = System.Drawing.Size(75, 23)
self._button1.TabIndex = 2
self._button1.Text = "Ok"
self._button1.UseVisualStyleBackColor = True
self._button1.Click += self.TextBox2TextChanged
#
# MainForm
#
self.ClientSize = System.Drawing.Size(284, 140)
self.values = []
self.CenterToScreen()
self.Controls.Add(self._button1)
self.Controls.Add(self._textBox1)
self.Controls.Add(self._label1)
self.MaximizeBox = False
self.MinimizeBox = False
self.Name = "MainForm"
self.ShowIcon = False
self.Text = "Forum"
self.Load += self.MainFormLoad
self.ResumeLayout(False)
self.PerformLayout()
def MainFormLoad(self, sender, e):
pass
def TextBox2TextChanged(self, sender, e):
self.values.append(self._textBox1.Text)
if self._textBox1.Text == '':
MessageBox.Show('Invalid Input, Please Enter your name','Error Message')
self.Close()
if IN[0]:
form = MainForm()
Application.Run(form)
OUT = form.values