Create form:class CreateWindow(Form)

Create form:

import clr

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

import System

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

# Create a Class Form
class CreateWindow(Form):
    def __init__(self): 
    
        # Create the Form
        self.Name = "Create Window"
        self.Text = "Create Window"
        self.Size = Size(500, 150)        
        self.CenterToScreen()

        self.values = []

        # Create Label for Sheet Name
        labelSheetName = Label(Text = "Sheet Name")
        labelSheetName.Parent = self
        labelSheetName.Location = Point(30, 20)

        # Create Label for Sheet Number
        labelSheetNumber = Label(Text = "Sheet Number")
        labelSheetNumber.Parent = self
        labelSheetNumber.Location = Point(30, 50)
        

        # Create TextBox for Sheet Name
        self.textboxSheetName = TextBox()
        self.textboxSheetName.Parent = self
        self.textboxSheetName.Text = "Sheet Name"
        self.textboxSheetName.Location = Point(150, 20)
        self.textboxSheetName.Width = 150
        
        # Create TextBox for Sheet Number
        self.textboxSheetNumber = TextBox()
        self.textboxSheetNumber.Parent = self
        self.textboxSheetNumber.Text = "Sheet Number"
        self.textboxSheetNumber.Location = Point(150, 50)
        self.textboxSheetNumber.Width = 150

        # Create Button = button
        button = Button()
        button.Parent = self
        button.Text = "Ok"
        button.Location = Point(400, 60)
        # Register event
        button.Click += self.ButtonClicked
        
    # Create button event
    def ButtonClicked(self, sender, args):
        if sender.Click:
            self.values.append(self.textboxSheetName.Text)
            self.values.append(self.textboxSheetNumber.Text)
            self.Close()            

if IN[0]:
    form = CreateWindow()
    Application.Run(form)
    
    OUT = form.values

Create form:class CreateWindow(Form)_第1张图片

Create form:class CreateWindow(Form)_第2张图片

 

sharpdev:

import System.Drawing
import System.Windows.Forms

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

class MainForm(Form):
    def __init__(self):
        self.InitializeComponent()
    def ButtonClicked(self, sender, e):
        self._excel = System.Windows.Forms.OpenFileDialog()
        # excel
        self._excel.FileName = "excel"
        self._excel.InitialDirectory = "E:\\a"
        self._excel.Title = "选择工程量清单excel"
        fileName = self._excel.FileName
        self._excel.ShowDialog()
        
        self._excel.FileOk += self.ExcelFileOk
    def InitializeComponent(self):
        self._button1 = System.Windows.Forms.Button()
        self._label1 = System.Windows.Forms.Label()
        self._选择清单 = System.Windows.Forms.TextBox()
        self.SuspendLayout()
        # 
        # button1
        # 
        self._button1.Location = System.Drawing.Point(354, 130)
        self._button1.Name = "button1"
        self._button1.Size = System.Drawing.Size(75, 23)
        self._button1.TabIndex = 0
        self._button1.Text = "选择文件"
        self._button1.UseVisualStyleBackColor = True
        self._button1.Click += self.ButtonClicked
        # 
        # label1
        # 
        self._label1.Location = System.Drawing.Point(12, 47)
        self._label1.Name = "label1"
        self._label1.Size = System.Drawing.Size(100, 23)
        self._label1.TabIndex = 1
        self._label1.Text = "nice"
        # 
        # 选择清单
        # 
        self._选择清单.Location = System.Drawing.Point(322, 48)
        self._选择清单.Name = "选择清单"
        self._选择清单.Size = System.Drawing.Size(100, 21)
        self._选择清单.TabIndex = 2
        self._选择清单.Text = "清单"
        self._选择清单.TextAlign = System.Windows.Forms.HorizontalAlignment.Right
        # 
        # MainForm
        # 
        self.ClientSize = System.Drawing.Size(463, 184)
        self.Controls.Add(self._选择清单)
        self.Controls.Add(self._label1)
        self.Controls.Add(self._button1)
        self.Name = "MainForm"
        self.Text = "abc"
        self.ResumeLayout(False)
        self.PerformLayout()

Create form:class CreateWindow(Form)_第3张图片

 

转载于:https://www.cnblogs.com/ShirleyX/p/8023738.html

你可能感兴趣的:(Create form:class CreateWindow(Form))