예제 #1
0
 def __init__(self):
     SWF.Form.__init__(self)
     self._people = people = []
     for name, age, ignored in SAMPLE_DATA:
         people.append(Person(name, age))
     grid = SWF.DataGridView()
     grid.AutoGenerateColumns = False
     grid.Columns.Add('Name', 'Name')
     grid.Columns[0].DataPropertyName = 'Name'
     grid.Columns.Add('Age', 'Age')
     grid.Columns[1].DataPropertyName = 'Age'
     grid.Columns.Add('AgeDescription', 'AgeDescription')
     grid.Columns[2].DataPropertyName = 'AgeDescription'
     grid.DataSource = people
     grid.Dock = SWF.DockStyle.Fill
     self.grid = grid
     self.Controls.Add(grid)
예제 #2
0
 def test_cp17072(self):
     import System.Windows.Forms as SWF
     tb_class_dir = dir(SWF.TextBox)
     tb_instance_dir = dir(SWF.TextBox())
     for x in [  #Protected??? "AccessibilityNotifyClients", #overloaded
             "BeginInvoke",  #overloaded
             "AppendText",  #inherited
             "BringToFront",  #inherited
             "CreateObjRef",  #inherited
             "AcceptsReturn",  #property
             "AutoSizeChanged",  #inherited
             "OnDragEnter",  #explicit interface implementation
             "__reduce_ex__",  #arbitrary Python method
     ]:
         self.assertTrue(x in tb_class_dir,
                         "%s not in dir(SWF.TextBox)" % x)
         self.assertTrue(x in tb_instance_dir,
                         "%s not in dir(SWF.TextBox())" % x)
예제 #3
0
        def __init__(self, title, url, width, height, resizable, fullscreen,
                     min_size, confirm_quit, webview_ready):
            self.Text = title
            self.ClientSize = Size(width, height)
            self.MinimumSize = Size(min_size[0], min_size[1])

            if not resizable:
                self.FormBorderStyle = WinForms.FormBorderStyle.FixedSingle
                self.MaximizeBox = False

            # Application icon
            handle = windll.kernel32.GetModuleHandleW(None)
            icon_handle = windll.shell32.ExtractIconW(handle, sys.executable,
                                                      0)

            if icon_handle != 0:
                self.Icon = Icon.FromHandle(
                    IntPtr.op_Explicit(Int32(icon_handle))).Clone()

            windll.user32.DestroyIcon(icon_handle)

            self.webview_ready = webview_ready

            self.web_browser = WinForms.WebBrowser()
            self.web_browser.Dock = WinForms.DockStyle.Fill
            self.web_browser.ScriptErrorsSuppressed = True
            self.web_browser.IsWebBrowserContextMenuEnabled = False

            self.cancel_back = False
            self.web_browser.PreviewKeyDown += self.on_preview_keydown
            self.web_browser.Navigating += self.on_navigating

            if url:
                self.web_browser.Navigate(url)

            self.Controls.Add(self.web_browser)
            self.is_fullscreen = False
            self.Shown += self.on_shown

            if confirm_quit:
                self.FormClosing += self.on_closing

            if fullscreen:
                self.toggle_fullscreen()
    def reFresh(self):
        self.listView1.Items.Clear()
        updatePadInfo()

        padInfo.sort(key=lambda tup: tup[self.sortIndex],
                     reverse=self.ascending)

        for terminal, comp, pin, net, status in padInfo:
            if terminal == 'Source':
                color = Drawing.Color.OrangeRed
            elif terminal == 'Sink':
                color = Drawing.Color.SeaGreen
            else:
                color = Drawing.Color.DodgerBlue

            listViewItem1 = Forms.ListViewItem(
                Array[string]([terminal, comp, pin, net, status]), -1, color,
                Drawing.Color.Empty, None)
            self.listView1.Items.Add(listViewItem1)
예제 #5
0
        def __init__(self, title, url, width, height, resizable, fullscreen,
                     min_size, webview_ready):
            self.Text = title
            self.AutoScaleBaseSize = Size(5, 13)
            self.ClientSize = Size(width, height)
            self.MinimumSize = Size(min_size[0], min_size[1])

            self.webview_ready = webview_ready

            self.web_browser = WinForms.WebBrowser()
            self.web_browser.Dock = WinForms.DockStyle.Fill

            if url:
                self.web_browser.Navigate(url)

            self.Controls.Add(self.web_browser)
            self.is_fullscreen = False
            self.Shown += self.on_shown

            if fullscreen:
                self.toggle_fullscreen()
예제 #6
0
    def __init__(self,
                 url: str,
                 title: str = "pycefsharp",
                 icon: str = None,
                 geometry: list = [-1, -1, -1, -1]):
        self.__cef_form = WinForms.Form()
        self.__cef_form.StartPosition = WinForms.FormStartPosition.CenterScreen

        self.__cef_browser = None

        self.url = url
        self.title = title
        self.icon = os.path.join(__path__[0],
                                 "cef.ico") if icon == None else icon
        self.geometry = geometry

        self.__cef_form.Load += self.__on_load
        self.__cef_form.Shown += self.__on_show
        self.__cef_form.FormClosed += self.__on_close

        self.__cef_form.Visible = False
예제 #7
0
        def __init__(self, title, url, width, height, resizable, fullscreen,
                     min_size, confirm_quit, webview_ready):
            self.Text = title
            self.ClientSize = Size(width, height)
            self.MinimumSize = Size(min_size[0], min_size[1])
            self.AutoScaleDimensions = SizeF(96.0, 96.0)
            self.AutoScaleMode = WinForms.AutoScaleMode.Dpi

            if not resizable:
                self.FormBorderStyle = WinForms.FormBorderStyle.FixedSingle
                self.MaximizeBox = False

            # Application icon
            try:  # Try loading an icon embedded in the exe file. This will crash when frozen with PyInstaller
                handler = windll.kernel32.GetModuleHandleW(None)
                icon_handler = windll.user32.LoadIconW(handler, 1)
                self.Icon = Icon.FromHandle(
                    IntPtr.op_Explicit(Int32(icon_handler)))
            except:
                pass

            self.webview_ready = webview_ready

            self.web_browser = WinForms.WebBrowser()
            self.web_browser.Dock = WinForms.DockStyle.Fill
            self.web_browser.ScriptErrorsSuppressed = True
            self.web_browser.IsWebBrowserContextMenuEnabled = False

            if url:
                self.web_browser.Navigate(url)

            self.Controls.Add(self.web_browser)
            self.is_fullscreen = False
            self.Shown += self.on_shown

            if confirm_quit:
                self.FormClosing += self.on_closing

            if fullscreen:
                self.toggle_fullscreen()
