def test_cp13405(self): import System.Windows.Forms as SWF from System.Windows.Forms import PropertyGrid, DockStyle, Form grid = PropertyGrid() grid.Dock = DockStyle.Fill form = Form() form.Controls.Add(grid) form.Show() class PropertyExample(object): def __init__(self, X): self._X = X def _getX(self): return self._X def _setX(self, value): self._X = value X = property(_getX, _setX) example = PropertyExample(3) grid.SelectedObject = example def close_form(): while not form.Visible: System.Threading.Thread.Sleep(100) System.Threading.Thread.Sleep(3000) form.Close() th = System.Threading.Thread(System.Threading.ThreadStart(close_form)) th.Start() SWF.Application.Run(form)
def ShowDialog(self, controller): # set controller self.controller = controller # initialize success bool self.success = False # initialize invalid params label self.invalid_params_label = None # get current TTL params self.TTL_params = controller.config_params['TTL_params'] # create the form self.dialog_window = Form() self.dialog_window.FormBorderStyle = FormBorderStyle.FixedSingle self.dialog_window.Text = "TTL Parameters" self.dialog_window.StartPosition = FormStartPosition.CenterScreen self.dialog_window.Width = 200 # add & populate TTL param panel self.add_TTL_param_panel() self.populate_TTL_param_panel() # add save button panel self.add_save_button_panel() # auto-size the window self.dialog_window.AutoSize = True # show the dialog self.dialog_window.ShowDialog() # return success boolean return self.success
def __init__(self, width=320, height=240, setup=None, teardown=None): """ Creates a .NET Windows Form instance. :param width: Width of the window :param height: Height of the window :param setup: Function callback to call when the form has been created :param tearmdown: Function delegate to assign to the Form's Closing event """ from System.Windows.Forms import Application, Form from System.Drawing import Size self.form = Form(Text="muFAT Test", Size=Size(width, height), MinimizeBox=False, MaximizeBox=False, TopMost=True) self.hwnd = self.form.Handle if setup is not None: setup.__call__() if teardown is not None: self.form.Closing += teardown else: self.form.Closing += self.__exit__ if hasattr(self, 'resized'): self.form.ResizeEnd += self.resized
def __init__(self, openFileDialog=None): Form.__init__(self) if openFileDialog: self.openFileDialog = openFileDialog else: self.openFileDialog = OpenFileDialog() self.Text = 'Tabbed Image Viewer' self.Width = 450 self.Height = 400 self.StartPosition = FormStartPosition.CenterScreen self.Icon = Icon(Path.Combine(IMAGEPATH, "pictures.ico")) self.AllowDrop = True self.justCopied = False self.paths = [] self.initTabControl() self.initToolBar() self.initMenu() self.initContextMenu() self._clipboardViewerNext = None if SetClipboardViewer is not None: self._clipboardViewerNext = SetClipboardViewer.SetClipboardViewer(self.Handle) for fileName in sys.argv[1:]: self.openFile(fileName) self.updateToolbar() self.DragEnter += self.onDragEnter self.DragDrop += self.onDragDrop
def ShowDialog(self, controller, title, text, default_input, exp_index): # set controller self.controller = controller # set exp index self.exp_index = exp_index # initialize exp name variable self.exp_name = None # initialize invalid name label self.invalid_name_label = None # create the form self.dialog_window = Form() self.dialog_window.AutoSize = True self.dialog_window.Width = 400 self.dialog_window.MaximumSize = Size(400, 160) self.dialog_window.StartPosition = FormStartPosition.CenterScreen self.dialog_window.Text = title self.dialog_window.FormBorderStyle = FormBorderStyle.FixedSingle # create the main panel self.panel = FlowLayoutPanel() self.panel.Parent = self.dialog_window self.panel.BackColor = DIALOG_COLOR self.panel.Dock = DockStyle.Top self.panel.Padding = Padding(10, 10, 0, 10) self.panel.FlowDirection = FlowDirection.TopDown self.panel.WrapContents = False self.panel.AutoSize = True self.panel.Font = BODY_FONT # add the dialog text exp_name_label = Label() exp_name_label.Parent = self.panel exp_name_label.Text = text exp_name_label.Width = self.panel.Width exp_name_label.AutoSize = True exp_name_label.Margin = Padding(0, 5, 0, 0) # add the textbox self.exp_name_box = TextBox() self.exp_name_box.Text = default_input self.exp_name_box.Parent = self.panel self.exp_name_box.Width = self.panel.Width - 30 self.exp_name_box.AutoSize = True self.exp_name_box.BackColor = BUTTON_PANEL_COLOR self.exp_name_box.Font = Font(BODY_FONT.FontFamily, 9) # add save button panel self.add_save_button_panel() # show the dialog self.dialog_window.ShowDialog() # return the exp name return self.exp_name
def __init__(self, docs): Form.__init__(self) self.ClientSize = Size(400, 400) self.Text = "Module Details" self.Icon = Icon(UIGlobal.ApplicationIcon) infoPane = ModuleInfoPane() infoPane.SetFromDocs(docs) self.Controls.Add(infoPane)
def __init__(self, bitmap): Form.__init__(self) picBox = PictureBox() picBox.SizeMode = PictureBoxSizeMode.AutoSize picBox.Image = bitmap picBox.Dock = DockStyle.Fill self.Controls.Add(picBox) self.Show() self.Width = bitmap.Width + 20 self.Height = bitmap.Height + 20
def __init__(self): Form.__init__(self) self.Text = 'MultiDoc Editor' self.MinimumSize = Size(150, 150) self.tabControl = TabControl() self.tabControl.Dock = DockStyle.Fill self.tabControl.Alignment = TabAlignment.Bottom self.Controls.Add(self.tabControl) self.addTabPage("New Page", '')
def thread_proc(): try: global dispatcher global are # Create a dummy Control so that we can use it to dispatch commands to the WinForms thread dispatcher = Form(Size=Size(0, 0)) dispatcher.Show() dispatcher.Hide() are.Set() Application.Run() finally: IronPython.Hosting.PythonEngine.ConsoleCommandDispatcher = None
def __init__(self): Form.__init__(self) self.Text = 'MultiDoc Editor' self.MinimumSize = Size(150, 150) self.tabControl = TabControl() self.tabControl.Dock = DockStyle.Fill self.tabControl.Alignment = TabAlignment.Bottom self.Controls.Add(self.tabControl) self.document = Document() self.tabController = TabController(self.tabControl, self.document)
def create_form(): f = Form() f.Text = "HelloIronPython" btn = Button() btn.Text = "ClickMe" f.Controls.Add(btn) btn.Top = (f.ClientSize.Height - btn.Height) / 2 btn.Left = (f.ClientSize.Width - btn.Width) / 2 Application.Run(f)
def create_form(): f=Form() f.Text="HelloIronPython" btn=Button() btn.Text="ClickMe" f.Controls.Add(btn) btn.Top=(f.ClientSize.Height-btn.Height)/2 btn.Left=(f.ClientSize.Width-btn.Width)/2 Application.Run(f)
def __init__(self): Form.__init__(self) self.ClientSize = Size(400, 250) self.Text = "About FLExTools" self.FormBorderStyle = FormBorderStyle .Fixed3D self.Icon = Icon(UIGlobal.ApplicationIcon) pb = PictureBox() pb.Image = Image.FromFile(UIGlobal.ApplicationIcon) pb.BackColor = UIGlobal.helpDialogColor pb.SizeMode = PictureBoxSizeMode.CenterImage self.Controls.Add(pb) self.Controls.Add(AboutInfo())
def __init__(self, name, rename): Form.__init__(self) title = "Name Tab" if rename: title = "Rename Tab" self.Text = title self.Size = Size(170, 85) self.FormBorderStyle = FormBorderStyle.FixedDialog self.ShowInTaskbar = False self.Padding = Padding(5) self.initialiseTextBox(name) self.initialiseButtons()
def __init__(self, currentProject=None): Form.__init__(self) self.ClientSize = Size(350, 250) self.Text = "Choose Project" self.Icon = Icon(UIGlobal.ApplicationIcon) self.projectName = currentProject self.projectList = ProjectList(currentProject) self.projectList.SetActivatedHandler(self.__OnProjectActivated) self.Load += self.__OnLoad self.Controls.Add(self.projectList)
def __init__(self, cm, mm, currentCollection): Form.__init__(self) self.ClientSize = Size(600, 600) self.Text = "Collections Manager" self.Icon = Icon(UIGlobal.ApplicationIcon) self.activatedCollection = None self.cmPanel = CollectionsManagerUI(cm, mm, currentCollection) self.cmPanel.SetActivatedHandler(self.__OnCollectionActivated) self.Load += self.__OnLoad self.Controls.Add(self.cmPanel) self.FormClosing += self.__OnFormClosing
def testRemoveInternalCallHandler(self): """Test remove on an event sink implemented w/internalcall.""" object = EventTest() def h(sender, args): pass object.PublicEvent += h object.PublicEvent -= h from System.Windows.Forms import Form f = Form() f.Click += h f.Click -= h f.Dispose()
def __init__(self, currentDatabase=None): Form.__init__(self) self.ClientSize = Size(300, 250) self.Text = "Choose Database" self.Icon = Icon(UIGlobal.ApplicationIcon) self.databaseName = currentDatabase self.databaseList = DatabaseList(currentDatabase) self.databaseList.SetActivatedHandler(self.__OnDatabaseActivated) self.Load += self.__OnLoad self.Controls.Add(self.databaseList)
def __init__(self): Form.__init__(self) self.Text = 'stutter' self.Height = self.INITIAL_HEIGHT self.Width = self.INITIAL_WIDTH self.postTextBox = TextBox() self.postTextBox.Multiline = True self.postButton = Button() self.postButton.Text = "Post" self.friendsListBox = ListBox() self._addMenu() self._layout()
def __init__(self): Form.__init__(self) self.Text = 'stutter' self.Height = self.INITIAL_HEIGHT self.Width = self.INITIAL_WIDTH self.postTextBox = TextBox() self.postTextBox.Multiline = True # Practical 1: Create a 'Post' button # store it in member 'postButton' self.friendsListBox = ListBox() self._addMenu() self._layout()
def test_databinding_auto(self): import System.Windows.Forms as SWF class Form(SWF.Form): 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 = True grid.DataSource = people grid.Dock = SWF.DockStyle.Fill self.grid = grid self.Controls.Add(grid) form = Form() def close_form(): while not form.Visible: System.Threading.Thread.Sleep(100) System.Threading.Thread.Sleep(1000) for i in xrange(len(SAMPLE_DATA)): row = form.grid.Rows[i] self.assertEqual(int(row.Cells[0].FormattedValue), SAMPLE_DATA[i][1]) self.assertEqual(row.Cells[1].FormattedValue, SAMPLE_DATA[i][0]) self.assertEqual(row.Cells[3].FormattedValue, SAMPLE_DATA[i][2]) form.Close() th = System.Threading.Thread(System.Threading.ThreadStart(close_form)) th.Start() SWF.Application.Run(form)
def __init__(self): Form.__init__(self) self.Text = 'MultiDoc Editor' self.MinimumSize = Size(150, 150) tab = self.tabControl = TabControl() self.tabControl.Dock = DockStyle.Fill self.tabControl.Alignment = TabAlignment.Bottom self.Controls.Add(self.tabControl) doc = self.document = Document() self.tabController = TabController(tab, doc) self.initialiseCommands() self.initialiseToolbar() self.initialiseMenus()
def test_databinding_manual(): class Form(SWF.Form): 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) form = Form() def close_form(): while not form.Visible: System.Threading.Thread.Sleep(100) System.Threading.Thread.Sleep(1000) for i in range(len(SAMPLE_DATA)): row = form.grid.Rows[i] AreEqual(row.Cells[0].FormattedValue, SAMPLE_DATA[i][0]) AreEqual(int(row.Cells[1].FormattedValue), SAMPLE_DATA[i][1]) AreEqual(row.Cells[2].FormattedValue, SAMPLE_DATA[i][2]) form.Close() th = System.Threading.Thread(System.Threading.ThreadStart(close_form)) th.Start() SWF.Application.Run(form)
class ClrForm(object): def __init__(self, width=320, height=240, setup=None, teardown=None): """ Creates a .NET Windows Form instance. :param width: Width of the window :param height: Height of the window :param setup: Function callback to call when the form has been created :param tearmdown: Function delegate to assign to the Form's Closing event """ from System.Windows.Forms import Application, Form from System.Drawing import Size self.form = Form(Text="muFAT Test", Size=Size(width, height), MinimizeBox=False, MaximizeBox=False, TopMost=True) self.hwnd = self.form.Handle if setup is not None: setup.__call__() if teardown is not None: self.form.Closing += teardown else: self.form.Closing += self.__exit__ if hasattr(self, 'resized'): self.form.ResizeEnd += self.resized def __enter__(self): """ Override this function to specify what happens when the form is initialized """ return self def __exit__(self, *args): """ Override this function to specify what happens when the form is closed or closing. """ pass def show(self): self.form.ShowDialog() def close(self): self.form.Close()
def OnFormClosing(self, args): # Overridden to make sure that we write out our persistent size/location # changes (if there were any) and do any other cleanup needed before # shutting down this window. if self.__bounds_changed: self.__save_bounds() self.Load -= self.__install_persistent_bounds Form.OnFormClosing(self, args)
def __init__(self, imagePath): Form.__init__(self) self.Width = 346 self.Height = 215 self.images = dict((name, loadImage(imagePath, name + '.jpg')) for name in ('pycon', 'andrzej', 'michael', 'christian')) self.pictureBox = PictureBox() self.pictureBox.Parent = self self.pictureBox.Location = Point(234, 12) self.pictureBox.TabStop = False self.switchImage("pycon") self.mainText = Label() self.mainText.Parent = self self.mainText.AutoSize = True self.mainText.Location = Point(12, 12); self.mainText.Text = ("Tabbed Image Viewer\r\n\r\nWritten for PyCon 2007\r\n" "Using IronPython and Windows Forms\r\n\r\nBy:") self.addNameLabel("Andrzej Krzywda", "andrzej", Point(36, 90)) self.addNameLabel("Christian Muirhead", "christian", Point(36, 105)) self.addNameLabel("Michael Foord", "michael", Point(36, 120)) versionLabel = Label() versionLabel.Parent = self versionLabel.AutoSize = True versionLabel.Location = Point(12, 151) versionLabel.Text = "Version: " + __revision__ self.okButton = Button() self.okButton.Parent = self self.okButton.Text = "OK" self.okButton.Location = Point(251, 146) self.okButton.Click += self.onOK self.AcceptButton = self.okButton self.Text = "About" self.FormBorderStyle = FormBorderStyle.FixedDialog self.MinimizeBox = False self.MaximizeBox = False
def thread_proc(): try: global dispatcher global are # Create the dummy control, and show then hide it to get Windows Forms # to initialize it. dispatcher = Form(Size=Size(0, 0)) dispatcher.Show() dispatcher.Hide() # Signal that the thread running thread_proc is ready for the main # thread to send input to it. are.Set() # Start the message loop. Application.Run() finally: # In case thread_proc's thread dies, restore the default IronPython # console execution behavior. clr.SetCommandDispatcher(None)
def EditValue(self, context, provider, value) : service = provider.GetService(clr.GetClrType(IWindowsFormsEditorService)) if service != None : from System.Windows.Forms import Form, TextBox, FormBorderStyle, DockStyle, DialogResult tb = TextBox() tb.Multiline = True tb.Text = value f = Form() f.Controls.Add(tb) f.FormBorderStyle = FormBorderStyle.None f.TopLevel = False tb.Dock = DockStyle.Fill service.DropDownControl(f) value = tb.Text return value
def popup(self): self.form = Form() self.form.Text = "Credential Check" self.form.MaximizeBox = False self.form.MinimizeBox = False self.form.Width = 300 self.form.Height = 180 self.form.Icon = Icon.ExtractAssociatedIcon(self.path) or None self.form.StartPosition = FormStartPosition.CenterScreen self.form.FormBorderStyle = FormBorderStyle.FixedDialog self.form.TopMost = True self.valButton = Button() self.valButton.Text = "OK" self.valButton.Location = Point(70, 110) self.valButton.Click += EventHandler(self.SubmitHandler) self.canButton = Button() self.canButton.Text = "Cancel" self.canButton.Location = Point(150, 110) self.canButton.Click += EventHandler(self.CancelButtonHandler) self.tbox = Label() self.tbox.Text = "Recent system administrative changes require Windows credentials to access {0}. \nThis security check is only required once.\n\nEnter your Windows password for validation:".format(self.name) self.tbox.Location = Point(10, 10) self.tbox.Width = 280 self.tbox.Height = 100 self.tbox.Font = Font("Arial", 8, FontStyle.Bold) self.inpBox = TextBox() self.inpBox.AcceptsReturn = True self.inpBox.Location = Point(13, 80) self.inpBox.Width = 250 self.inpBox.UseSystemPasswordChar = True self.form.AcceptButton = self.valButton self.form.CancelButton = self.canButton self.form.Controls.Add(self.valButton) self.form.Controls.Add(self.canButton) self.form.Controls.Add(self.inpBox) self.form.Controls.Add(self.tbox) self.form.ActiveControl = self.tbox self.form.FormClosing += FormClosingEventHandler(self.CancelHandler) self.form.ShowDialog()
def ShowDialog(self, controller, title, text): # set controller self.controller = controller # create confirmation boolean -- True means the user wants to save # the stimulus settings and stop the currently running stimulation. self.confirmation = False # create the form self.dialog_window = Form() self.dialog_window.AutoSize = True self.dialog_window.Width = 400 self.dialog_window.MaximumSize = Size(400, 225) self.dialog_window.StartPosition = FormStartPosition.CenterScreen self.dialog_window.Text = title self.dialog_window.FormBorderStyle = FormBorderStyle.FixedSingle # create the main panel self.panel = FlowLayoutPanel() self.panel.Parent = self.dialog_window self.panel.BackColor = DIALOG_COLOR self.panel.Dock = DockStyle.Top self.panel.Padding = Padding(10, 10, 0, 10) self.panel.FlowDirection = FlowDirection.TopDown self.panel.WrapContents = False self.panel.AutoSize = True self.panel.Font = BODY_FONT # add the dialog text dialog_label = Label() dialog_label.Parent = self.panel dialog_label.Text = text dialog_label.Width = self.panel.Width dialog_label.AutoSize = True dialog_label.Margin = Padding(0, 5, 0, 0) # add button panel self.add_button_panel() # show the dialog self.dialog_window.ShowDialog() # return the exp name return self.confirmation
def __init__(self): Form.__init__(self) self.Text = 'MultiDoc Editor' self.MinimumSize = Size(150, 150) self.iconPath = Path.Combine(executableDirectory, 'icons') self.Icon = self.loadImage('copy_clipboard_16.dat') tab = self.tabControl = TabControl() self.tabControl.Dock = DockStyle.Fill self.tabControl.Alignment = TabAlignment.Bottom self.Controls.Add(self.tabControl) self.tabController = TabController(tab) self.initialiseCommands() self.initialiseToolbar() self.initialiseMenus() self.initialiseObservers() self.document = Document()
def __init__(self): Form.__init__(self) self.ClientSize = Size(700, 500) self.Text = "FLExTools " + Version.number ## Get configurables - current DB, current collection self.configuration = ConfigStore(FTPaths.CONFIG_PATH) self.collectionsManager = FTCollections.CollectionsManager() self.__LoadModules() try: listOfModules = self.collectionsManager.ListOfModules( self.configuration.currentCollection) except FTCollections.FTC_NameError: # The configuration value is bad... self.configuration.currentCollection = None listOfModules = [] self.Icon = Icon(UIGlobal.ApplicationIcon) self.InitMainMenu() self.progressPercent = -1 self.progressMessage = None self.StatusBar = StatusBar() self.__UpdateStatusBar() self.UIPanel = FTPanel(self.moduleManager, self.configuration.currentProject, listOfModules, self.__LoadModules, self.__ProgressBar ) self.UIPanel.SetChooseProjectHandler(self.ChooseProject) self.UIPanel.SetEditCollectionsHandler(self.EditCollections) self.FormClosed += self.__OnFormClosed self.Controls.Add(self.UIPanel) self.Controls.Add(self.StatusBar)
def __init__(self): Form.__init__(self) self.ClientSize = Size(700, 500) self.Text = "FLExTools " + Version.number ## Get configurables - current DB, current collection self.configuration = CDFConfigStore(FTPaths.CONFIG_PATH) self.collectionsManager = FTCollections.CollectionsManager() self.__LoadModules() try: listOfModules = self.collectionsManager.ListOfModules( self.configuration.currentCollection) except FTCollections.FTC_NameError: # The configuration value is bad... self.configuration.currentCollection = None listOfModules = [] self.Icon = Icon(UIGlobal.ApplicationIcon) self.InitMainMenu() self.progressPercent = -1 self.progressMessage = None self.StatusBar = StatusBar() self.__UpdateStatusBar() self.UIPanel = FTPanel(self.moduleManager, self.configuration.currentDatabase, listOfModules, self.__LoadModules, self.__ProgressBar ) self.UIPanel.SetChooseDatabaseHandler(self.ChooseDatabase) self.UIPanel.SetEditCollectionsHandler(self.EditCollections) self.FormClosed += self.__OnFormClosed self.Controls.Add(self.UIPanel) self.Controls.Add(self.StatusBar)
def popup(text): form = Form() form.StartPosition = FormStartPosition.CenterScreen form.Width = 300 form.Height = 300 form.Text = 'Mais pas tout le temps' label = Label() label.Text = text label.Width = 300 label.Height = 300 label.Parent = form form.ShowDialog()
def LocateYTID(): """Function to find YouTube Channel ID!""" f = Form() f.Text = "YouTube Advanced Account Settings" f.Width = 630 f.Height = 630 wb = WebBrowser() wb.ScriptErrorsSuppressed = True wb.Navigate("https://www.youtube.com/account_advanced") wb.Dock = DockStyle.Fill f.Controls.Add(wb) f.ShowDialog()
def __init__(self): c = Form() def attached(source, args): print('my_handler called!') def detached(source, args): print('Detatched') a = clr.UsbFsm100ServerClass(c.Handle) a.Attached += attached a.Detached += detached self.usb = a Application.Run(c) self.threshold = 10000.
def __init__(self): c = Form() self.connected = False def attached(source, args): print('Connected to splicer') self.connected = True def detached(source,args): self.connected = False print('Disconnected from splicer') a = clr.UsbFsm100ServerClass(c.Handle ) a.Attached += attached a.Detached += detached self.usb = a self.c = c #c.Visible=False #c.Show() #c.Close() Application.DoEvents() #<--- BOO YA #Application.Run(c) print('g') #c.Close() #a.close() self.usb.Clear() self.threshold = 2000. self.lastZLZR = ('0','0') self.lastarc = 0,0 self.lastmove = self.readZLZR() self.lastvelocity = (0.,0.) #important for moving fast self.lastZLZR = self.readZLZR() self.lastarc = (0,0) self.immodeSize = {1:np.array((640,480)),2:np.array((640,480)),3:np.array((486,364))} self.exposure = 0.
def __initialize(self): ''' intial configuration for new instances of this class ''' Form.__init__(self) self.StartPosition = FormStartPosition.Manual self.Load += self.__install_persistent_bounds
self.FormClosing += self.__OnFormClosing def __OnLoad(self, sender, event): self.cmPanel.SetFocusOnCurrentCollection() def __OnCollectionActivated(self, collectionName): # make selection available to caller self.activatedCollection = collectionName self.Close() def __OnFormClosing(self, sender, event): self.activatedCollection = self.cmPanel.currentCollection self.cmPanel.SaveAll() # ------------------------------------------------------------------ if __name__ == "__main__": collections = FTCollections.CollectionsManager() mm = FTModules.ModuleManager() mm.LoadAll() cmPanel = CollectionsManagerUI(collections, mm, None) form = Form() form.ClientSize = Size(600, 550) form.Text = "Test of Collections Manager" form.Controls.Add(cmPanel) Application.Run(form)
from System.Windows.Forms import Form, Button, Application from PythonSharp.Utilities import ObjectUtilities f = Form() f.Text = "PythonSharp Form" b = Button() b.Text = "Hello" b.Width = 150 b.Height = 50 f.Controls.Add(b) def click(sender, event): print("Click") ObjectUtilities.AddHandler(b, "Click", click, locals()) Application.Run(f)
import clr clr.AddReference('System.Windows.Forms') from System.Windows.Forms import Application, Form form = Form() form.Text = "Hello World" Application.Run(form)
import clr clr.AddReference('System.Windows.Forms') clr.AddReference('System.Drawing') from System.Windows.Forms import ( Application, Form, FormBorderStyle, Label ) from System.Drawing import ( Color, Font, FontStyle, Point ) form = Form() form.Text = "Hello World" form.FormBorderStyle = FormBorderStyle.Fixed3D form.Height = 150 newFont = Font("Verdana", 16, FontStyle.Bold | FontStyle.Italic) label = Label() label.AutoSize = True label.Text = "My Hello World Label" label.Font = newFont label.BackColor = Color.Aquamarine label.ForeColor = Color.DarkMagenta label.Location = Point(10, 50) form.Controls.Add(label) Application.Run(form)
##################################################################################### # # Copyright (c) Microsoft Corporation. All rights reserved. # # This source code is subject to terms and conditions of the Apache License, Version 2.0. A # copy of the license can be found in the License.html file at the root of this distribution. If # you cannot locate the Apache License, Version 2.0, please send an email to # [email protected]. By using this source code in any fashion, you are agreeing to be bound # by the terms of the Apache License, Version 2.0. # # You must not remove this notice, or any other, from this software. # # ##################################################################################### import clr clr.AddReference("System.Windows.Forms") from System.Windows.Forms import Form form = Form(Text="(Compiled WinForms) Hello World") form.ShowDialog()
import sys import clr clr.AddReference('System.Drawing') clr.AddReference('System.Windows.Forms') clr.AddReference('Microsoft.Ink, Version=1.7.2600.2180, Culture=neutral, PublicKeyToken=31bf3856ad364e35') from System.Drawing import Font, Color from System.Windows.Forms import (Form, DockStyle, Panel, TextBox, Button, SplitContainer, Orientation) from Microsoft.Ink import InkOverlay f = Form() f.Text = 'InkOverlay Example' btn = Button() btn.Text = 'Erase' pnl = Panel() pnl.BackColor = Color.Khaki overlay = InkOverlay(pnl) overlay.Enabled = True tb = TextBox() tb.Font = Font('serif', 20) tb.Multiline = True sc = SplitContainer() sc.SplitterWidth = 10 sc.Orientation = Orientation.Horizontal # Layout f.Width = 600
def __init__(self): Form.__init__(self) self.Text = "Tai-Pan Chart" self.Name = "Tai-Pan Chart" self.Width = 640 self.Height = 480
def draw(self, show=True, filename=None, update=False, usecoords=False): """Create a 2D depiction of the molecule. Optional parameters: show -- display on screen (default is True) filename -- write to file (default is None) update -- update the coordinates of the atoms to those determined by the structure diagram generator (default is False) usecoords -- don't calculate 2D coordinates, just use the current coordinates (default is False) Tkinter and Python Imaging Library are required for image display. """ if update: mol = self.Mol else: mol = self.Mol.clone() if not usecoords: mol.layout() if show or filename: renderer = IndigoRenderer(indigo) indigo.setOption("render-output-format", "png") indigo.setOption("render-margins", 10, 10) indigo.setOption("render-coloring", "True") indigo.setOption("render-image-size", 300, 300) indigo.setOption("render-background-color", "1.0, 1.0, 1.0") if self.title: indigo.setOption("render-comment", self.title) if filename: filedes = None else: filedes, filename = tempfile.mkstemp() renderer.renderToFile(mol, filename) if show: if sys.platform[:4] == "java": image = javax.imageio.ImageIO.read(java.io.File(filename)) frame = javax.swing.JFrame(visible=1) frame.getContentPane().add(javax.swing.JLabel(javax.swing.ImageIcon(image))) frame.setSize(300,300) frame.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE) frame.show() elif sys.platform[:3] == "cli": if filedes: errormessage = ("It is only possible to show the molecule if you " "provide a filename. The reason for this is that I kept " "having problems when using temporary files.") raise RuntimeError(errormessage) form = Form() form.ClientSize = Size(300, 300) form.Text = self.title image = Image.FromFile(filename) box = PictureBox() box.SizeMode = PictureBoxSizeMode.StretchImage box.Image = image box.Dock = DockStyle.Fill form.Controls.Add(box) form.Show() Application.Run(form) else: if not PILtk: errormessage = ("Tkinter or Python Imaging " "Library not found, but is required for image " "display. See installation instructions for " "more information.") raise ImportError, errormessage root = tk.Tk() root.title((hasattr(self, "title") and self.title) or self.__str__().rstrip()) frame = tk.Frame(root, colormap="new", visual='truecolor').pack() image = PIL.open(filename) imagedata = PILtk.PhotoImage(image) label = tk.Label(frame, image=imagedata).pack() quitbutton = tk.Button(root, text="Close", command=root.destroy).pack(fill=tk.X) root.mainloop() if filedes: os.close(filedes) os.remove(filename)
import clr clr.AddReference('System.Windows.Forms') from System.Windows.Forms import Application, Form, Label form = Form(Text="Hello World Form") label = Label(Text="Hello World!") form.Controls.Add(label) Application.Run(form)
def info(self, sender, event): newform = SimpleTextBoxForm() #run rail form Form.ShowDialog(newform)
def __init__(self, title): Form.__init__(self) self.Text = title
def __init__(self): Form.__init__(self)
# ------------------------------------------------------------------ class ModuleInfoDialog(Form): def __init__(self, docs): Form.__init__(self) self.ClientSize = Size(400, 400) self.Text = "Module Details" self.Icon = Icon(UIGlobal.ApplicationIcon) infoPane = ModuleInfoPane() infoPane.SetFromDocs(docs) self.Controls.Add(infoPane) # ------------------------------------------------------------------ if __name__ == "__main__": import FTModules mm = FTModules.ModuleManager() mm.LoadAll() mb = ModuleBrowser(mm) form = Form() form.ClientSize = Size(500, 300) form.Text = "Test of Module Browser" form.Controls.Add(mb) Application.Run(form)
def main(): f=Form() f.Text="HelloIronPython" Application.Run(f)