Skip to content
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

remove Python2 hybridation code #2540

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
29 changes: 15 additions & 14 deletions samples/printing/printing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import print_function
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably don't need this...we can drop support for Python 2.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so let's remove all sixusage ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and the vendored copy living as wx/lib/pubsub/py2and3.py


import wx
from six import print_
import os

FONTSIZE = 10
Expand Down Expand Up @@ -180,7 +181,7 @@ def OnPageSetup(self, evt):
data = dlg.GetPageSetupData()
self.pdata = wx.PrintData(data.GetPrintData()) # force a copy
self.pdata.SetPaperId(data.GetPaperId())
#print_("paperID %r, paperSize %r" % (self.pdata.GetPaperId(), self.pdata.GetPaperSize()))
#print("paperID %r, paperSize %r" % (self.pdata.GetPaperId(), self.pdata.GetPaperSize()))
self.margins = (data.GetMarginTopLeft(),
data.GetMarginBottomRight())
dlg.Destroy()
Expand Down Expand Up @@ -226,20 +227,20 @@ def OnPrintTest(self, evt):
dlg = wx.PrintDialog(self, data)
if dlg.ShowModal() == wx.ID_OK:
data = dlg.GetPrintDialogData()
print_()
print_("GetFromPage:", data.GetFromPage())
print_("GetToPage:", data.GetToPage())
print_("GetMinPage:", data.GetMinPage())
print_("GetMaxPage:", data.GetMaxPage())
print_("GetNoCopies:", data.GetNoCopies())
print_("GetAllPages:", data.GetAllPages())
print_("GetSelection:", data.GetSelection())
print_("GetCollate:", data.GetCollate())
print_("GetPrintToFile:", data.GetPrintToFile())
print()
print("GetFromPage:", data.GetFromPage())
print("GetToPage:", data.GetToPage())
print("GetMinPage:", data.GetMinPage())
print("GetMaxPage:", data.GetMaxPage())
print("GetNoCopies:", data.GetNoCopies())
print("GetAllPages:", data.GetAllPages())
print("GetSelection:", data.GetSelection())
print("GetCollate:", data.GetCollate())
print("GetPrintToFile:", data.GetPrintToFile())

self.pdata = wx.PrintData(data.GetPrintData())
print_()
print_("GetPrinterName:", self.pdata.GetPrinterName())
print()
print("GetPrinterName:", self.pdata.GetPrinterName())

dlg.Destroy()

Expand Down
11 changes: 6 additions & 5 deletions samples/roses/clroses.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@
# ideal Roses program should be, however, callers are welcome to assert their
# independence, override defaults, ignore features, etc.

from __future__ import print_function

from math import sin, cos, pi
from six import print_

# Rose class knows about:
# > Generating points and vectors (returning data as a list of points)
Expand Down Expand Up @@ -151,7 +152,7 @@ def gcd(self, a, b):
# update parameters or stop.
def restart(self):
if self.verbose:
print_('restart: int_state', self.int_state, 'cmd_state', self.cmd_state)
print('restart: int_state', self.int_state, 'cmd_state', self.cmd_state)
try:
tmp = self.sin_table[0]
except:
Expand Down Expand Up @@ -192,7 +193,7 @@ def resize(self, size, delay):
# before initialization is done.
def repaint(self, delay):
if self.int_state != self.INT_RESIZE:
# print_('repaint after', delay)
# print('repaint after', delay)
self.int_state = self.INT_RESIZE
self.AppCancelTimer()
self.AppAfter(delay, self.clock)
Expand Down Expand Up @@ -264,7 +265,7 @@ def cmd_step(self):
# roses is 0.)
def clock(self):
if self.int_state == self.INT_IDLE:
# print_('clock called in idle state')
# print('clock called in idle state')
delay = 0
elif self.int_state == self.INT_DRAW:
line, run = self.roselet()
Expand Down Expand Up @@ -295,7 +296,7 @@ def clock(self):

if delay == 0:
if self.verbose:
print_('clock: going idle from state', self.int_state)
print('clock: going idle from state', self.int_state)
else:
self.AppAfter(delay, self.clock)

Expand Down
39 changes: 20 additions & 19 deletions samples/roses/wxroses.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@
# control the display (without blocking the user's control) would be pretty
# straightforward.

from __future__ import print_function

import wx
import clroses
import wx.lib.colourselect as cs
from six import print_