예제 #8
0
def test_builtintypes():
    import clr
    clr.AddReferenceByPartialName('System.Windows.Forms')
    import System.Windows.Forms as WinForms
    a = WinForms.Button(Text='abc')
    Assert(a.Text, 'abc')
    def __init__(self):
        self.label1 = Forms.Label()
        self.label2 = Forms.Label()
        self.listBox_selection = Forms.ListBox()
        self.comboBox_layer = Forms.ComboBox()
        self.textBox_net = Forms.TextBox()
        self.label3 = Forms.Label()
        self.textBox_linewidth = Forms.TextBox()
        self.button_change = Forms.Button()
        self.label4 = Forms.Label()
        self.SuspendLayout()
        # label1
        self.label1.AutoSize = True
        self.label1.Location = Drawing.Point(13, 10)
        self.label1.Name = "label1"
        self.label1.Size = Drawing.Size(50, 19)
        self.label1.TabIndex = 0
        self.label1.Text = "Layer:"
        # label2
        self.label2.AutoSize = True
        self.label2.Location = Drawing.Point(13, 72)
        self.label2.Name = "label2"
        self.label2.Size = Drawing.Size(103, 19)
        self.label2.TabIndex = 1
        self.label2.Text = "Net Keyword:"
        self.label2.Click += self.label2_Click

        # listBox_selection
        self.listBox_selection.FormattingEnabled = True
        self.listBox_selection.ItemHeight = 19
        self.listBox_selection.Location = Drawing.Point(174, 32)
        self.listBox_selection.Name = "listBox_selection"
        self.listBox_selection.SelectionMode = Forms.SelectionMode.MultiExtended
        self.listBox_selection.Size = Drawing.Size(225, 308)
        self.listBox_selection.TabIndex = 2
        self.listBox_selection.SelectedIndexChanged += self.listBox_selection_SelectedIndexChanged

        # comboBox_layer
        self.comboBox_layer.FormattingEnabled = True
        self.comboBox_layer.Location = Drawing.Point(13, 32)
        self.comboBox_layer.Name = "comboBox_layer"
        self.comboBox_layer.Size = Drawing.Size(151, 27)
        self.comboBox_layer.TabIndex = 3
        self.comboBox_layer.SelectedIndexChanged += self.comboBox_layer_SelectedIndexChanged

        # textBox_net
        self.textBox_net.Location = Drawing.Point(13, 94)
        self.textBox_net.Name = "textBox_net"
        self.textBox_net.Size = Drawing.Size(151, 27)
        self.textBox_net.TabIndex = 4
        self.textBox_net.Text = ".*"
        self.textBox_net.TextChanged += self.textBox_net_TextChanged

        # label3
        self.label3.AutoSize = True
        self.label3.Location = Drawing.Point(13, 207)
        self.label3.Name = "label3"
        self.label3.Size = Drawing.Size(88, 19)
        self.label3.TabIndex = 5
        self.label3.Text = "Line Width:"
        # textBox_linewidth
        self.textBox_linewidth.Location = Drawing.Point(13, 229)
        self.textBox_linewidth.Name = "textBox_linewidth"
        self.textBox_linewidth.Size = Drawing.Size(151, 27)
        self.textBox_linewidth.TabIndex = 6
        # button_change
        self.button_change.Font = Drawing.Font("Microsoft JhengHei UI", 12, Drawing.FontStyle.Bold, Drawing.GraphicsUnit.Point)
        self.button_change.Location = Drawing.Point(13, 278)
        self.button_change.Name = "button_change"
        self.button_change.Size = Drawing.Size(151, 62)
        self.button_change.TabIndex = 7
        self.button_change.Text = "CHANGE"
        self.button_change.UseVisualStyleBackColor = True
        self.button_change.Click += self.button_change_Click

        # label4
        self.label4.AutoSize = True
        self.label4.Location = Drawing.Point(174, 10)
        self.label4.Name = "label4"
        self.label4.Size = Drawing.Size(104, 19)
        self.label4.TabIndex = 8
        self.label4.Text = "Net Selection:"
        # Form1
        self.AutoScaleDimensions = Drawing.SizeF(9, 19)
        self.AutoScaleMode = Forms.AutoScaleMode.Font
        self.ClientSize = Drawing.Size(412, 353)
        self.Controls.Add(self.label4)
        self.Controls.Add(self.button_change)
        self.Controls.Add(self.textBox_linewidth)
        self.Controls.Add(self.label3)
        self.Controls.Add(self.textBox_net)
        self.Controls.Add(self.comboBox_layer)
        self.Controls.Add(self.listBox_selection)
        self.Controls.Add(self.label2)
        self.Controls.Add(self.label1)
        self.FormBorderStyle = Forms.FormBorderStyle.FixedSingle
        self.MaximizeBox = False
        self.MinimizeBox = False
        self.MinimumSize = Drawing.Size(400, 400)
        self.Name = "Form1"
        self.Padding = Forms.Padding(10)
        self.SizeGripStyle = Forms.SizeGripStyle.Show
        self.StartPosition = Forms.FormStartPosition.CenterScreen
        self.Text = "Line Width Editor"
        self.TopMost = True
        self.Load += self.Form1_Load

        self.ResumeLayout(False)
        self.PerformLayout()
예제 #10
0
    def InitializeComponent(self):
        '''Windows Form Designer generated code'''
        self.lblServerName = SysForms.Label()
        self.lblServerNameComment = SysForms.Label()
        self.txtServerName = SysForms.TextBox()
        self.btnDisconnect = SysForms.Button()
        self.btnConnect = SysForms.Button()
        self.lblCommandString = SysForms.Label()
        self.txtCommand = SysForms.TextBox()
        self.btnSendCommand = SysForms.Button()
        self.lblCommandReply = SysForms.Label()
        self.lblCommandReplyValue = SysForms.Label()
        self.SuspendLayout()
		# 
		# lblServerName
		#
        self.lblServerName.Location = SysDrawing.Point(16, 8)
        self.lblServerName.Name = "lblServerName"
        self.lblServerName.Size = SysDrawing.Size(72, 16)
        self.lblServerName.TabIndex = 24
        self.lblServerName.Text = "Server Name"
        # 
        # lblServerNameComment
        # 
        self.lblServerNameComment.Location = SysDrawing.Point(136, 32)
        self.lblServerNameComment.Name = "lblServerNameComment"
        self.lblServerNameComment.Size = SysDrawing.Size(208, 16)
        self.lblServerNameComment.TabIndex = 28
        self.lblServerNameComment.Text = "(User may enter pc name or IP address)"
        # 
        # txtServerName
        # 
        self.txtServerName.Location = SysDrawing.Point(96, 8)
        self.txtServerName.Name = "txtServerName"
        self.txtServerName.Size = SysDrawing.Size(280, 20)
        self.txtServerName.TabIndex = 27
        self.txtServerName.Text = ""
        # 
        # btnDisconnect
        # 
        self.btnDisconnect.Location = SysDrawing.Point(464, 8)
        self.btnDisconnect.Name = "btnDisconnect"
        self.btnDisconnect.TabIndex = 26
        self.btnDisconnect.Text = "Disconnect"
        self.btnDisconnect.Click += System.EventHandler(self.btnDisconnect_Click)
        # 
        # btnConnect
        # 
        self.btnConnect.Location = SysDrawing.Point(384, 8)
        self.btnConnect.Name = "btnConnect"
        self.btnConnect.TabIndex = 25
        self.btnConnect.Text = "Connect"
        self.btnConnect.Click += System.EventHandler(self.btnConnect_Click)
		# 
		# lblCommandString
		#
        self.lblCommandString.Location = SysDrawing.Point(16, 80)
        self.lblCommandString.Name = "lblCommandName"
        self.lblCommandString.Size = SysDrawing.Size(90, 16)
        self.lblCommandString.TabIndex = 29
        self.lblCommandString.Text = "Command String"
        # 
        # txtCommand
        # 
        self.txtCommand.Location = SysDrawing.Point(110, 80)
        self.txtCommand.Name = "txtCommand"
        self.txtCommand.Size = SysDrawing.Size(280, 20)
        self.txtCommand.TabIndex = 30
        self.txtCommand.Text = "-PostEvent \"Test Event\" 0 0"
        # 
        # btnSendCommand
        # 
        self.btnSendCommand.Location = SysDrawing.Point(400, 80)
        self.btnSendCommand.Name = "btnSendCommand"
        self.btnSendCommand.TabIndex = 31
        self.btnSendCommand.Size = SysDrawing.Size(100, 20)
        self.btnSendCommand.Text = "Send Command"
        self.btnSendCommand.Click += System.EventHandler(self.btnSendCommand_Click)
		# 
		# lblCommandReply
		#
        self.lblCommandReply.Location = SysDrawing.Point(16, 120)
        self.lblCommandReply.Name = "lblCommandReply"
        self.lblCommandReply.Size = SysDrawing.Size(100, 16)
        self.lblCommandReply.TabIndex = 32
        self.lblCommandReply.Text = "Command Reply: "
		# 
		# lblCommandReplyValue
		#
        self.lblCommandReplyValue.Location = SysDrawing.Point(118, 120)
        self.lblCommandReplyValue.Name = "lblCommandReplyValue"
        self.lblCommandReplyValue.Size = SysDrawing.Size(300, 16)
        self.lblCommandReplyValue.TabIndex = 33
        self.lblCommandReplyValue.Text = ""
        # 
        # NetComExampleCommandsForm
        # 
        self.AutoScaleBaseSize = SysDrawing.Size(5, 13)
        self.ClientSize = SysDrawing.Size(552, 150)
        self.Controls.Add(self.lblServerName)
        self.Controls.Add(self.lblServerNameComment)
        self.Controls.Add(self.txtServerName)
        self.Controls.Add(self.btnDisconnect)
        self.Controls.Add(self.btnConnect)
        self.Controls.Add(self.lblCommandString)
        self.Controls.Add(self.txtCommand)
        self.Controls.Add(self.btnSendCommand)
        self.Controls.Add(self.lblCommandReply)
        self.Controls.Add(self.lblCommandReplyValue)
        self.FormBorderStyle = SysForms.FormBorderStyle.FixedDialog
        self.Name = "NetComExampleCommandsForm"
        self.Text = "NetCom Example - Commands"
        self.ResumeLayout(False)
