Skip to content

Commit 48a712c

Browse files
committed
Merge pull request #1575 from robotframework/HelioGuilherme66-improvements
Helio guilherme66 improvements
2 parents c843738 + 8bd8338 commit 48a712c

File tree

14 files changed

+85
-49
lines changed

14 files changed

+85
-49
lines changed

src/robotide/__init__.py

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,31 +32,30 @@
3232
from string import Template
3333

3434
errorMessageTemplate = Template("""$reason
35-
You need to install wxPython 2.8.12.1 with unicode support to run RIDE.
36-
wxPython 2.8.12.1 can be downloaded from http://sourceforge.net/projects/wxpython/files/wxPython/2.8.12.1/""")
37-
supported_versions = ["2.8"]
35+
You need to install wxPython 2.8.12.1 or 3.0.2 or newer with unicode support \
36+
to run RIDE. wxPython can be downloaded from \
37+
http://sourceforge.net/projects/wxpython/files/wxPython/""")
38+
supported_versions = ["2.8", "3.0"]
3839

3940
try:
4041
import wxversion
4142
from wxversion import VersionError
42-
if sys.platform == 'darwin':
43-
supported_versions.append("2.9")
4443
wxversion.select(supported_versions)
4544
import wx
4645
except ImportError as e:
47-
if "no appropriate 64-bit architecture" in e.message.lower() and \
46+
if "no appropriate 64-bit architecture" in "{0}".format(e).lower() and \
4847
sys.platform == 'darwin':
49-
print "python should be executed in 32-bit mode with wxPython on OSX."
48+
print("python should be executed in 32-bit mode with wxPython on OSX.")
5049
else:
51-
print errorMessageTemplate.substitute(reason="wxPython not found.")
50+
print(errorMessageTemplate.substitute(reason="wxPython not found."))
5251
sys.exit(1)
5352
except VersionError:
54-
print errorMessageTemplate.substitute(reason="Wrong wxPython version.")
53+
print(errorMessageTemplate.substitute(reason="Wrong wxPython version."))
5554
sys.exit(1)
5655