# Class SpinPanel creates a control that includes both a StaticText widget
# which holds the the name of a parameter and a SpinCtrl widget which
Expand Down Expand Up @@ -109,7 +110,7 @@ def OnSpin(self, event):
name = self.st.GetLabel()
value = self.sc.GetValue()
if verbose:
print_('OnSpin', name, '=', value)
print('OnSpin', name, '=', value)
self.callback(name, value) # Call MyFrame.OnSpinback to call clroses


Expand Down Expand Up @@ -372,10 +373,10 @@ def makeSP(name, labels, statictexts = None):
h = max(600, fh) # Change 600 to desired minimum size
w = h + fw - rw
if verbose:
print_('rose panel size', (rw, rh))
print_('side panel size', (sw, sh))
print_(' frame size', (fw, fh))
print_('Want size', (w,h))
print('rose panel size', (rw, rh))
print('side panel size', (sw, sh))
print(' frame size', (fw, fh))
print('Want size', (w,h))
self.SetSize((w, h))
self.SupplyControlValues() # Ask clroses to tell us all the defaults
self.Show()
Expand All @@ -386,25 +387,25 @@ def makeSP(name, labels, statictexts = None):
# Go/Stop button
def OnGoStop(self, event):
if verbose:
print_('OnGoStop')
print('OnGoStop')
self.cmd_go_stop()

# Redraw/Redraw
def OnRedraw(self, event):
if verbose:
print_('OnRedraw')
print('OnRedraw')
self.cmd_redraw()

# Backward/Reverse
def OnBackward(self, event):
if verbose:
print_('OnBackward')
print('OnBackward')
self.cmd_backward()

# Forward/Skip
def OnForward(self, event):
if verbose:
print_('OnForward')
print('OnForward')
self.cmd_step()


Expand All @@ -415,7 +416,7 @@ def OnForward(self, event):

def AppClear(self):
if verbose:
print_('AppClear: clear screen')
print('AppClear: clear screen')
self.rose_panel.Clear()

def AppCreateLine(self, line):
Expand Down Expand Up @@ -467,23 +468,23 @@ def AppCmdLabels(self, labels):
# Method to provide a single callback after some amount of time.
def AppAfter(self, msec, callback):
if self.timer_callback:
print_('AppAfter: timer_callback already set!')
# print_('AppAfter:', callback)
print('AppAfter: timer_callback already set!')
# print('AppAfter:', callback)
self.timer_callback = callback
self.timer.Start(msec, True)

# Method to cancel something we might be waiting for but have lost
# interest in.
def AppCancelTimer(self):
self.timer.Stop()
# print_('AppCancelTimer')
# print('AppCancelTimer')
self.timer_callback = None

# When the timer happens, we come here and jump off to clroses internal code.
def OnTimer(self, evt):
callback = self.timer_callback
self.timer_callback = None
# print_('OnTimer,', callback)
# print('OnTimer,', callback)
if callback:
callback() # Often calls AppAfter() and sets the callback
else:
Expand All @@ -502,7 +503,7 @@ def TriggerRedraw(self):
# Called when data in spin boxes changes.
def OnSpinback(self, name, value):
if verbose:
print_('OnSpinback', name, value)
print('OnSpinback', name, value)
if name == 'Style':
self.SetStyle(value)
elif name == 'Sincr':
Expand Down Expand Up @@ -530,7 +531,7 @@ def OnSpinback(self, name, value):
elif name == 'Delay':
self.SetWaitDelay(value)
else:
print_('OnSpinback: Don\'t recognize', name)
print('OnSpinback: Don\'t recognize', name)

verbose = 0 # Need some command line options...
spin_panels = {} # Hooks to get from rose to panel labels
Expand All @@ -539,6 +540,6 @@ def OnSpinback(self, name, value):
app = wx.App(False)
MyFrame()
if verbose:
print_('spin_panels', list(spin_panels))
print_('ctrl_buttons', list(ctrl_buttons))
print('spin_panels', list(spin_panels))
print('ctrl_buttons', list(ctrl_buttons))
app.MainLoop()
14 changes: 7 additions & 7 deletions samples/simple/events.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from __future__ import print_function

import wx
from six import print_

print_(wx.version())
#import os; print_('PID:', os.getpid()); raw_input('Ready to start, press enter...')
print(wx.version())
#import os; print('PID:', os.getpid()); raw_input('Ready to start, press enter...')


class MyFrame(wx.Frame):
Expand All @@ -13,21 +13,21 @@ def __init__(self, *args, **kw):
wx.CallAfter(self.after, 1, 2, 3)

def after(self, a, b, c):
print_('Called via wx.CallAfter:', a, b, c)
print('Called via wx.CallAfter:', a, b, c)