예제 #11
0
 def __init__(self, links):
     self.tableLayoutOverall = swf.TableLayoutPanel()
     self.labelLink = swf.Label()
     self.comboBoxLink = swf.ComboBox()
     self.flowLayoutPanelButtons = swf.FlowLayoutPanel()
     self.buttonSelect = swf.Button()
     self.buttonCancel = swf.Button()
     self.tableLayoutOverall.SuspendLayout()
     self.flowLayoutPanelButtons.SuspendLayout()
     self.SuspendLayout()
     # labelLink
     self.labelLink.Anchor = swf.AnchorStyles.Right
     self.labelLink.AutoSize = True
     self.labelLink.Location = sd.Point(25, 18)
     self.labelLink.Name = "labelLink"
     self.labelLink.Size = sd.Size(27, 13)
     self.labelLink.TabIndex = 0
     self.labelLink.Text = "Link"
     # comboBoxLink
     self.comboBoxLink.Anchor = swf.AnchorStyles.Left | swf.AnchorStyles.Right
     self.comboBoxLink.FormattingEnabled = True
     self.comboBoxLink.Location = sd.Point(58, 14)
     self.comboBoxLink.Name = "comboBoxLink"
     self.comboBoxLink.Size = sd.Size(258, 21)
     self.comboBoxLink.TabIndex = 1
     # buttonSelect
     self.buttonSelect.DialogResult = swf.DialogResult.OK
     self.buttonSelect.Location = sd.Point(149, 3)
     self.buttonSelect.Name = "buttonSelect"
     self.buttonSelect.Size = sd.Size(75, 23)
     self.buttonSelect.TabIndex = 0
     self.buttonSelect.Text = "Select"
     self.buttonSelect.UseVisualStyleBackColor = True
     # buttonCancel
     self.buttonCancel.Anchor = swf.AnchorStyles.None
     self.buttonCancel.DialogResult = swf.DialogResult.Cancel
     self.buttonCancel.Location = sd.Point(230, 3)
     self.buttonCancel.Name = "buttonCancel"
     self.buttonCancel.Size = sd.Size(75, 23)
     self.buttonCancel.TabIndex = 1
     self.buttonCancel.Text = "Cancel"
     self.buttonCancel.UseVisualStyleBackColor = True
     # flowLayoutPanelButtons
     self.flowLayoutPanelButtons.BackColor = sd.SystemColors.Control
     self.tableLayoutOverall.SetColumnSpan(self.flowLayoutPanelButtons, 2)
     self.flowLayoutPanelButtons.Controls.Add(self.buttonCancel)
     self.flowLayoutPanelButtons.Controls.Add(self.buttonSelect)
     self.flowLayoutPanelButtons.Dock = swf.DockStyle.Fill
     self.flowLayoutPanelButtons.FlowDirection = swf.FlowDirection.RightToLeft
     self.flowLayoutPanelButtons.Location = sd.Point(8, 48)
     self.flowLayoutPanelButtons.Name = "flowLayoutPanelButtons"
     self.flowLayoutPanelButtons.Size = sd.Size(308, 35)
     self.flowLayoutPanelButtons.TabIndex = 2
     # tableLayoutOverall
     self.tableLayoutOverall.ColumnCount = 2
     self.tableLayoutOverall.ColumnStyles.Add(
         swf.ColumnStyle(swf.SizeType.Absolute, 50))
     self.tableLayoutOverall.ColumnStyles.Add(swf.ColumnStyle())
     self.tableLayoutOverall.Controls.Add(self.labelLink, 0, 0)
     self.tableLayoutOverall.Controls.Add(self.comboBoxLink, 1, 0)
     self.tableLayoutOverall.Controls.Add(self.flowLayoutPanelButtons, 0, 1)
     self.tableLayoutOverall.Dock = swf.DockStyle.Fill
     self.tableLayoutOverall.Location = sd.Point(0, 0)
     self.tableLayoutOverall.Name = "tableLayoutOverall"
     self.tableLayoutOverall.Padding = swf.Padding(5)
     self.tableLayoutOverall.RowCount = 2
     self.tableLayoutOverall.RowStyles.Add(
         swf.RowStyle(swf.SizeType.Percent, 50))
     self.tableLayoutOverall.RowStyles.Add(
         swf.RowStyle(swf.SizeType.Percent, 50))
     self.tableLayoutOverall.Size = sd.Size(324, 91)
     self.tableLayoutOverall.TabIndex = 0
     # RoomSpaceCopyForm
     self.AcceptButton = self.buttonSelect
     self.AutoScaleDimensions = sd.SizeF(6, 13)
     self.AutoScaleMode = swf.AutoScaleMode.Font
     self.CancelButton = self.buttonCancel
     self.ClientSize = sd.Size(324, 91)
     self.Controls.Add(self.tableLayoutOverall)
     self.MaximizeBox = False
     self.MinimizeBox = False
     self.MinimumSize = sd.Size(340, 130)
     self.Name = "RoomSpaceCopyForm"
     self.Text = "RoomSpaceCopyForm"
     self.tableLayoutOverall.ResumeLayout(False)
     self.tableLayoutOverall.PerformLayout()
     self.flowLayoutPanelButtons.ResumeLayout(False)
     self.ResumeLayout(False)
     # Populate comboBox and preselec first item
     for link_title in links.keys():
         self.comboBoxLink.Items.Add(link_title)
     self.comboBoxLink.SelectedIndex = 0
예제 #12
0
def test_class_name():
    '''
    This failed under IP 2.0A4.
    '''
    AreEqual(SWF.TextBox.__name__, "TextBox")
    AreEqual(SWF.TextBox().__class__.__name__, "TextBox")
 def VBoxManageButtonClick(self, sender, args):
     ofd = Forms.OpenFileDialog()
     ofd.CheckFileExists = True
     if ofd.ShowDialog() == Forms.DialogResult.OK:
         self.VBoxManageTextBox.Text = ofd.FileName
예제 #14
0
def create_file_dialog(
    dialog_type, directory, allow_multiple, save_filename, file_types, uid
):
    window = BrowserView.instances[uid]

    if not directory:
        directory = os.environ["HOMEPATH"]

    try:
        if dialog_type == FOLDER_DIALOG:
            dialog = CommonOpenFileDialog()
            dialog.IsFolderPicker = True

            if directory:
                dialog.InitialDirectory = directory

            result = dialog.ShowDialog()
            if result == WinForms.DialogResult.OK:
                file_path = (dialog.FileName,)
            else:
                file_path = None
        elif dialog_type == OPEN_DIALOG:
            dialog = WinForms.OpenFileDialog()

            dialog.Multiselect = allow_multiple
            dialog.InitialDirectory = directory

            if len(file_types) > 0:
                dialog.Filter = "|".join(
                    ["{0} ({1})|{1}".format(*parse_file_type(f)) for f in file_types]
                )
            else:
                dialog.Filter = (
                    localization["windows.fileFilter.allFiles"] + " (*.*)|*.*"
                )
            dialog.RestoreDirectory = True

            result = dialog.ShowDialog(window)
            if result == WinForms.DialogResult.OK:
                file_path = tuple(dialog.FileNames)
            else:
                file_path = None

        elif dialog_type == SAVE_DIALOG:
            dialog = WinForms.SaveFileDialog()
            if len(file_types) > 0:
                dialog.Filter = "|".join(
                    ["{0} ({1})|{1}".format(*parse_file_type(f)) for f in file_types]
                )
            else:
                dialog.Filter = (
                    localization["windows.fileFilter.allFiles"] + " (*.*)|*.*"
                )
            dialog.InitialDirectory = directory
            dialog.RestoreDirectory = True
            dialog.FileName = save_filename

            result = dialog.ShowDialog(window)
            if result == WinForms.DialogResult.OK:
                file_path = dialog.FileName
            else:
                file_path = None

        return file_path
    except:
        logger.exception("Error invoking {0} dialog".format(dialog_type))
        return None
예제 #15
0
    def __init__(self):

        # Create an instance of each control being used.
        self.components = System.ComponentModel.Container()
        self.treeView1 = WinForms.TreeView()
        self.listView1 = WinForms.ListView()
        self.richTextBox1 = WinForms.RichTextBox()
        self.splitter1 = WinForms.Splitter()
        self.splitter2 = WinForms.Splitter()
        self.panel1 = WinForms.Panel()

        # Set properties of TreeView control.
        self.treeView1.Dock = WinForms.DockStyle.Left
        self.treeView1.Width = self.ClientSize.Width / 3
        self.treeView1.TabIndex = 0
        self.treeView1.Nodes.Add("TreeView")

        # Set properties of ListView control.
        self.listView1.Dock = WinForms.DockStyle.Top
        self.listView1.Height = self.ClientSize.Height * 2 / 3
        self.listView1.TabIndex = 0
        self.listView1.Items.Add("ListView")

        # Set properties of RichTextBox control.
        self.richTextBox1.Dock = WinForms.DockStyle.Fill
        self.richTextBox1.TabIndex = 2
        self.richTextBox1.Text = "richTextBox1"

        # Set properties of Panel's Splitter control.
        self.splitter2.Dock = WinForms.DockStyle.Top

        # Width is irrelevant if splitter is docked to Top.
        self.splitter2.Height = 3

        # Use a different color to distinguish the two splitters.
        self.splitter2.BackColor = Color.Blue
        self.splitter2.TabIndex = 1

        # Set TabStop to false for ease of use when negotiating UI.
        self.splitter2.TabStop = 0

        # Set properties of Form's Splitter control.
        self.splitter1.Location = System.Drawing.Point(121, 0)
        self.splitter1.Size = System.Drawing.Size(3, 273)
        self.splitter1.BackColor = Color.Red
        self.splitter1.TabIndex = 1

        # Set TabStop to false for ease of use when negotiating UI.
        self.splitter1.TabStop = 0

        # Add the appropriate controls to the Panel.
        for item in (self.richTextBox1, self.splitter2, self.listView1):
            self.panel1.Controls.Add(item)

        # Set properties of Panel control.
        self.panel1.Dock = WinForms.DockStyle.Fill
        self.panel1.TabIndex = 2

        # Add the rest of the controls to the form.
        for item in (self.panel1, self.splitter1, self.treeView1):
            self.Controls.Add(item)

        self.Text = "Intricate UI Example"
