Skip to content

Format and White-spacing #205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static void Main(string[] args)
```
outputs:
```
1.0
1.0
-0.958924274663
-0.6752620892
float64
Expand Down
15 changes: 3 additions & 12 deletions demo/helloform.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
# ===========================================================================
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
# ===========================================================================

import clr

SWF = clr.AddReference("System.Windows.Forms")
print (SWF.Location)
import System.Windows.Forms as WinForms
Expand All @@ -31,7 +23,7 @@ def __init__(self):
self.button.Size = Size(820, 20)
self.button.TabIndex = 2
self.button.Text = "Click Me!"

# Register the event handler
self.button.Click += self.button_Click

Expand All @@ -41,7 +33,7 @@ def __init__(self):
self.textbox.TabIndex = 1
self.textbox.Size = Size(1260, 40)
self.textbox.Location = Point(160, 24)

# Add the controls to the form
self.AcceptButton = self.button
self.Controls.Add(self.button);
Expand All @@ -66,4 +58,3 @@ def main():

if __name__ == '__main__':
main()

21 changes: 5 additions & 16 deletions demo/splitter.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
# ===========================================================================
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
# ===========================================================================

import clr
import System.Windows.Forms as WinForms
from System.Drawing import Color, Size, Point
Expand All @@ -28,7 +19,6 @@ def __init__(self):
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
Expand All @@ -48,14 +38,14 @@ def __init__(self):

# 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

Expand All @@ -67,7 +57,7 @@ def __init__(self):

# 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)
Expand All @@ -87,12 +77,11 @@ def Dispose(self):
WinForms.Form.Dispose(self)



def main():
app = Splitter()
WinForms.Application.Run(app)
app.Dispose()


if __name__ == '__main__':
main()

48 changes: 12 additions & 36 deletions demo/wordpad.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
# ===========================================================================
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
# ===========================================================================

import clr
import System.Windows.Forms as WinForms
from System.Threading import Thread, ThreadStart, ApartmentState
Expand Down Expand Up @@ -60,18 +51,16 @@ def InitializeComponent(self):
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
Expand All @@ -83,7 +72,7 @@ def InitializeComponent(self):
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
Expand Down Expand Up @@ -112,7 +101,6 @@ def InitializeComponent(self):

self.fileMenu.MenuItems.AddRange(items)


# ===================================================================
# Edit menu
# ===================================================================
Expand All @@ -134,7 +122,7 @@ def InitializeComponent(self):
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
Expand Down Expand Up @@ -163,7 +151,6 @@ def InitializeComponent(self):

self.editMenu.MenuItems.AddRange(items)


# ===================================================================
# Format Menu
# ===================================================================
Expand All @@ -184,11 +171,10 @@ def InitializeComponent(self):

self.formatMenu.MenuItems.AddRange(items)


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

self.menuHelpAbout.Text = "&About"
self.menuHelpAbout.Index = 0
self.menuHelpAbout.Click += self.OnClickHelpAbout
Expand All @@ -210,19 +196,16 @@ def InitializeComponent(self):
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"

Expand All @@ -231,7 +214,6 @@ def InitializeComponent(self):
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
Expand All @@ -244,7 +226,6 @@ def InitializeComponent(self):
def Dispose(self):
self.components.Dispose()
WinForms.Form.Dispose(self)


def OnClickFileNew(self, sender, args):
self.SaveChangesDialog()
Expand All @@ -265,7 +246,6 @@ def OnClickFileExit(self, sender, args):
self.SaveChangesDialog()
self.Close()


def OnClickEditUndo(self, sender, args):
self.richTextBox.Undo()

Expand All @@ -284,7 +264,6 @@ def OnClickEditPaste(self, sender, args):
def OnClickEditSelectAll(self, sender, args):
self.richTextBox.SelectAll()


def OnClickFormatWordWrap(self, sender, args):
value = not self.word_wrap
self.richTextBox.WordWrap = value
Expand All @@ -298,7 +277,6 @@ def OnClickFormatFont(self, sender, args):
def OnClickHelpAbout(self, sender, args):
AboutForm().ShowDialog(self)