5756
if "ansi" in wx.PlatformInfo:
58-
print errorMessageTemplate.substitute(
59-
reason="wxPython with ansi encoding is not supported")
57+
print(errorMessageTemplate.substitute(reason="wxPython with ansi encoding \
58+
is not supported"))
6059
sys.exit(1)
6160

6261

@@ -67,7 +66,7 @@
6766
def main(*args):
6867
noupdatecheck, debug_console, inpath = _parse_args(args)
6968
if len(args) > 3 or '--help' in args:
70-
print __doc__
69+
print(__doc__)
7170
sys.exit()
7271
try:
7372
_run(inpath, not noupdatecheck, debug_console)
@@ -82,7 +81,7 @@ def _parse_args(args):
8281
return False, False, None
8382
noupdatecheck = '--noupdatecheck' in args
8483
debug_console = '--debugconsole' in args
85-
inpath = args[-1] if args[-1] not in ['--noupdatecheck', '--debugconsole'] \
84+
inpath = args[-1] if args[-1] not in ['--noupdatecheck', '--debugconsole']\
8685
else None
8786
return noupdatecheck, debug_console, inpath
8887

@@ -107,19 +106,17 @@ def _show_old_wxpython_warning_if_needed(parent=None):
107106
if wx.VERSION >= (2, 8, 12, 1):
108107
return
109108
title = 'Please upgrade your wxPython installation'
110-
message = ('RIDE officially supports wxPython 2.8.12.1. '
111-
'Your current version is %s.\n\n'
112-
'Older wxPython versions are known to miss some features used by RIDE. '
113-
'Notice also that wxPython 3.0 is not yet supported.\n\n'
114-
'wxPython 2.8.12.1 packages can be found from\n'
115-
'http://sourceforge.net/projects/wxpython/files/wxPython/2.8.12.1/.'
116-
% wx.VERSION_STRING)
109+
message = ("RIDE officially supports wxPython 2.8.12.1, 3.0.2 and newer \
110+
releases in 3.0 series. Your current version is {0}.\n\n \
111+
Older wxPython versions are known to miss some features used by RIDE.\n \
112+
wxPython 2.8.12.1 packages can be found from\n \
113+
http://sourceforge.net/projects/wxpython/files/wxPython/2.8.12.1/.".format(
114+
wx.VERSION_STRING))
117115
style = wx.ICON_EXCLAMATION
118116
if not parent:
119-
_ = wx.PySimpleApp()
120-
parent = wx.Frame(None, size=(0,0))
117+
_ = wx.App()
118+
parent = wx.Frame(None, size=(0, 0))
121119
wx.MessageDialog(parent, message, title, style).ShowModal()
122120

123-
124121
if __name__ == '__main__':
125122
main(sys.argv[1:])

src/robotide/application/application.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,12 @@ def _get_editor(self):
8888

8989
def _load_data(self):
9090
path = self._initial_path or self._get_latest_path()
91-
if path:
91+
# FIXME: Loading suite on startuup causes segfault in OSX.
92+
if path and not context.IS_MAC:
9293
with self.active_event_loop():
93-
observer = LoadProgressObserver(self.frame)
94-
self._controller.load_data(path, observer)
94+
# FIXME: wxPython3 hack
95+
# observer = LoadProgressObserver(self.frame)
96+
self._controller.load_data(path, None)
9597

9698
def _find_robot_installation(self):
9799
output = utils.run_python_command(

src/robotide/application/pluginconnector.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ class BrokenPlugin(_PluginConnector):
6565

6666
def __init__(self, error, plugin_class):
6767
name = utils.name_from_class(plugin_class, 'Plugin')
68-
doc = 'This plugin is disabled because it failed to load properly.\n' \
69-
+ 'Error: ' + error
68+
doc = 'The plugin is disabled because it failed to load properly.\n' \
69+
+ 'Error: {}'.format(error)
7070
_PluginConnector.__init__(self, name, doc=doc, error=error)
71-
LOG.error("Taking %s plugin into use failed:\n%s" % (name, error))
71+
LOG.error("Taking {} plugin into use failed:\n{}".format(name, error))
7272

7373
def enable_on_startup(self):
7474
pass

src/robotide/editor/grid.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def __init__(self, parent, num_rows, num_cols, popup_creator=None,
3636
self.SetDefaultRenderer(grid.GridCellAutoWrapStringRenderer())
3737
self._clipboard_handler = ClipboardHandler(self)
3838
self._history = _GridState()
39+
self.SetColMinimalAcceptableWidth(70)
3940
self.CreateGrid(num_rows, num_cols)
4041
self._popup_creator = popup_creator or PopupCreator()
4142
self.settings = settings

src/robotide/log/log.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def __init__(self, app):
4040
self._log = []
4141
self._window = None
4242
self._path = os.path.join(
43-
tempfile.gettempdir(), '{}-ride.log'.format(uuid.uuid4()))
43+
tempfile.gettempdir(), '{0}-ride.log'.format(uuid.uuid4()))
4444
self._outfile = None
4545
self._remove_old_log_files()
4646
atexit.register(self._close)
@@ -56,7 +56,7 @@ def _remove_old_log_files(self):
5656
try:
5757
os.remove(fname)
5858
except OSError or IOError as e:
59-
sys.stderr.write("{}".format(e))
59+
sys.stderr.write("{0}".format(e))
6060

6161
@property
6262
def _logfile(self):
@@ -103,33 +103,36 @@ def OnViewLog(self, event):
103103
self.notebook.show_tab(self._window)
104104

105105

106-
class _LogWindow(wx.TextCtrl):
106+
class _LogWindow(wx.Panel):
107107

108108
def __init__(self, notebook, log):
109-
wx.TextCtrl.__init__(
110-
self, notebook, style=wx.TE_READONLY | wx.TE_MULTILINE)
109+
wx.Panel.__init__(self, notebook)
110+
self._output = wx.TextCtrl(self, style=wx.TE_READONLY | wx.TE_MULTILINE)
111111
self._log = log
112-
self._create_ui()
113112
self._add_to_notebook(notebook)
114113
self.SetFont(widgets.Font().fixed_log)
114+
self.Bind(wx.EVT_SIZE, self.OnSize)
115115

116116
def _create_ui(self):
117-
sizer = wx.BoxSizer(wx.VERTICAL)
118-
sizer.Add(self)
119-
self.SetSizer(sizer)
117+
self.SetSizer(widgets.VerticalSizer())
118+
self.Sizer.add_expanding(self._output)
120119

121120
def _add_to_notebook(self, notebook):
122-
notebook.add_tab(self, 'Log', allow_closing=True)
121+
notebook.add_tab(self, 'RIDE Log', allow_closing=True)
123122
notebook.show_tab(self)
123+
self._output.SetSize(self.Size)
124124

125125
def close(self, notebook):
126126
notebook.delete_tab(self)
127127

128128
def update_log(self):
129-
self.SetValue(self._decode_log(self._log))
129+
self._output.SetValue(self._decode_log(self._log))
130130

131131
def _decode_log(self, log):
132132
result = ''
133133
for msg in log:
134134
result += _message_to_string(msg)
135135
return result
136+
137+
def OnSize(self, evt):
138+
self._output.SetSize(self.Size)

src/robotide/preferences/saving.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class SavingPreferences(widgets.PreferencesPanel):
2424
def __init__(self, settings, *args, **kwargs):
2525
super(SavingPreferences, self).__init__(*args, **kwargs)
2626
self._settings = settings
27-
self.SetSizer(wx.FlexGridSizer(rows=7, cols=2))
27+
self.SetSizer(wx.FlexGridSizer(cols=2))
2828
for editor in self._create_editors(settings):
2929
self._add_editor(editor)
3030

src/robotide/preferences/settings.cfg

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ library xml directories = []
2020
txt number of spaces = 4
2121
txt format separator = 'space'
2222
line separator = 'native'
23-
default file format = 'txt'
23+
default file format = 'robot'
2424

2525
[Text Edit]
26-
font size = 8
26+
font size = 9
2727
argument = '#bb8844'
2828
comment = 'black'
2929
error = 'black'
@@ -38,7 +38,7 @@ tc_kw_name = '#aaaaaa'
3838
variable = '#008080'
3939

4040
[Grid]
41-
font size = 8
41+
font size = 9
4242
fixed font = False
4343
col size = 170
4444
max col size = 300

src/robotide/publish/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ def important_action(self):
119119

120120
import os
121121

122+
from robotide.context import WX_VERSION
123+
if WX_VERSION > '3.0':
124+
from wx.lib.pubsub import setuparg1
125+
elif WX_VERSION > '2.9':
126+
from wx.lib.pubsub import setupv1
122127
from messages import *
123128
from publisher import PUBLISHER
124129

src/robotide/publish/messages.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
try:
16+
from wx.lib.pubsub import Publisher
17+
WxPublisher = Publisher()
18+
except ImportError:
19+
from wx.lib.pubsub import pub
20+
WxPublisher = pub.getDefaultPublisher()
1521
import inspect
1622
import sys
1723
import traceback

src/robotide/publish/publisher.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
try:
16+
from wx.lib.pubsub import Publisher
17+
WxPublisher = Publisher()
18+
except ImportError:
19+
from wx.lib.pubsub import pub
20+
WxPublisher = pub.getDefaultPublisher()
21+
1522

1623
class Publisher(object):
1724

@@ -67,6 +74,7 @@ class _ListenerWrapper(object):
6774
def __init__(self, listener, topic):
6875
self.listener = listener
6976
self.topic = self._get_topic(topic)
77+
WxPublisher.subscribe(self, self.topic)
7078

7179
def _get_topic(self, topic):
7280
if not isinstance(topic, basestring):
@@ -80,7 +88,7 @@ def listens(self, topic):
8088
return self._get_topic(topic).startswith(self.topic)
8189

8290
def unsubscribe(self):
83-
pass
91+
WxPublisher.unsubscribe(self, self.topic)
8492

8593
def __call__(self, data):
8694
from messages import RideLogException

0 commit comments

Comments
 (0)