예제 #16
0
        def __init__(self, uid, title, url, width, height, resizable,
                     fullscreen, min_size, confirm_quit, background_color,
                     debug, js_api, text_select, webview_ready):
            self.uid = uid
            self.Text = title
            self.ClientSize = Size(width, height)
            self.MinimumSize = Size(min_size[0], min_size[1])
            self.BackColor = ColorTranslator.FromHtml(background_color)

            self.AutoScaleDimensions = SizeF(96.0, 96.0)
            self.AutoScaleMode = WinForms.AutoScaleMode.Dpi

            if not resizable:
                self.FormBorderStyle = WinForms.FormBorderStyle.FixedSingle
                self.MaximizeBox = False

            # Application icon
            handle = windll.kernel32.GetModuleHandleW(None)
            icon_handle = windll.shell32.ExtractIconW(handle, sys.executable,
                                                      0)

            if icon_handle != 0:
                self.Icon = Icon.FromHandle(
                    IntPtr.op_Explicit(Int32(icon_handle))).Clone()

            windll.user32.DestroyIcon(icon_handle)

            self.webview_ready = webview_ready
            self.load_event = Event()

            self.web_browser = WinForms.WebBrowser()
            self.web_browser.Dock = WinForms.DockStyle.Fill
            self.web_browser.ScriptErrorsSuppressed = not debug
            self.web_browser.IsWebBrowserContextMenuEnabled = debug
            self.web_browser.WebBrowserShortcutsEnabled = False
            self.web_browser.DpiAware = True

            self.js_result_semaphore = Semaphore(0)
            self.js_bridge = BrowserView.JSBridge()
            self.js_bridge.parent_uid = uid
            self.web_browser.ObjectForScripting = self.js_bridge

            self.text_select = text_select

            if js_api:
                self.js_bridge.api = js_api

            # HACK. Hiding the WebBrowser is needed in order to show a non-default background color. Tweaking the Visible property
            # results in showing a non-responsive control, until it is loaded fully. To avoid this, we need to disable this behaviour
            # for the default background color.
            if background_color != '#FFFFFF':
                self.web_browser.Visible = False
                self.first_load = True
            else:
                self.first_load = False

            self.cancel_back = False
            self.web_browser.PreviewKeyDown += self.on_preview_keydown
            self.web_browser.Navigating += self.on_navigating
            self.web_browser.DocumentCompleted += self.on_document_completed

            if url:
                self.web_browser.Navigate(url)

            self.url = url

            self.Controls.Add(self.web_browser)
            self.is_fullscreen = False
            self.Shown += self.on_shown
            self.FormClosed += self.on_close

            if confirm_quit:
                self.FormClosing += self.on_closing

            if fullscreen:
                self.toggle_fullscreen()