def NewDocument(self):
self.doctype = 1
self.richTextBox.Rtf = ''
Expand Down Expand Up @@ -327,7 +305,7 @@ def OpenDocument(self):
stream.Close()

filename = self.filename = filename.lower()

if filename.endswith('.rtf'):
self.richTextBox.Rtf = data
self.doctype = 2
Expand All @@ -345,10 +323,10 @@ def SaveDocument(self):
if self.saveFileDialog.ShowDialog() != WinForms.DialogResult.OK:
return
filename = self.saveFileDialog.FileName

filename = self.filename = filename.lower()
self.Text = 'Python Wordpad - %s' % filename

self.richTextBox.Select(0, 0)

stream = File.OpenWrite(filename)
Expand All @@ -366,17 +344,16 @@ def SaveDocument(self):
def SaveChangesDialog(self):
if self.richTextBox.Modified:
if WinForms.MessageBox.Show(
"Save changes?", "Word Pad",
WinForms.MessageBoxButtons.OK |
WinForms.MessageBoxButtons.YesNo
) == WinForms.DialogResult.Yes:
"Save changes?", "Word Pad",
WinForms.MessageBoxButtons.OK |
WinForms.MessageBoxButtons.YesNo
) == WinForms.DialogResult.Yes:
self.SaveDocument()
return 1
return 0


class AboutForm(WinForms.Form):

def __init__(self):
self.InitializeComponent()

Expand Down Expand Up @@ -406,7 +383,7 @@ def InitializeComponent(self):
self.ClientSize = System.Drawing.Size(300, 150)

self.Controls.AddRange((self.label1, self.btnClose))

self.FormBorderStyle = WinForms.FormBorderStyle.FixedDialog
self.MaximizeBox = 0
self.MinimizeBox = 0
Expand Down Expand Up @@ -435,4 +412,3 @@ def main():

if __name__ == '__main__':
main()

24 changes: 10 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ def _find_msbuild_tool(tool="msbuild.exe", use_windows_sdk=False):


class PythonNET_BuildExt(build_ext):

def build_extension(self, ext):
"""
Builds the .pyd file using msbuild or xbuild.
Expand Down Expand Up @@ -191,7 +190,7 @@ def build_extension(self, ext):
self._build_monoclr(ext)

def _get_manifest(self, build_dir):
if DEVTOOLS == "MsDev" and sys.version_info[:2] > (2,5):
if DEVTOOLS == "MsDev" and sys.version_info[:2] > (2, 5):
mt = _find_msbuild_tool("mt.exe", use_windows_sdk=True)
manifest = os.path.abspath(os.path.join(build_dir, "app.manifest"))
cmd = [mt, '-inputresource:"%s"' % sys.executable, '-out:"%s"' % manifest]
Expand All @@ -209,12 +208,12 @@ def _build_monoclr(self, ext):

# build the clr python module
clr_ext = Extension("clr",
sources=[
"src/monoclr/pynetinit.c",
"src/monoclr/clrmod.c"
],
extra_compile_args=cflags.split(" "),
extra_link_args=libs.split(" "))
sources=[
"src/monoclr/pynetinit.c",
"src/monoclr/clrmod.c"
],
extra_compile_args=cflags.split(" "),
extra_link_args=libs.split(" "))

build_ext.build_extension(self, clr_ext)

Expand All @@ -232,11 +231,10 @@ def _install_packages(self):


class PythonNET_InstallLib(install_lib):

def install(self):
if not os.path.isdir(self.build_dir):
self.warn("'%s' does not exist -- no Python modules to install" %
self.build_dir)
self.build_dir)
return

if not os.path.exists(self.install_dir):
Expand All @@ -249,7 +247,6 @@ def install(self):


class PythonNET_InstallData(install_data):

def run(self):
build_cmd = self.get_finalized_command("build_ext")
install_cmd = self.get_finalized_command("install")
Expand Down Expand Up @@ -350,10 +347,9 @@ def _get_interop_filename():
],
zip_safe=False,
cmdclass={
"build_ext" : PythonNET_BuildExt,
"install_lib" : PythonNET_InstallLib,
"build_ext": PythonNET_BuildExt,
"install_lib": PythonNET_InstallLib,
"install_data": PythonNET_InstallData,
},
setup_requires=setup_requires
)

Loading