Interface create hyperlink and change defaut settings, how?

Hello Dynos,

I did some copy/paste stuff. I want to create a windo with hyperlinks. Later on to create some layout stuff, but step by step:
1.) how can i change the default height/length
2.) how can i create a hyperlink
is there something like self.Hyperlink.Text?
3.) how can say button.click = close.window


import sys
sys.path.append(r'C:\Python24\Lib')

import clr
clr.AddReference("System.Drawing")
clr.AddReference("System.Windows.Forms")

from System.Drawing import Point
from System.Windows.Forms import Application, Button, Form, Label

class Intro(Form):

def __init__(self):
    self.Text = 'Visuelles Programmieren bei XXX'

    self.label = Label()
    self.label.Text = "https://forum.dynamobim.com/"
    self.label.Location = Point(50, 50)
    self.label.Height = 30
    self.label.Width = 1200

    self.count = 0

    button = Button()
    button.Text = "OK"
    button.Location = Point(50, 100)

    button.Click += self.buttonPressed

    self.Controls.Add(self.label)
    self.Controls.Add(button)

def buttonPressed(self, sender, args):
    print 'The label *used to say* : %s' % self.label.Text
    self.count += 1
    self.label.Text = "You have clicked me %s times." % self.count


form = Intro()
Application.Run(form)

(the def buttonPressed is from the tutorial. - it is useless, but when i delete i got an error)

I am glad about any info

KR

Andreas

Hello

to change the default height/length use ClientSize Property
to create a hyperlink use a LinkLabel

import clr
import System
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 *

class Intro(Form):
    def __init__(self):
        self._linkLabel1 = System.Windows.Forms.LinkLabel()
        # 
        # linkLabel1
        # 
        self._linkLabel1.Location = System.Drawing.Point(40, 44)
        self._linkLabel1.Name = "linkLabel1"
        self._linkLabel1.Size = System.Drawing.Size(217, 23)
        self._linkLabel1.TabIndex = 0
        self._linkLabel1.TabStop = True
        self._linkLabel1.Text = "https://forum.dynamobim.com/"
        self._linkLabel1.LinkClicked += self.LinkLabel1LinkClicked
        # 
        # Form1
        # 
        self.ClientSize = System.Drawing.Size(284, 114)
        self.Controls.Add(self._linkLabel1)
        self.Name = "Form1"
        self.Text = "Form1"

    def LinkLabel1LinkClicked(self, sender, e):
        System.Diagnostics.Process.Start(sender.Text)
        
form = Intro()
Application.Run(form)
1 Like


Thabk you very much, i already modified some stuff.
But how can i understand that, when i Close the window and rerun the script. The script does not open anymore. So i can do it just one times?

You can :

  • close, re-open script and run
  • use Dynamo Player
  • add a node to refresh script (like Boolean node)

image

2 Likes