def onSize(self, evt):
print_(repr(evt.Size))
print(repr(evt.Size))
evt.Skip()

class MyApp(wx.App):
def OnInit(self):
print_('OnInit')
print('OnInit')
frm = MyFrame(None, title="Hello with Events", size=(480,360))
frm.Show()
return True

def OnExit(self):
print_('OnExit')
print('OnExit')
return 0

app = MyApp()
Expand Down
5 changes: 3 additions & 2 deletions wx/lib/pubsub/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
:license: BSD, see LICENSE_BSD_Simple.txt for details.
"""

from __future__ import print_function

import sys
from .. import py2and3

__all__ = ('printImported', 'StructMsg', 'Callback', 'Enum' )

Expand All @@ -16,7 +17,7 @@ def printImported():
"""Output a list of pubsub modules imported so far"""
ll = sorted([mod for mod in sys.modules if mod.find('pubsub') >= 0])

py2and3.print_('\n'.join(ll))
print('\n'.join(ll))


class StructMsg:
Expand Down
4 changes: 3 additions & 1 deletion wx/lib/pubsub/utils/xmltopicdefnprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
:license: BSD, see LICENSE_BSD_Simple.txt for details.
"""

from __future__ import print_function

__author__ = 'Joshua R English'
__revision__ = 6
__date__ = '2013-07-27'
Expand Down Expand Up @@ -80,7 +82,7 @@ def _get_elem(elem):
try:
elem = ET.fromstring(elem)
except:
py2and3.print_("Value Error", elem)
print("Value Error", elem)
raise ValueError("Cannot convert to element")
return elem

Expand Down
24 changes: 13 additions & 11 deletions wx/tools/pywxrc.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
-o, --output output filename, or - for stdout
"""

from __future__ import print_function

import sys, os, getopt, glob, re
import xml.dom.minidom as minidom
from six import print_, byte2int
from six import byte2int

#----------------------------------------------------------------------

Expand Down Expand Up @@ -286,7 +288,7 @@ def MakePythonModule(self, inputFiles, outputFilename,
gettextStrings += self.FindStringsInNode(resourceDocument.firstChild)

# now write it all out
print_(self.templates.FILE_HEADER, file=outputFile)
print(self.templates.FILE_HEADER, file=outputFile)

# Note: Technically it is not legal to have anything other
# than ascii for class and variable names, but since the user
Expand All @@ -295,23 +297,23 @@ def MakePythonModule(self, inputFiles, outputFilename,
# later when they try to run the program.
if subclasses:
subclasses = self.ReplaceBlocks(u"\n".join(subclasses))
print_(subclasses, file=outputFile)
print(subclasses, file=outputFile)
if classes:
classes = self.ReplaceBlocks(u"\n".join(classes))
print_(classes, file=outputFile)
print(classes, file=outputFile)

print_(self.templates.INIT_RESOURE_HEADER, file=outputFile)
print(self.templates.INIT_RESOURE_HEADER, file=outputFile)
if embedResources:
print_(self.templates.PREPARE_MEMFS, file=outputFile)
print(self.templates.PREPARE_MEMFS, file=outputFile)
resources = u"\n".join(resources)
print_(resources, file=outputFile)
print(resources, file=outputFile)

if generateGetText:
# gettextStrings is a list of unicode strings as returned by ConvertText
conversions = [u' _("%s")' % s for s in gettextStrings]
conversion_block = u"\n".join(conversions)
conversion_func = self.templates.GETTEXT_DUMMY_FUNC % conversion_block
print_(conversion_func, file=outputFile)
print(conversion_func, file=outputFile)

#-------------------------------------------------------------------

Expand All @@ -327,7 +329,7 @@ def MakeGetTextOutput(self, inputFiles, outputFilename):
strings = self.FindStringsInNode(resource)
# strings is a list of unicode strings as returned by ConvertText
strings = ['_("%s");' % s for s in strings]
print_("\n".join(strings), file=outputFile)
print("\n".join(strings), file=outputFile)

#-------------------------------------------------------------------

Expand Down Expand Up @@ -940,10 +942,10 @@ def main(args=None):


except IOError as exc:
print_("%s." % str(exc), file=sys.stderr)
print("%s." % str(exc), file=sys.stderr)
else:
if outputFilename != "-":
print_("Resources written to %s." % outputFilename, file=sys.stderr)
print("Resources written to %s." % outputFilename, file=sys.stderr)

if __name__ == "__main__":
main(sys.argv[1:])
Loading