Skip to content

Instantly share code, notes, and snippets.

@bennihepp
Created January 19, 2012 14:55
Show Gist options
  • Save bennihepp/1640431 to your computer and use it in GitHub Desktop.
Save bennihepp/1640431 to your computer and use it in GitHub Desktop.
CellProfiler patch for changing the size of a cps.Text field
diff -ruN cellprofiler.orig/gui/moduleview.py cellprofiler/gui/moduleview.py
--- cellprofiler.orig/gui/moduleview.py 2012-01-13 10:01:00.632279000 +0100
+++ cellprofiler/gui/moduleview.py 2012-01-12 11:29:23.125876000 +0100
@@ -1066,6 +1066,9 @@
style = 0
if getattr(v, "multiline_display", False):
style = wx.TE_MULTILINE|wx.TE_PROCESS_ENTER
+ size = wx.DefaultSize
+ if getattr(v, "display_size", None) is not None:
+ size = wx.Size(v.display_size[0], v.display_size[1])
text = v.value
if not isinstance(text, (unicode, str)):
@@ -1074,7 +1077,8 @@
-1,
text,
name=control_name,
- style = style)
+ style = style,
+ size = size)
def on_cell_change(event, setting = v, control=control):
self.__on_cell_change(event, setting,control)
self.__module_panel.Bind(wx.EVT_TEXT,on_cell_change,control)
diff -ruN cellprofiler.orig/settings.py cellprofiler/settings.py
--- cellprofiler.orig/settings.py 2012-01-13 10:01:09.276904000 +0100
+++ cellprofiler/settings.py 2012-01-13 10:08:06.039558000 +0100
@@ -217,8 +217,12 @@
def __init__(self, text, value, *args, **kwargs):
kwargs = kwargs.copy()
self.multiline_display = kwargs.pop("multiline", False)
+ self.display_size = kwargs.pop("size", None)
self.metadata_display = kwargs.pop(METADATA_ATTRIBUTE, False)
super(Text,self).__init__(text, value, *args, **kwargs)
+ # give modules a chance to find out whether they
+ # can change the size of the TextBox
+ __change_size_support__ = True
class RegexpText(Setting):
"""A setting with a regexp button on the side
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment