Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 4171

Userform in Rhino 6 Opens Half the Size

$
0
0

@eric.bunn wrote:

Hi,

I have a user on Rhino 6 that is having problems with how a userform is displayed on their machine. I sent them a simple test userform to try and troubleshoot this and the userform opens up about half the size and all of the controls get crammed together. They also have a version of Rhino 5 and it opens fine on the same machine. I can open it on my machine in 5 or 6 with no problem. Anyone seen this before and any and all suggestions are appreciated.

I’ve posted the code below. This came from SharpDevelop with some modifications.

Eric

805f145a-7057-410e-9ac0-fba6910ac435 UF V 5

import System.Drawing
import System.Windows.Forms

from System.Drawing import *
from System.Windows.Forms import *

mbl = 30

class MainForm(Form):
def init(self):
self.InitializeComponent()

def InitializeComponent(self):
	self._numericUpDown1 = System.Windows.Forms.NumericUpDown()
	self._groupBox1 = System.Windows.Forms.GroupBox()
	self._label1 = System.Windows.Forms.Label()
	self._lblTitle = System.Windows.Forms.Label()
	self._checkBox1 = System.Windows.Forms.CheckBox()
	self._checkBox2 = System.Windows.Forms.CheckBox()
	self._numericUpDown2 = System.Windows.Forms.NumericUpDown()
	self._numericUpDown1.BeginInit()
	self._groupBox1.SuspendLayout()
	self._numericUpDown2.BeginInit()
	self.SuspendLayout()
	# 
	# numericUpDown1
	# 
	self._numericUpDown1.DecimalPlaces = 3
	self._numericUpDown1.Increment = System.Decimal(System.Array[System.Int32](
		[5,
		0,
		0,
		65536]))
	self._numericUpDown1.Location = System.Drawing.Point(132, 19)
	self._numericUpDown1.Name = "numericUpDown1"
	self._numericUpDown1.Size = System.Drawing.Size(120, 20)
	self._numericUpDown1.TabIndex = 0
	self._numericUpDown1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
	self._numericUpDown1.Value = System.Decimal(System.Array[System.Int32](
		[24,
		0,
		0,
		0]))
	self._numericUpDown1.ValueChanged += self.NumericUpDown1ValueChanged
	# 
	# numericUpDown2
	# 
	self._numericUpDown2.Location = System.Drawing.Point(133, 42)
	self._numericUpDown2.Name = "numericUpDown2"
	self._numericUpDown2.Size = System.Drawing.Size(139, 20)
	self._numericUpDown2.TabIndex = 4
	self._numericUpDown2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
	self._numericUpDown2.Value = System.Decimal(System.Array[System.Int32](
		[24,
		0,
		0,
		0]))
	self._numericUpDown2.ValueChanged += self.NumericUpDown2ValueChanged
	# 
	# groupBox1
	# 
	self._groupBox1.Controls.Add(self._checkBox2)
	self._groupBox1.Controls.Add(self._label1)
	self._groupBox1.Controls.Add(self._numericUpDown1)
	self._groupBox1.Location = System.Drawing.Point(13, 97)
	self._groupBox1.Name = "groupBox1"
	self._groupBox1.Size = System.Drawing.Size(259, 96)
	self._groupBox1.TabIndex = 1
	self._groupBox1.TabStop = False
	self._groupBox1.Text = "groupBox1"
	# 
	# label1
	# 
	self._label1.Location = System.Drawing.Point(17, 20)
	self._label1.Name = "label1"
	self._label1.Size = System.Drawing.Size(109, 19)
	self._label1.TabIndex = 1
	self._label1.Text = "Update MB L"
	self._label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight
	# 
	# lblTitle
	# 
	self._lblTitle.Location = System.Drawing.Point(13, 9)
	self._lblTitle.Name = "lblTitle"
	self._lblTitle.Size = System.Drawing.Size(126, 23)
	self._lblTitle.TabIndex = 2
	self._lblTitle.Text = "Test Form"
	self._lblTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
	# 
	# checkBox1
	# 
	self._checkBox1.Checked = True
	self._checkBox1.CheckState = System.Windows.Forms.CheckState.Checked
	self._checkBox1.Location = System.Drawing.Point(133, 12)
	self._checkBox1.Name = "checkBox1"
	self._checkBox1.Size = System.Drawing.Size(139, 24)
	self._checkBox1.TabIndex = 3
	self._checkBox1.Text = "checkBox1"
	self._checkBox1.UseVisualStyleBackColor = True
	# 
	# checkBox2
	# 
	self._checkBox2.Checked = True
	self._checkBox2.CheckState = System.Windows.Forms.CheckState.Checked
	self._checkBox2.Location = System.Drawing.Point(132, 45)
	self._checkBox2.Name = "checkBox2"
	self._checkBox2.Size = System.Drawing.Size(120, 24)
	self._checkBox2.TabIndex = 4
	self._checkBox2.Text = "checkBox2"
	self._checkBox2.UseVisualStyleBackColor = True
	# 
	# MainForm
	# 
	self.ClientSize = System.Drawing.Size(284, 205)
	self.Controls.Add(self._numericUpDown2)
	self.Controls.Add(self._checkBox1)
	self.Controls.Add(self._lblTitle)
	self.Controls.Add(self._groupBox1)
	self.Name = "MainForm"
	self.Text = "Test"
	self._numericUpDown1.EndInit()
	self._groupBox1.ResumeLayout(False)
	self._numericUpDown2.EndInit()
	self.ResumeLayout(False)
	
	
#THIS ROUTINE WILL FIND A CONTROL AND UPDATE IT WITH MACRO DEFINED DATA
def UpdateUI(self,cName,cVal):
    for i in self.Controls:
        #Get Type
        fType = type(i)
        #Find Control on Main Form
        #Labels
        if i.Name == cName and fType == Label:
            i.Text = cVal
        #Checkboxes
        if i.Name == cName and fType == CheckBox:
            i.Checked = cVal
        # Numeric UpDown
        if i.Name == cName and fType == NumericUpDown:
            i.Value = cVal
            
        #Find Control in Group Box
        if fType == GroupBox:
            for j in i.Controls:
                #Get Type
                gType = type(j)
                # Numeric UpDown
                if j.Name == cName and gType == NumericUpDown:
                    j.Value = cVal	
                #Labels
                if j.Name == cName and gType == Label:
                    j.Text = cVal	
                #Checkboxes
                if j.Name == cName and gType == CheckBox:
                    j.Checked = cVal


def NumericUpDown1ValueChanged(self, sender, e):
	self._numericUpDown1 = sender.Value
	self.UpdateUI("numericUpDown1",mbl)
	self.UpdateUI("lblTitle","Changed1")
	self.UpdateUI("label1","Changed2")
	self.UpdateUI("checkBox1",False)
	self.UpdateUI("checkBox2",False)

def NumericUpDown2ValueChanged(self, sender, e):
	self._numericUpDown1 = sender.Value
	self.UpdateUI("numericUpDown2",mbl)

def DoSomething():
form = MainForm()
if form.ShowDialog() == System.Windows.Forms.DialogResult.OK:
print(form._numericUpDown1)
else:
print(“Canceled”)

if name==“main”:
DoSomething()

Posts: 7

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4171

Latest Images

Trending Articles



Latest Images