예제 #17
0
    def __init__(self):
        self.components = ComponentModel.Container()
        #resources = ComponentModel.ComponentResourceManager(typeof(Form1))
        #listViewItem1 = Forms.ListViewItem(Array[string](["Source","U1","A1","DQ0","True"]), -1, Drawing.Color.OrangeRed, Drawing.Color.Empty, None)
        self.toolStrip1 = Forms.ToolStrip()
        self.toolStripButton1 = Forms.ToolStripButton()
        self.toolStripButton2 = Forms.ToolStripButton()
        self.toolStripButton3 = Forms.ToolStripButton()
        self.toolStripSeparator1 = Forms.ToolStripSeparator()
        self.toolStripLabel1 = Forms.ToolStripLabel()
        self.toolStripComboBox1 = Forms.ToolStripComboBox()

        self.listView1 = Forms.ListView()
        self.columnHeader1 = ((Forms.ColumnHeader()))
        self.columnHeader2 = ((Forms.ColumnHeader()))
        self.columnHeader3 = ((Forms.ColumnHeader()))
        self.columnHeader4 = ((Forms.ColumnHeader()))
        self.columnHeader5 = ((Forms.ColumnHeader()))
        self.button1 = Forms.Button()
        self.toolStripLabel1 = Forms.ToolStripLabel()
        self.checkBox1 = Forms.CheckBox()
        self.checkBox2 = Forms.CheckBox()
        self.toolTip1 = Forms.ToolTip(self.components)
        self.contextMenuStrip1 = Forms.ContextMenuStrip(self.components)
        self.sourceToolStripMenuItem = Forms.ToolStripMenuItem()
        self.sinkToolStripMenuItem = Forms.ToolStripMenuItem()
        self.floatToolStripMenuItem = Forms.ToolStripMenuItem()
        self.toolStrip1.SuspendLayout()
        self.contextMenuStrip1.SuspendLayout()
        self.SuspendLayout()
        # toolStrip1
        self.toolStrip1.ImageScalingSize = Drawing.Size(20, 20)
        self.toolStrip1.Items.Add(self.toolStripButton1)
        self.toolStrip1.Items.Add(self.toolStripButton2)
        self.toolStrip1.Items.Add(self.toolStripButton3)
        self.toolStrip1.Items.Add(self.toolStripSeparator1)
        self.toolStrip1.Items.Add(self.toolStripLabel1)
        self.toolStrip1.Items.Add(self.toolStripComboBox1)
        #self.toolStrip1.SelectedIndex = 0
        self.toolStrip1.Location = Drawing.Point(10, 10)
        self.toolStrip1.Name = "toolStrip1"
        self.toolStrip1.Size = Drawing.Size(815, 26)
        self.toolStrip1.TabIndex = 0
        self.toolStrip1.Text = "toolStrip1"
        # toolStripButton1
        self.toolStripButton1.DisplayStyle = Forms.ToolStripItemDisplayStyle.Text
        self.toolStripButton1.ForeColor = Drawing.Color.OrangeRed

        self.toolStripButton1.ImageTransparentColor = Drawing.Color.Magenta
        self.toolStripButton1.Name = "toolStripButton1"
        self.toolStripButton1.Size = Drawing.Size(61, 23)
        self.toolStripButton1.Text = "Source"
        self.toolStripButton1.Click += self.toolStripButton1_Click
        # toolStripButton2
        self.toolStripButton2.DisplayStyle = Forms.ToolStripItemDisplayStyle.Text
        self.toolStripButton2.ForeColor = Drawing.Color.SeaGreen

        self.toolStripButton2.ImageTransparentColor = Drawing.Color.Magenta
        self.toolStripButton2.Name = "toolStripButton2"
        self.toolStripButton2.Size = Drawing.Size(43, 23)
        self.toolStripButton2.Text = "Sink"
        self.toolStripButton2.Click += self.toolStripButton2_Click
        # toolStripButton3
        self.toolStripButton3.DisplayStyle = Forms.ToolStripItemDisplayStyle.Text
        self.toolStripButton3.ForeColor = Drawing.Color.DodgerBlue

        self.toolStripButton3.ImageTransparentColor = Drawing.Color.Magenta
        self.toolStripButton3.Name = "toolStripButton3"
        self.toolStripButton3.Size = Drawing.Size(47, 23)
        self.toolStripButton3.Text = "Float"
        self.toolStripButton3.Click += self.toolStripButton3_Click
        # toolStripSeparator1
        self.toolStripSeparator1.Name = "toolStripSeparator1"
        self.toolStripSeparator1.Size = Drawing.Size(6, 26)

        # toolStripLabel1
        self.toolStripLabel1.Name = "toolStripLabel1"
        self.toolStripLabel1.Size = Drawing.Size(104, 24)
        self.toolStripLabel1.Text = "Naming Rule:"
        # toolStripComboBox1
        self.toolStripComboBox1.Items.Add("net_comp_pin")
        self.toolStripComboBox1.Items.Add("net_pin_comp")
        self.toolStripComboBox1.Items.Add("comp_pin_net")
        self.toolStripComboBox1.Items.Add("comp_net_pin")
        self.toolStripComboBox1.Items.Add("pin_net_comp")
        self.toolStripComboBox1.Items.Add("pin_comp_net")
        self.toolStripComboBox1.SelectedIndex = 0
        self.toolStripComboBox1.Name = "toolStripComboBox1"
        self.toolStripComboBox1.Size = Drawing.Size(200, 27)

        # listView1
        self.listView1.Anchor = (((
            ((Forms.AnchorStyles.Top | Forms.AnchorStyles.Bottom)
             | Forms.AnchorStyles.Left) | Forms.AnchorStyles.Right)))
        self.listView1.BorderStyle = Forms.BorderStyle.FixedSingle
        self.listView1.Columns.Add(self.columnHeader1)
        self.listView1.Columns.Add(self.columnHeader2)
        self.listView1.Columns.Add(self.columnHeader3)
        self.listView1.Columns.Add(self.columnHeader4)
        self.listView1.Columns.Add(self.columnHeader5)
        #self.listView1.Columns.SelectedIndex = 0
        self.listView1.ContextMenuStrip = self.contextMenuStrip1
        self.listView1.FullRowSelect = True
        self.listView1.GridLines = True
        self.listView1.HideSelection = False
        #self.listView1.Items.Add(listViewItem1)
        #self.listView1.SelectedIndex = 0
        self.listView1.Location = Drawing.Point(10, 41)
        self.listView1.Name = "listView1"
        self.listView1.Size = Drawing.Size(815, 453)
        self.listView1.TabIndex = 1
        self.listView1.UseCompatibleStateImageBehavior = False
        self.listView1.View = Forms.View.Details
        self.listView1.ColumnClick += self.listView1_ColumnClick
        self.listView1.ItemSelectionChanged += self.listView1_ItemSelectionChanged
        # columnHeader1
        self.columnHeader1.Text = "Type"
        self.columnHeader1.Width = 126
        # columnHeader2
        self.columnHeader2.Text = "Component"
        self.columnHeader2.Width = 154
        # columnHeader3
        self.columnHeader3.Text = "Pin"
        self.columnHeader3.Width = 83
        # columnHeader4
        self.columnHeader4.Text = "Net"
        self.columnHeader4.Width = 286
        # columnHeader5
        self.columnHeader5.Text = "Both Source/Sink "
        self.columnHeader5.Width = 127
        # button1
        self.button1.Anchor = (((Forms.AnchorStyles.Bottom
                                 | Forms.AnchorStyles.Right)))
        self.button1.BackColor = Drawing.Color.DodgerBlue
        self.button1.Font = Drawing.Font("Microsoft Sans Serif", 12,
                                         Drawing.FontStyle.Bold,
                                         Drawing.GraphicsUnit.Point)
        self.button1.ForeColor = Drawing.SystemColors.ButtonHighlight
        self.button1.Location = Drawing.Point(715, 500)
        self.button1.Name = "button1"
        self.button1.Size = Drawing.Size(110, 41)
        self.button1.TabIndex = 2
        self.button1.Text = "Export"
        self.button1.UseVisualStyleBackColor = False
        self.button1.Click += self.button1_Click_1
        # toolStripLabel1
        self.toolStripLabel1.Name = "toolStripLabel1"
        self.toolStripLabel1.Size = Drawing.Size(0, 23)
        # checkBox1
        self.checkBox1.Anchor = (((Forms.AnchorStyles.Bottom
                                   | Forms.AnchorStyles.Left)))
        self.checkBox1.AutoSize = True
        self.checkBox1.Font = Drawing.Font("Microsoft Sans Serif", 10.2,
                                           Drawing.FontStyle.Regular,
                                           Drawing.GraphicsUnit.Point)
        self.checkBox1.Location = Drawing.Point(13, 511)
        self.checkBox1.Name = "checkBox1"
        self.checkBox1.Size = Drawing.Size(136, 24)
        self.checkBox1.TabIndex = 3
        self.checkBox1.Text = "Merge Source"
        self.checkBox1.UseVisualStyleBackColor = True
        # checkBox2
        self.checkBox2.Anchor = (((Forms.AnchorStyles.Bottom
                                   | Forms.AnchorStyles.Left)))
        self.checkBox2.AutoSize = True
        self.checkBox2.Checked = True
        self.checkBox2.CheckState = Forms.CheckState.Checked
        self.checkBox2.Font = Drawing.Font("Microsoft Sans Serif", 10.2,
                                           Drawing.FontStyle.Regular,
                                           Drawing.GraphicsUnit.Point)
        self.checkBox2.Location = Drawing.Point(155, 511)
        self.checkBox2.Name = "checkBox2"
        self.checkBox2.Size = Drawing.Size(115, 24)
        self.checkBox2.TabIndex = 4
        self.checkBox2.Text = "Merge Sink"
        self.checkBox2.UseVisualStyleBackColor = True
        # contextMenuStrip1
        self.contextMenuStrip1.ImageScalingSize = Drawing.Size(20, 20)
        self.contextMenuStrip1.Items.Add(self.sourceToolStripMenuItem)
        self.contextMenuStrip1.Items.Add(self.sinkToolStripMenuItem)
        self.contextMenuStrip1.Items.Add(self.floatToolStripMenuItem)
        #self.contextMenuStrip1.SelectedIndex = 0
        self.contextMenuStrip1.Name = "contextMenuStrip1"
        self.contextMenuStrip1.Size = Drawing.Size(127, 76)
        # sourceToolStripMenuItem
        self.sourceToolStripMenuItem.Name = "sourceToolStripMenuItem"
        self.sourceToolStripMenuItem.Size = Drawing.Size(126, 24)
        self.sourceToolStripMenuItem.Text = "Source"
        self.sourceToolStripMenuItem.Click += self.sourceToolStripMenuItem_Click
        # sinkToolStripMenuItem
        self.sinkToolStripMenuItem.Name = "sinkToolStripMenuItem"
        self.sinkToolStripMenuItem.Size = Drawing.Size(126, 24)
        self.sinkToolStripMenuItem.Text = "Sink"
        self.sinkToolStripMenuItem.Click += self.sinkToolStripMenuItem_Click
        # floatToolStripMenuItem
        self.floatToolStripMenuItem.Name = "floatToolStripMenuItem"
        self.floatToolStripMenuItem.Size = Drawing.Size(126, 24)
        self.floatToolStripMenuItem.Text = "Float"
        self.floatToolStripMenuItem.Click += self.floatToolStripMenuItem_Click
        # Form1
        self.AutoScaleDimensions = Drawing.SizeF(8, 16)
        self.AutoScaleMode = Forms.AutoScaleMode.Font
        self.BackColor = Drawing.Color.Azure
        self.ClientSize = Drawing.Size(835, 554)
        self.Controls.Add(self.checkBox2)
        self.Controls.Add(self.checkBox1)
        self.Controls.Add(self.button1)
        self.Controls.Add(self.listView1)
        self.Controls.Add(self.toolStrip1)
        self.Name = "Form1"
        self.Padding = Forms.Padding(10)
        self.Text = "Q3D Terminal Assignment"
        self.Load += self.Form1_Load
        self.toolStrip1.ResumeLayout(False)
        self.toolStrip1.PerformLayout()
        self.contextMenuStrip1.ResumeLayout(False)
        self.ResumeLayout(False)
        self.PerformLayout()
예제 #18
0
파일: __init__.py 프로젝트: Gaming32/wintk
 def __init__(self, cnf={}, **kw):
     global _defmaster
     _defmaster = self
     self.form = _for.Form()
     self.control = self.form
     self._new(cnf, **kw)
예제 #19
0
def pick_folder():
    fb_dlg = Forms.FolderBrowserDialog()
    if fb_dlg.ShowDialog() == Forms.DialogResult.OK:
        return fb_dlg.SelectedPath
예제 #20
0
def main():
    """Main script docstring."""

    print("🐍 Running {fname} version {ver}...".format(fname=__name,
                                                      ver=__version))

    # STEP 0: Setup
    app = __revit__.Application
    doc = __revit__.ActiveUIDocument.Document
    uidoc = __revit__.ActiveUIDocument
    view = doc.ActiveView

    # STEP 1: Find all appropriate schedules
    print("Getting all available schedules from the model...", end="")
    all_schedules = db.FilteredElementCollector(doc)\
                  .OfCategory(db.BuiltInCategory.OST_Schedules)\
                  .WhereElementIsNotElementType()\
                  .ToElements()
    print("✔")
    print("  ➜ Found {num} schedules in the project.".format(
        num=len(all_schedules)))
    #print(all_schedules)

    # STEP 2: Filtering for quantification schedules (with given prefix)
    print("Filtering quantification schedules from the found schedules...",
          end="")
    quantity_schedules = [
        s for s in all_schedules if s.Name.startswith(PREFIX)
    ]
    print("✔")
    print("  ➜ Found {num} schedules with prefix '{prefix}'.".format(
        num=len(quantity_schedules), prefix=PREFIX))
    #print(quantity_schedules)

    # STEP 3: Ask for export folder location
    print("Please select an output folder for saving the schedules...", end="")
    folder_browser = swf.FolderBrowserDialog()
    folder_browser.Description = "Please select an output folder for saving the schedules."
    if folder_browser.ShowDialog(
    ) != swf.DialogResult.OK:  # no folder selected
        print("\n✘ No folder selected. Nothing to do.")
        return ui.Result.Cancelled
    print("✔")
    print("🛈 Selected output folder: {folder}".format(
        folder=folder_browser.SelectedPath))

    # STEP 3: Export all selected schedules
    # https://www.revitapidocs.com/2018/8ba18e73-6daf-81b6-d15b-e4aa90bc8c22.htm
    print("Exporting schedules as CSV to selected output folder...", end="")
    try:
        export_options = db.ViewScheduleExportOptions()
        export_options.FieldDelimiter = ","
        for schedule in quantity_schedules:
            file_name = "{name}.csv".format(name=schedule.Name)
            schedule.Export(folder_browser.SelectedPath, file_name,
                            export_options)
    except Exception as ex:
        print("\n✘ Exception:\n {ex}".format(ex=ex))
        return ui.Result.Failed
    else:
        print("✔\nDone. 😊")
        return ui.Result.Succeeded
