Esempio n. 1
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"
Esempio n. 2
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()