2021年5月24日 星期一

AEDT簡單的輸入視窗(Windows + Linux)

SimpleInputDialog.py

import clr
clr.AddReference("ANS.UI.Toolkit")
clr.AddReference("ANS.UI.Toolkit.Base")
import Ansys.UI.Toolkit as ui


class mainwindow(ui.Dialog):
def __init__(self):
self.Size = ui.Drawing.Size(400, 200)
self.Text = 'Simple Input Dialog'
self.mainPanel = ui.TableLayoutPanel()
self.mainPanel.Rows.Add(ui.TableLayoutSizeType.Absolute, 30)
self.mainPanel.Rows.Add(ui.TableLayoutSizeType.Absolute, 30)
self.mainPanel.Rows.Add(ui.TableLayoutSizeType.Absolute, 30)
self.mainPanel.Columns.Add(ui.TableLayoutSizeType.Absolute, 10)
self.mainPanel.Columns.Add(ui.TableLayoutSizeType.Absolute, 300)
self.mainPanel.Columns.Add(ui.TableLayoutSizeType.Absolute, 60)

self.SetControl(self.mainPanel)

self.tb = ui.TextBox()
self.mainPanel.Controls.Add(self.tb, 1, 1, 1, 1)

self.bt = ui.Button('Run')

self.bt.Click += ui.EventDelegate(self.click)
self.mainPanel.Controls.Add(self.bt, 1, 2, 1, 1)

def click(self, sender, args):
if self.tb.Text:
AddWarningMessage(self.tb.Text)
else:
AddWarningMessage('No Input!')


gui = mainwindow()
gui.ShowDialog()





沒有留言:

張貼留言