예제 #21
0
    def InitializeComponent(self):
        """Initialize form components."""
        self.components = System.ComponentModel.Container()

        self.openFileDialog = WinForms.OpenFileDialog()
        self.saveFileDialog = WinForms.SaveFileDialog()

        self.mainMenu = WinForms.MainMenu()

        self.fileMenu = WinForms.MenuItem()
        self.menuFileNew = WinForms.MenuItem()
        self.menuFileOpen = WinForms.MenuItem()
        self.menuFileSave = WinForms.MenuItem()
        self.menuFileSaveAs = WinForms.MenuItem()
        self.menuFileSep_1 = WinForms.MenuItem()
        self.menuFileExit = WinForms.MenuItem()

        self.editMenu = WinForms.MenuItem()
        self.menuEditUndo = WinForms.MenuItem()
        self.menuEditRedo = WinForms.MenuItem()
        self.menuEditSep_1 = WinForms.MenuItem()
        self.menuEditCut = WinForms.MenuItem()
        self.menuEditCopy = WinForms.MenuItem()
        self.menuEditPaste = WinForms.MenuItem()
        self.menuEditSep_2 = WinForms.MenuItem()
        self.menuEditSelectAll = WinForms.MenuItem()

        self.formatMenu = WinForms.MenuItem()
        self.menuFormatFont = WinForms.MenuItem()
        self.menuFormatWordWrap = WinForms.MenuItem()

        self.aboutMenu = WinForms.MenuItem()
        self.menuHelpAbout = WinForms.MenuItem()

        self.richTextBox = WinForms.RichTextBox()
        self.statusBarPanel1 = WinForms.StatusBarPanel()
        self.statusBar = WinForms.StatusBar()
        self.fontDialog = WinForms.FontDialog()
        self.statusBarPanel1.BeginInit()

        # ===================================================================
        # File Menu
        # ===================================================================

        self.menuFileNew.Text = "&New"
        self.menuFileNew.Shortcut = WinForms.Shortcut.CtrlN
        self.menuFileNew.ShowShortcut = False
        self.menuFileNew.Index = 0
        self.menuFileNew.Click += self.OnClickFileNew

        self.menuFileOpen.Text = "&Open"
        self.menuFileOpen.Shortcut = WinForms.Shortcut.CtrlO
        self.menuFileOpen.ShowShortcut = False
        self.menuFileOpen.Index = 1
        self.menuFileOpen.Click += self.OnClickFileOpen

        self.menuFileSave.Text = "&Save"
        self.menuFileSave.Shortcut = WinForms.Shortcut.CtrlS
        self.menuFileSave.ShowShortcut = False
        self.menuFileSave.Index = 2
        self.menuFileSave.Click += self.OnClickFileSave

        self.menuFileSaveAs.Text = "Save &As"
        self.menuFileSaveAs.Index = 3
        self.menuFileSaveAs.Click += self.OnClickFileSaveAs

        self.menuFileSep_1.Text = "-"
        self.menuFileSep_1.Index = 4

        self.menuFileExit.Text = "E&xit"
        self.menuFileExit.Shortcut = WinForms.Shortcut.AltF4
        self.menuFileExit.ShowShortcut = False
        self.menuFileExit.Index = 5
        self.menuFileExit.Click += self.OnClickFileExit

        self.fileMenu.Text = "&File"
        self.fileMenu.Index = 0

        items = (self.menuFileNew, self.menuFileOpen, self.menuFileSave,
                 self.menuFileSaveAs, self.menuFileSep_1, self.menuFileExit)

        self.fileMenu.MenuItems.AddRange(items)

        # ===================================================================
        # Edit menu
        # ===================================================================

        self.menuEditUndo.Text = "&Undo"
        self.menuEditUndo.Shortcut = WinForms.Shortcut.CtrlZ
        self.menuEditUndo.Index = 0
        self.menuEditUndo.Click += self.OnClickEditUndo

        self.menuEditRedo.Text = "&Redo"
        self.menuEditRedo.Shortcut = WinForms.Shortcut.CtrlY
        self.menuEditRedo.Index = 1
        self.menuEditRedo.Click += self.OnClickEditRedo

        self.menuEditSep_1.Text = "-"
        self.menuEditSep_1.Index = 2

        self.menuEditCut.Text = "Cut"
        self.menuEditCut.Shortcut = WinForms.Shortcut.CtrlX
        self.menuEditCut.Index = 3
        self.menuEditCut.Click += self.OnClickEditCut

        self.menuEditCopy.Text = "Copy"
        self.menuEditCopy.Shortcut = WinForms.Shortcut.CtrlC
        self.menuEditCopy.Index = 4
        self.menuEditCopy.Click += self.OnClickEditCopy

        self.menuEditPaste.Text = "Paste"
        self.menuEditPaste.Shortcut = WinForms.Shortcut.CtrlV
        self.menuEditPaste.Index = 5
        self.menuEditPaste.Click += self.OnClickEditPaste

        self.menuEditSelectAll.Text = "Select All"
        self.menuEditSelectAll.Shortcut = WinForms.Shortcut.CtrlA
        self.menuEditSelectAll.Index = 7
        self.menuEditSelectAll.Click += self.OnClickEditSelectAll

        self.menuEditSep_2.Text = "-"
        self.menuEditSep_2.Index = 6

        self.editMenu.Text = "&Edit"
        self.editMenu.Index = 1

        items = (self.menuEditUndo, self.menuEditRedo, self.menuEditSep_1,
                 self.menuEditCut, self.menuEditCopy, self.menuEditPaste,
                 self.menuEditSep_2, self.menuEditSelectAll)

        self.editMenu.MenuItems.AddRange(items)

        # ===================================================================
        # Format Menu
        # ===================================================================

        self.menuFormatWordWrap.Text = "Word Wrap"
        self.menuFormatWordWrap.Checked = self.word_wrap
        self.menuFormatWordWrap.Index = 1
        self.menuFormatWordWrap.Click += self.OnClickFormatWordWrap

        self.menuFormatFont.Text = "Fo&nt"
        self.menuFormatFont.Index = 0
        self.menuFormatFont.Click += self.OnClickFormatFont

        self.formatMenu.Text = "F&ormat"
        self.formatMenu.Index = 2

        items = (self.menuFormatWordWrap, self.menuFormatFont)

        self.formatMenu.MenuItems.AddRange(items)

        # ===================================================================
        # About menu
        # ===================================================================

        self.menuHelpAbout.Text = "&About"
        self.menuHelpAbout.Index = 0
        self.menuHelpAbout.Click += self.OnClickHelpAbout

        self.aboutMenu.Text = "&Help"
        self.aboutMenu.Index = 3
        self.aboutMenu.MenuItems.Add(self.menuHelpAbout)

        self.statusBarPanel1.Dock = WinForms.DockStyle.Fill
        self.statusBarPanel1.Text = "Ready"
        self.statusBarPanel1.Width = 755

        self.richTextBox.Dock = WinForms.DockStyle.Fill
        self.richTextBox.Size = System.Drawing.Size(795, 485)
        self.richTextBox.TabIndex = 0
        self.richTextBox.AutoSize = 1
        self.richTextBox.ScrollBars = WinForms.RichTextBoxScrollBars.ForcedBoth
        self.richTextBox.Font = System.Drawing.Font("Tahoma", 10.0)
        self.richTextBox.AcceptsTab = 1
        self.richTextBox.Location = System.Drawing.Point(0, 0)

        self.statusBar.BackColor = System.Drawing.SystemColors.Control
        self.statusBar.Location = System.Drawing.Point(0, 518)
        self.statusBar.Size = System.Drawing.Size(775, 19)
        self.statusBar.TabIndex = 1
        self.statusBar.ShowPanels = True
        self.statusBar.Panels.Add(self.statusBarPanel1)

        items = (self.fileMenu, self.editMenu, self.formatMenu, self.aboutMenu)
        self.mainMenu.MenuItems.AddRange(items)

        self.openFileDialog.Filter = "Text documents|*.txt|RTF document|*.rtf"
        self.openFileDialog.Title = "Open document"

        self.saveFileDialog.Filter = "Text Documents|*.txt|" \
                                     "Rich Text Format|*.rtf"
        self.saveFileDialog.Title = "Save document"
        self.saveFileDialog.FileName = "Untitled"

        self.AutoScaleBaseSize = System.Drawing.Size(5, 13)
        self.ClientSize = System.Drawing.Size(775, 537)
        self.Menu = self.mainMenu
        self.Text = "Python Wordpad"

        self.Controls.Add(self.statusBar)
        self.Controls.Add(self.richTextBox)
        self.statusBarPanel1.EndInit()
