HI ALL
HI @c.poupin
Referring to the code you wrote in
AND
I AM ADDING TIMRE
self.timer1 = System.Windows.Forms.Timer()
I tried to draw an arc ( Graphics .DrawArc) within the event timer1_Tick
I didn’t succeed
Can you take a look?
Thanks in advance
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('System.Drawing')
clr.AddReference('System.Windows.Forms')
import System.Drawing
import System.Windows.Forms
from System.Drawing import *
from System.Windows.Forms import *
from System.Drawing import Point, Image, Bitmap, Size , Graphics
from System.Windows.Forms import Application, Button, Form, Label, TextBox , DataGridView , DataGridViewCellCollection , ListView , ListBox , MessageBox
from System.Drawing.Drawing2D import LinearGradientBrush
#from System.Drawing.Graphics import Graphics
class MainForm(Form):
def __init__(self):
self.InitializeComponent()
self.output = []
def InitializeComponent(self):
self._button1 = System.Windows.Forms.Button()
self._textBox1 = System.Windows.Forms.TextBox()
self._label1 = System.Windows.Forms.Label()
self.timer1 = System.Windows.Forms.Timer()
self.SuspendLayout()
#
# button1
#
self._button1.Location = System.Drawing.Point(98, 148)
self._button1.Name = "button1"
self._button1.Size = System.Drawing.Size(94, 37)
self._button1.TabIndex = 0
self._button1.Text = "My Button"
self._button1.UseVisualStyleBackColor = True
self._button1.Click += self.Button1Click
#
#################################################################################
self.timer1.Interval = 15
self.timer1.Enabled = True
self.timer1.Start()
self.timer1.Tick += self.timer1_Tick
# textBox1
#
self._textBox1.Location = System.Drawing.Point(61, 102)
self._textBox1.Name = "textBox1"
self._textBox1.Size = System.Drawing.Size(167, 20)
self._textBox1.TabIndex = 1
#
# label1
#
self._label1.Location = System.Drawing.Point(61, 73)
self._label1.Name = "label1"
self._label1.Size = System.Drawing.Size(167, 23)
self._label1.TabIndex = 2
self._label1.Text = "Enter a text"
#
# Form1
#
self.ClientSize = System.Drawing.Size(284, 261)
self.Controls.Add(self._label1)
self.Controls.Add(self._textBox1)
self.Controls.Add(self._button1)
self.Name = "Form1"
self.Text = "MainForm"
self.ResumeLayout(False)
self.PerformLayout()
def Button1Click(self, sender, e):
try:
newMDIChild = ChildForm(self)
newMDIChild.StartPosition = FormStartPosition.CenterParent
newMDIChild.ShowDialog(self)
except Exception as ex:
print(ex)
def timer1_Tick(self, sender, e):
#grq = 10
g = e.Graphics
pen = Pen(Color.Gray, 1)
g.DrawArc(pen, 20, 40, 33 , 33, 0, 360)
class ChildForm(Form):
def __init__(self, parent):
self._parent = parent
self.InitializeComponent()
def InitializeComponent(self):
self._label1 = System.Windows.Forms.Label()
self.SuspendLayout()
#
# label1
#
self._label1.Location = System.Drawing.Point(47, 41)
self._label1.Name = "label1"
self._label1.Size = System.Drawing.Size(178, 37)
self._label1.TabIndex = 0
self._label1.Text = "the enter text is '{}'".format(self._parent._textBox1.Text)
self._label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
#self.components = System.ComponentModel.Container()
#
# Form14
#
self.ClientSize = System.Drawing.Size(284, 128)
self.Controls.Add(self._label1)
self.Name = "ChildForm"
self.Text = "ChildForm"
self.ResumeLayout(False)
self.PerformLayout()
form = MainForm()
Application.Run(form)
OUT = form.output