def main():
    """Main Function."""

    print("Running {fname} version {ver}...".format(fname=__name,
                                                    ver=__version))

    # STEP 0: Setup
    doc = __revit__.ActiveUIDocument.Document
    view = doc.ActiveView

    # STEP 1: Ask user for clash report html file adn parse it
    print("Opening interference check report file...")
    open_dialog = swf.OpenFileDialog()
    open_dialog.Title = "Open Interference Check Report"
    open_dialog.Filter = "HMTL files (*.html)|*.html"
    if open_dialog.ShowDialog() == swf.DialogResult.OK:  # file selected
        file_path = open_dialog.FileName
        # STEP 2: Parse clash report file and summarize findings
        print("Reading {fname}...".format(fname=file_path))
        with open(file_path, mode="rb") as html_file:
            html = html_file.read()  # just read the plain bytes
            uhtml = unicode(
                html, "utf-16")  # Revit exports html in UTF-16(-LE) encoding
        print("Parsing file contents...")
        parser = InterferenceReportParser()
        parser.feed(uhtml)
        parser.close()
        clashes = parser.clashes
        clashing_ids = []
        for pair in parser.clashes.values():
            for elem_id in pair:
                clashing_ids.append(elem_id)
        clashing_ids = set(clashing_ids)
        # Get all element ids of the elements in the view
        all_ids = db.FilteredElementCollector(doc, view.Id)\
                    .WhereElementIsNotElementType()\
                    .ToElementIds()
        all_ids = set([elem_id.IntegerValue for elem_id in all_ids])
        # Get all element ids of non-clashing elements in the view
        non_clashing_ids = all_ids - clashing_ids
        # Create summary text for user input dialog
        summary_text = "Checked report {path}\n".format(path=file_path)
        summary_text += "Found {num} clashes in the report.\n".format(
            num=len(clashes))
        summary_text += "Found {num} clashing elements involved in those clashes.\n".format(
            num=len(clashing_ids))
        summary_text += "The total number of elements in the current view is {num}\n".format(
            num=len(all_ids))
        summary_text += "Found {num} non-clashing elements in the current view.".format(
            num=len(non_clashing_ids))
        print(summary_text)

        # STEP 3: Ask user for display option
        dialog = ui.TaskDialog(title="Mark All Clashes")
        dialog.MainInstruction = "Interference Report Summary"
        dialog.MainContent = summary_text
        dialog.AddCommandLink(ui.TaskDialogCommandLinkId.CommandLink1,
                              "Mark clashing elements and fade the rest")
        dialog.AddCommandLink(ui.TaskDialogCommandLinkId.CommandLink2,
                              "Hide all non-clashing elements temporarily")
        dialog.CommonButtons = ui.TaskDialogCommonButtons.Close
        dialog.DefaultButton = ui.TaskDialogResult.Close
        result = dialog.Show()

        # Step 4: Emphasize the clashes based on the user selection
        transaction = db.Transaction(doc)
        transaction.Start("{name} - v{ver}".format(name=__name, ver=__version))
        try:
            if result == ui.TaskDialogResult.CommandLink1:  # Mark clashes and fade the rest
                print("Marking all clashing elements and fading the rest...")
                for elem_id in all_ids:  # fade all visible elements in the view
                    view.SetElementOverrides(db.ElementId(elem_id),
                                             faded_overrides)
                for elem_id in clashing_ids:  # emphasize the clashing elements
                    view.SetElementOverrides(db.ElementId(elem_id),
                                             clashing_overrides)
            elif result == ui.TaskDialogResult.CommandLink2:  # Hide all non-clashing elements
                print(
                    "Hiding all non-clashing elements in the view temporarily..."
                )
                for elem_id in non_clashing_ids:  # hide alll non-clashing elements
                    view.HideElementTemporary(db.ElementId(elem_id))
            else:
                print("Nothing to do.")
        except Exception as ex:
            print("Exception: {ex}".format(ex=ex))
            transaction.RollBack()
        else:
            transaction.Commit()
            print("Done.")
    else:  # no file to parse
        print("Nothing to do.")
예제 #23
0
 def test_class_name(self):
     '''This failed under IP 2.0A4.'''
     import System.Windows.Forms as SWF
     self.assertEqual(SWF.TextBox.__name__, "TextBox")
     self.assertEqual(SWF.TextBox().__class__.__name__, "TextBox")
예제 #24
0
 def InitializeComponent(self):
     '''Windows Form Designer generated code'''
     self.lblServerName = SysForms.Label()
     self.grpStreamProps = SysForms.GroupBox()
     self.btnCloseStream = SysForms.Button()
     self.btnOpenStream = SysForms.Button()
     self.btnObjectRefresh = SysForms.Button()
     self.lblObjectCountNum = SysForms.Label()
     self.lblObjectCount = SysForms.Label()
     self.lblObjectTypeString = SysForms.Label()
     self.lblObjectType = SysForms.Label()
     self.cmbDASObjects = SysForms.ComboBox()
     self.lblDASObjects = SysForms.Label()
     self.lblServerNameComment = SysForms.Label()
     self.txtServerName = SysForms.TextBox()
     self.btnDisconnect = SysForms.Button()
     self.btnConnect = SysForms.Button()
     self.grpRecordLog = SysForms.GroupBox()
     self.lbRecordLog = SysForms.ListBox()
     self.grpStreamProps.SuspendLayout()
     self.grpRecordLog.SuspendLayout()
     self.SuspendLayout()
     #
     # lblServerName
     #
     self.lblServerName.Location = SysDrawing.Point(16, 8)
     self.lblServerName.Name = "lblServerName"
     self.lblServerName.Size = SysDrawing.Size(72, 16)
     self.lblServerName.TabIndex = 24
     self.lblServerName.Text = "Server Name"
     #
     # grpStreamProps
     #
     self.grpStreamProps.Controls.Add(self.btnCloseStream)
     self.grpStreamProps.Controls.Add(self.btnOpenStream)
     self.grpStreamProps.Controls.Add(self.btnObjectRefresh)
     self.grpStreamProps.Controls.Add(self.lblObjectCountNum)
     self.grpStreamProps.Controls.Add(self.lblObjectCount)
     self.grpStreamProps.Controls.Add(self.lblObjectTypeString)
     self.grpStreamProps.Controls.Add(self.lblObjectType)
     self.grpStreamProps.Controls.Add(self.cmbDASObjects)
     self.grpStreamProps.Controls.Add(self.lblDASObjects)
     self.grpStreamProps.Location = SysDrawing.Point(16, 64)
     self.grpStreamProps.Name = "grpStreamProps"
     self.grpStreamProps.Size = SysDrawing.Size(520, 88)
     self.grpStreamProps.TabIndex = 29
     self.grpStreamProps.TabStop = False
     self.grpStreamProps.Text = "Stream Properties"
     #
     # btnCloseStream
     #
     self.btnCloseStream.Location = SysDrawing.Point(192, 56)
     self.btnCloseStream.Name = "btnCloseStream"
     self.btnCloseStream.Size = SysDrawing.Size(88, 23)
     self.btnCloseStream.TabIndex = 8
     self.btnCloseStream.Text = "Close Stream"
     self.btnCloseStream.Click += System.EventHandler(
         self.btnCloseStream_Click)
     #
     # btnOpenStream
     #
     self.btnOpenStream.Location = SysDrawing.Point(104, 56)
     self.btnOpenStream.Name = "btnOpenStream"
     self.btnOpenStream.Size = SysDrawing.Size(80, 23)
     self.btnOpenStream.TabIndex = 7
     self.btnOpenStream.Text = "Open Stream"
     self.btnOpenStream.Click += System.EventHandler(
         self.btnOpenStream_Click)
     #
     # btnObjectRefresh
     #
     self.btnObjectRefresh.Location = SysDrawing.Point(16, 56)
     self.btnObjectRefresh.Name = "btnObjectRefresh"
     self.btnObjectRefresh.Size = SysDrawing.Size(80, 23)
     self.btnObjectRefresh.TabIndex = 6
     self.btnObjectRefresh.Text = "Refresh List"
     self.btnObjectRefresh.Click += System.EventHandler(
         self.btnObjectRefresh_Click)
     #
     # lblObjectCountNum
     #
     self.lblObjectCountNum.BorderStyle = SysForms.BorderStyle.Fixed3D
     self.lblObjectCountNum.Location = SysDrawing.Point(472, 29)
     self.lblObjectCountNum.Name = "lblObjectCountNum"
     self.lblObjectCountNum.Size = SysDrawing.Size(32, 23)
     self.lblObjectCountNum.TabIndex = 5
     #
     # lblObjectCount
     #
     self.lblObjectCount.Location = SysDrawing.Point(400, 32)
     self.lblObjectCount.Name = "lblObjectCount"
     self.lblObjectCount.Size = SysDrawing.Size(72, 16)
     self.lblObjectCount.TabIndex = 4
     self.lblObjectCount.Text = "Object Count"
     #
     # lblObjectTypeString
     #
     self.lblObjectTypeString.BorderStyle = SysForms.BorderStyle.Fixed3D
     self.lblObjectTypeString.Location = SysDrawing.Point(296, 29)
     self.lblObjectTypeString.Name = "lblObjectTypeString"
     self.lblObjectTypeString.Size = SysDrawing.Size(88, 23)
     self.lblObjectTypeString.TabIndex = 3
     #
     # lblObjectType
     #
     self.lblObjectType.Location = SysDrawing.Point(224, 32)
     self.lblObjectType.Name = "lblObjectType"
     self.lblObjectType.Size = SysDrawing.Size(72, 16)
     self.lblObjectType.TabIndex = 2
     self.lblObjectType.Text = "Object Type"
     #
     # cmbDASObjects
     #
     self.cmbDASObjects.DropDownStyle = SysForms.ComboBoxStyle.DropDownList
     self.cmbDASObjects.Location = SysDrawing.Point(104, 30)
     self.cmbDASObjects.Name = "cmbDASObjects"
     self.cmbDASObjects.Size = SysDrawing.Size(112, 21)
     self.cmbDASObjects.TabIndex = 1
     self.cmbDASObjects.SelectedIndexChanged += System.EventHandler(
         self.cmbDASObjects_SelectedIndexChanged)
     #
     # lblDASObjects
     #
     self.lblDASObjects.Location = SysDrawing.Point(16, 32)
     self.lblDASObjects.Name = "lblDASObjects"
     self.lblDASObjects.Size = SysDrawing.Size(88, 16)
     self.lblDASObjects.TabIndex = 0
     self.lblDASObjects.Text = "DAS Objects"
     #
     # lblServerNameComment
     #
     self.lblServerNameComment.Location = SysDrawing.Point(136, 32)
     self.lblServerNameComment.Name = "lblServerNameComment"
     self.lblServerNameComment.Size = SysDrawing.Size(208, 16)
     self.lblServerNameComment.TabIndex = 28
     self.lblServerNameComment.Text = "(User may enter pc name or IP address)"
     #
     # txtServerName
     #
     self.txtServerName.Location = SysDrawing.Point(96, 8)
     self.txtServerName.Name = "txtServerName"
     self.txtServerName.Size = SysDrawing.Size(280, 20)
     self.txtServerName.TabIndex = 27
     self.txtServerName.Text = ""
     #
     # btnDisconnect
     #
     self.btnDisconnect.Location = SysDrawing.Point(464, 8)
     self.btnDisconnect.Name = "btnDisconnect"
     self.btnDisconnect.TabIndex = 26
     self.btnDisconnect.Text = "Disconnect"
     self.btnDisconnect.Click += System.EventHandler(
         self.btnDisconnect_Click)
     #
     # btnConnect
     #
     self.btnConnect.Location = SysDrawing.Point(384, 8)
     self.btnConnect.Name = "btnConnect"
     self.btnConnect.TabIndex = 25
     self.btnConnect.Text = "Connect"
     self.btnConnect.Click += System.EventHandler(self.btnConnect_Click)
     #
     # grpRecordLog
     #
     self.grpRecordLog.Controls.Add(self.lbRecordLog)
     self.grpRecordLog.Location = SysDrawing.Point(16, 168)
     self.grpRecordLog.Name = "grpRecordLog"
     self.grpRecordLog.Size = SysDrawing.Size(520, 240)
     self.grpRecordLog.TabIndex = 30
     self.grpRecordLog.TabStop = False
     self.grpRecordLog.Text = "Record Log"
     #
     # lbRecordLog
     #
     self.lbRecordLog.Location = SysDrawing.Point(8, 16)
     self.lbRecordLog.Name = "lbRecordLog"
     self.lbRecordLog.Size = SysDrawing.Size(504, 212)
     self.lbRecordLog.TabIndex = 0
     #
     # NetComExampleStreamsForm
     #
     self.AutoScaleBaseSize = SysDrawing.Size(5, 13)
     self.ClientSize = SysDrawing.Size(552, 422)
     self.Controls.Add(self.lblServerName)
     self.Controls.Add(self.grpStreamProps)
     self.Controls.Add(self.lblServerNameComment)
     self.Controls.Add(self.txtServerName)
     self.Controls.Add(self.btnDisconnect)
     self.Controls.Add(self.btnConnect)
     self.Controls.Add(self.grpRecordLog)
     self.FormBorderStyle = SysForms.FormBorderStyle.FixedDialog
     self.Name = "NetComExampleStreamsForm"
     self.Text = "NetCom Example - Streams"
     self.grpStreamProps.ResumeLayout(False)
     self.grpRecordLog.ResumeLayout(False)
     self.ResumeLayout(False)
예제 #25
0
 def create_panel():
     """Create a new `Panel <https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.panel>`_."""
     return Forms.Panel()
예제 #26
0
def main():
    """Main Script."""

    print("🐍 Running {fname} version {ver}...".format(fname=__name,
                                                      ver=__version))

    # STEP 0: Setup
    doc = __revit__.ActiveUIDocument.Document

    # STEP 1: Inspect Model and summarize findings
    pipe_insulations = query_all_elements_of_category(
        doc=doc, cat=db.BuiltInCategory.OST_PipeInsulations)
    duct_insulations = query_all_elements_of_category(
        doc=doc, cat=db.BuiltInCategory.OST_DuctInsulations)
    rogue_pipe, unhosted_pipe = find_rogue_and_unhosted_elements(
        doc=doc, elems=pipe_insulations)
    rogue_duct, unhosted_duct = find_rogue_and_unhosted_elements(
        doc=doc, elems=duct_insulations)
    summary_list = write_summary(
        tpipe=pipe_insulations,
        tduct=duct_insulations,  # totals
        upipe=unhosted_pipe,
        uduct=unhosted_duct,  # unhosted
        rpipe=rogue_pipe,
        rduct=rogue_duct)  # rogue
    summary_text = "\n".join(summary_list)
    print(summary_text)

    # STEP 2: Receive User Input
    dialog = ui.TaskDialog(title="Insulation Cleanup")
    dialog.MainInstruction = "Insulation Cleanup Summary"
    dialog.MainContent = summary_text
    dialog.AddCommandLink(ui.TaskDialogCommandLinkId.CommandLink1,
                          "Write Report")
    dialog.AddCommandLink(ui.TaskDialogCommandLinkId.CommandLink2,
                          "Clean Insulation")
    dialog.CommonButtons = ui.TaskDialogCommonButtons.Close
    dialog.DefaultButton = ui.TaskDialogResult.Close
    result = dialog.Show()

    # STEP 3: Write report or clean up insulation
    if result == ui.TaskDialogResult.CommandLink1:  # Write report
        save_dialog = swf.SaveFileDialog()
        save_dialog.Title = "Save Insulation Cleanup Report"
        save_dialog.Filter = "Text files|*.txt"
        save_dialog.FileName = "report.txt"
        if save_dialog.ShowDialog() == swf.DialogResult.OK:  # Save report
            file_path = save_dialog.FileName
            print("Writing report to {0}".format(file_path))
            with open(file_path, mode="wb") as fh:
                report = write_report(doc, unhosted_pipe, rogue_pipe,
                                      unhosted_duct, rogue_duct)
                for line in report:
                    fh.write("{line}\r\n".format(line=line))
            print("✔\nDone. 😊")
            return ui.Result.Succeeded
        else:  # Don't save report
            print("🛈 File save dialog canceled.")
            return ui.Result.Cancelled
    elif result == ui.TaskDialogResult.CommandLink2:  # Clean Insulation
        transaction = db.Transaction(doc)
        transaction.Start("{name} - v{ver}".format(name=__name, ver=__version))
        try:
            print("Cleaning Insulation...")
            for pipe_element in unhosted_pipe:
                doc.Delete(pipe_element.Id)
            print("Deleted {num} unhosted pipe insulation elements".format(
                num=len(unhosted_pipe)))
            for pipe_pair in rogue_pipe:
                cleanup_insulation(pipe_pair)
            print("Moved {num} rogue pipe insulation elements.".format(
                num=len(rogue_pipe)))
            for duct_element in unhosted_duct:
                doc.Delete(duct_element.Id)
            print("Deleted {num} unhosted duct insulation elements.".format(
                num=len(unhosted_duct)))
            for duct_pair in rogue_duct:
                cleanup_insulation(duct_pair)
            print("Moved {num} rogue duct insulation elements.".format(
                num=len(rogue_duct)))
        except Exception as exception:
            print("Failed.\nException:\n{ex}".format(ex=exception))
            transaction.RollBack()
            return ui.Result.Failed
        else:
            print("✔\nDone. 😊")
            transaction.Commit()
            return ui.Result.Succeeded
    else:
        print("Nothing to do.")
        return ui.Result.Cancelled