happyscript 0.0.27__tar.gz → 0.0.34__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. {happyscript-0.0.27 → happyscript-0.0.34}/PKG-INFO +3 -1
  2. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/__init__.py +1 -1
  3. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/charts/matplotlib_chart.py +1 -16
  4. happyscript-0.0.34/happyscript/splashmenu/exit.png +0 -0
  5. happyscript-0.0.34/happyscript/userpanel/userpanel.py +194 -0
  6. happyscript-0.0.34/happyscript/userpanel/userpaneltimer.py +46 -0
  7. happyscript-0.0.34/happyscript/userpanel/userpanelvalue.py +26 -0
  8. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript.egg-info/PKG-INFO +3 -1
  9. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript.egg-info/SOURCES.txt +6 -1
  10. happyscript-0.0.34/happyscript.egg-info/requires.txt +2 -0
  11. {happyscript-0.0.27 → happyscript-0.0.34}/pyproject.toml +7 -4
  12. {happyscript-0.0.27 → happyscript-0.0.34}/README.md +0 -0
  13. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/charts/__init__.py +0 -0
  14. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/charts/chart.py +0 -0
  15. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/charts/histogram_chart.py +0 -0
  16. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/charts/histogram_series.py +0 -0
  17. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/charts/panel_charts.py +0 -0
  18. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/charts/scatter_chart.py +0 -0
  19. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/charts/scatter_series.py +0 -0
  20. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/charts/time_chart.py +0 -0
  21. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/charts/time_series.py +0 -0
  22. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/forms/form_askchoice.py +0 -0
  23. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/forms/form_askimage.py +0 -0
  24. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/forms/form_main.py +0 -0
  25. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/forms/form_ontestfailure.py +0 -0
  26. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/forms/form_serials.py +0 -0
  27. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/forms/form_stop.py +0 -0
  28. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/forms/formsbase.py +0 -0
  29. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/imglib.py +0 -0
  30. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/panels/panel_log.py +0 -0
  31. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/panels/panel_messages.py +0 -0
  32. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/panels/panel_scripts2.py +0 -0
  33. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/panels/panel_tests.py +0 -0
  34. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/panels/panelsbase.py +0 -0
  35. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/scriptartwork.py +0 -0
  36. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/scriptcontrol.py +0 -0
  37. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/scriptexceptions.py +0 -0
  38. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/scriptgui.py +0 -0
  39. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/scriptinfo.py +0 -0
  40. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/scriptmanager.py +0 -0
  41. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/scriptparams.py +0 -0
  42. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/scriptreader.py +0 -0
  43. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/scriptrunner.py +0 -0
  44. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/splashmenu/forms.py +0 -0
  45. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/splashmenu/splashmenuform.py +0 -0
  46. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/splashmenu/splashmenumain.py +0 -0
  47. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/testlog/global_log_handler.py +0 -0
  48. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/testlog/log_to_text.py +0 -0
  49. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/testlog/logtoxml.py +0 -0
  50. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript/testlog/printredirect.py +0 -0
  51. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript.egg-info/dependency_links.txt +0 -0
  52. {happyscript-0.0.27 → happyscript-0.0.34}/happyscript.egg-info/top_level.txt +0 -0
  53. {happyscript-0.0.27 → happyscript-0.0.34}/setup.cfg +0 -0
@@ -1,9 +1,11 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: happyscript
3
- Version: 0.0.27
3
+ Version: 0.0.34
4
4
  Summary: Framework for running scripts
5
5
  Requires-Python: >=3.5
6
6
  Description-Content-Type: text/markdown
7
+ Requires-Dist: wxpython
8
+ Requires-Dist: numpy
7
9
 
8
10
 
9
11
  More info coming soon...
@@ -1,6 +1,6 @@
1
1
  """HappyScript - handy script launcher"""
2
2
 
3
- __version__ = "0.0.27"
3
+ __version__ = "0.0.34"
4
4
 
5
5
  # With these statements, after doing 'import happyscript' you can do 'xxx = happyscript.ScriptManager()'
6
6
  #from .scriptmanager import ScriptManager
@@ -17,24 +17,9 @@ try:
17
17
  HAVE_MATPLOTLIB = True
18
18
  except ImportError:
19
19
  HAVE_MATPLOTLIB = False
20
-
21
-
22
- # fig_canvas_toolbar = dict()
23
- #
24
- # old_panels = dict()
25
20
 
26
21
  class MatPlotLibChart(wx.Panel):
27
22
 
28
- # @classmethod
29
- # def create(cls, parent_control, name):
30
- #
31
- # if not name in old_panels:
32
- # panel = MatPlotLibChart(parent_control, name)
33
- # old_panels[name] = panel
34
- #
35
- # return old_panels[name]
36
-
37
-
38
23
  def __init__(self, parent_control, name):
39
24
  '''
40
25
  Constructor
@@ -83,7 +68,7 @@ class MatPlotLibChart(wx.Panel):
83
68
  return self.__name
84
69
 
85
70
  @property
86
- def figure(self) -> Figure:
71
+ def figure(self) -> 'Figure':
87
72
  return self.__figure
88
73
 
89
74
  def configure(self, /, x_label=None, y_label=None, title=None,
@@ -0,0 +1,194 @@
1
+ import wx
2
+ import wx.xrc
3
+ from happyscript.happyscript.userpanel.userpaneltimer import UserPanelTimer
4
+ from happyscript.happyscript.userpanel.userpanelvalue import UserPanelValue
5
+
6
+
7
+ class UserPanel(wx.Panel):
8
+ """
9
+ Public methods
10
+ """
11
+
12
+ def __init__(self, parent):
13
+ """GUI builder for widgets to be used with happyscript
14
+
15
+ Keyword Arguments:
16
+ parent -- The window parent. This may be, and often is, None. (default: {None})
17
+ """
18
+ wx.Panel.__init__(self, parent=parent, id = wx.ID_ANY, pos = wx.DefaultPosition, style = wx.TAB_TRAVERSAL, name = wx.EmptyString )
19
+ self.__mainbox = wx.BoxSizer(wx.VERTICAL)
20
+ self.SetSizer(self.__mainbox)
21
+ self.Layout()
22
+
23
+ self.__timers=[]
24
+
25
+ def add_box(self, title):
26
+ """adds a box with a title to be used to contain the widgets
27
+
28
+ Arguments:
29
+ title -- label for the box
30
+ """
31
+ self.__current_top_box = wx.StaticBoxSizer(wx.StaticBox(self, label=title), wx.VERTICAL)
32
+ self.__mainbox.Add(self.__current_top_box, 0, wx.EXPAND, 5)
33
+
34
+ def add_buttons(self, button_labels, button_event, label=None):
35
+ """adds a horizontal row of buttons, which trigger the button_event(button_label) callback)
36
+
37
+ Arguments:
38
+ button_labels -- list of labels (one for each button)
39
+ button_event -- callback triggered on button presses. function takes a button label as its argument
40
+
41
+ Keyword Arguments:
42
+ label -- optional label to be placed left of the buttons (default: {None})
43
+ """
44
+ self.__current_sub_box = self.__create_boxsizer(wx.HORIZONTAL, 0)
45
+ if label is not None:
46
+ self.__insert_label(label, 1)
47
+ for button_label in button_labels:
48
+ event_wrapper = lambda *args, x=button_label: button_event(x)
49
+ proportion = 1 if (label is None) else 0
50
+ self.__insert_button(button_label, event_wrapper, proportion)
51
+
52
+ def add_slider(self, label, initial, min, max, set_event=None):
53
+ """adds a slider for the user to set a value, which can trigger the set_event(value) callback
54
+ the value can be accessed in the .value field of the object returned by this method
55
+
56
+ Arguments:
57
+ label -- label to be placed left of the slider
58
+ initial -- slider initial value
59
+ min -- slider minimum value
60
+ max -- slider maximum value
61
+
62
+ Keyword Arguments:
63
+ set_event -- optional callback triggered when set button is pressed. function takes the new value as its argument (default: {None})
64
+
65
+ Returns:
66
+ object to access the slider value via the .value field (object type is SmartInput)
67
+ """
68
+ self.__current_sub_box= self.__create_boxsizer(wx.HORIZONTAL, 0)
69
+ self.__insert_label(label, 0)
70
+ slider_obj = self.__insert_slider(initial, min, max, 1)
71
+ label_obj = self.__insert_label(str(initial), 0)
72
+ smart_input = UserPanelValue(slider_obj, set_event)
73
+ self.__insert_button("Set", lambda *args: smart_input.set(), 0)
74
+ slider_obj.Bind(wx.EVT_SCROLL, lambda *args: label_obj.SetLabel(str(slider_obj.GetValue())))
75
+ return smart_input
76
+
77
+ def add_combo_box(self, label, option_list, set_event=None):
78
+ """adds a combo box for the user to set a value, which can trigger the set_event(value) callback
79
+ the value can be accessed in the .value field of the object returned by this method
80
+
81
+ Arguments:
82
+ label -- label to be placed left of the combo box
83
+ option_list -- list of options to be presented in the combo box
84
+
85
+ Keyword Arguments:
86
+ set_event -- optional callback triggered when set button is pressed. function takes the new value as its argument (default: {None})
87
+
88
+ Returns:
89
+ object to access the combo box value via the .value field (object type is SmartInput)
90
+ """
91
+ self.__current_sub_box = self.__create_boxsizer(wx.HORIZONTAL, 0)
92
+ self.__insert_label(label, 0)
93
+ combo_obj = self.__insert_combo_box(option_list, 1)
94
+ smart_input = UserPanelValue(combo_obj, set_event)
95
+ self.__insert_button("Set", lambda *args: smart_input.set(), 0)
96
+ return smart_input
97
+
98
+ def add_spin_control(self, label, initial, min, max, set_event=None):
99
+ """adds a spin control for the user to set a value, which can trigger the set_event(value) callback
100
+ the value can be accessed in the .value field of the object returned by this method
101
+
102
+ Arguments:
103
+ label -- label to be placed left of the spin control
104
+ initial -- spin control initial value
105
+ min -- spin control minimum value
106
+ max -- spin control maximum value
107
+
108
+ Keyword Arguments:
109
+ set_event -- optional callback triggered when set button is pressed. function takes the new value as its argument (default: {None})
110
+
111
+ Returns:
112
+ object to access the spin control value via the .value field (object type is SmartInput)
113
+ """
114
+ self.__current_sub_box = self.__create_boxsizer(wx.HORIZONTAL, 0)
115
+ self.__insert_label(label, 0)
116
+ spin_obj = self.__insert_spin_control(initial, min, max, 1)
117
+ smart_input = UserPanelValue(spin_obj, set_event)
118
+ self.__insert_button("Set", lambda *args: smart_input.set(), 0)
119
+ return smart_input
120
+
121
+ # def add_timer_control(self, default, min, max, interval_callback, *args, **kwargs):
122
+ # """allows the user to periodically trigger a callback
123
+ # the timer interval is set with a spin control
124
+ # pressing start or stop will (re)start or stop the interval timer
125
+
126
+ # Arguments:
127
+ # default -- inverval default value
128
+ # min -- interval minimum value
129
+ # max -- interval maximum value
130
+ # interval_callback -- callback to be triggered each interval. any number of arguments can be passed via *args and **kwargs (interval_callback(*args, **kwargs))
131
+ # """
132
+ # self.__current_sub_box = self.__create_boxsizer(wx.HORIZONTAL, 0)
133
+ # self.__insert_label("Interval (s)", 0)
134
+ # spin_obj = self.__insert_spin_control(default, min, max, 1)
135
+
136
+ # timer = UserPanelTimer(UserPanelValue(spin_obj), interval_callback, *args, **kwargs)
137
+ # self.__timers.append(timer)
138
+ # self.__insert_button("Start", lambda *args: timer.restart(), 0)
139
+ # self.__insert_button("Stop", lambda *args: timer.stop(), 0)
140
+
141
+ """
142
+ private methods
143
+ """
144
+
145
+ def __create_boxsizer(self, orientation, proportion):
146
+ """setup for a BoxSizer
147
+ """
148
+ box = wx.BoxSizer(orientation)
149
+ self.__current_top_box.Add(box, proportion, wx.EXPAND, 5)
150
+ return box
151
+
152
+ def __insert_label(self, label_text, proportion):
153
+ """setup for a label
154
+ """
155
+ label = wx.StaticText(self.__current_top_box.GetStaticBox(), label=label_text)
156
+ label.Wrap(-1)
157
+ self.__current_sub_box.Add(label, proportion, wx.ALL, 5)
158
+ return label
159
+
160
+ def __insert_button(self, button_label, button_event, proportion):
161
+ """setup for a button
162
+ """
163
+ button = wx.Button(self.__current_top_box.GetStaticBox(), label=button_label)
164
+ button.Bind(wx.EVT_BUTTON, button_event)
165
+ self.__current_sub_box.Add(button, proportion, wx.ALL, 5)
166
+ return button
167
+
168
+ def __insert_slider(self, initial, min, max, proportion):
169
+ """setup for a slider
170
+ """
171
+ slider = wx.Slider(self.__current_top_box.GetStaticBox(), value=initial, minValue=min, maxValue=max)
172
+ self.__current_sub_box.Add(slider, proportion, wx.ALL | wx.EXPAND, 5)
173
+ return slider
174
+
175
+ def __insert_combo_box(self, option_list, proportion):
176
+ """setup for a combo box
177
+ """
178
+ combo = wx.ComboBox(self.__current_top_box.GetStaticBox(), value=option_list[0], choices=option_list)
179
+ self.__current_sub_box.Add(combo, proportion, wx.ALL, 5)
180
+ return combo
181
+
182
+ def __insert_spin_control(self, initial, min, max, proportion):
183
+ """setup for a spin control
184
+ """
185
+ spin = wx.SpinCtrl(self.__current_top_box.GetStaticBox(), initial=initial, min=min, max=max)
186
+ self.__current_sub_box.Add(spin, proportion, wx.ALL, 5)
187
+ return spin
188
+
189
+ # def __on_close(self, wxEvent):
190
+ # """cancels the running timer threads
191
+ # """
192
+ # for timer in self.__timers:
193
+ # timer.stop()
194
+ # self.Destroy()
@@ -0,0 +1,46 @@
1
+ from threading import Timer
2
+
3
+ class UserPanelTimer(object):
4
+ def __init__(self, interval_source, function, *args, **kwargs):
5
+ """interval timer that repeatedly calls a callback function
6
+ based on: https://stackoverflow.com/a/13151299
7
+
8
+ Arguments:
9
+ interval_source -- SmartInput object to retrieve the interval in seconds from
10
+ function -- callback function to run every interval
11
+ """
12
+ self._timer = None
13
+ self.interval_source = interval_source
14
+ self.function = function
15
+ self.args = args
16
+ self.kwargs = kwargs
17
+ self.is_running = False
18
+
19
+ def __run(self):
20
+ """callback to run after timer completes
21
+ """
22
+ self.is_running = False
23
+ self.start()
24
+ self.function(*self.args, **self.kwargs)
25
+
26
+ def start(self):
27
+ """starts the timer
28
+ """
29
+ if not self.is_running:
30
+ self._timer = Timer(self.interval_source.set(), self.__run)
31
+ self._timer.start()
32
+ self.is_running = True
33
+
34
+ def restart(self):
35
+ """restarts the timer
36
+ """
37
+ if self.is_running:
38
+ self.stop()
39
+ self.start()
40
+
41
+ def stop(self):
42
+ """stops the timer
43
+ """
44
+ if self._timer is not None:
45
+ self._timer.cancel()
46
+ self.is_running = False
@@ -0,0 +1,26 @@
1
+
2
+ class UserPanelValue():
3
+ def __init__(self, value_source, on_set=None):
4
+ """initialiser method
5
+ SmartInput objects are used to keep track of GUI input values
6
+
7
+ Arguments:
8
+ value_source -- GUI object to retreive self.value from
9
+
10
+ Keyword Arguments:
11
+ on_set -- callback to be run after self.set(), receives self.value as its first argument (default: {None})
12
+ """
13
+ self.__value_source = value_source
14
+ self.value = self.__value_source.GetValue()
15
+ self.on_set = on_set
16
+
17
+ def set(self):
18
+ """update self.value and then run the on_set function
19
+
20
+ Returns:
21
+ newest self.value
22
+ """
23
+ self.value = self.__value_source.GetValue()
24
+ if self.on_set is not None:
25
+ self.on_set(self.value)
26
+ return self.value
@@ -1,9 +1,11 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: happyscript
3
- Version: 0.0.27
3
+ Version: 0.0.34
4
4
  Summary: Framework for running scripts
5
5
  Requires-Python: >=3.5
6
6
  Description-Content-Type: text/markdown
7
+ Requires-Dist: wxpython
8
+ Requires-Dist: numpy
7
9
 
8
10
 
9
11
  More info coming soon...
@@ -14,6 +14,7 @@ happyscript/scriptrunner.py
14
14
  happyscript.egg-info/PKG-INFO
15
15
  happyscript.egg-info/SOURCES.txt
16
16
  happyscript.egg-info/dependency_links.txt
17
+ happyscript.egg-info/requires.txt
17
18
  happyscript.egg-info/top_level.txt
18
19
  happyscript/charts/__init__.py
19
20
  happyscript/charts/chart.py
@@ -37,10 +38,14 @@ happyscript/panels/panel_messages.py
37
38
  happyscript/panels/panel_scripts2.py
38
39
  happyscript/panels/panel_tests.py
39
40
  happyscript/panels/panelsbase.py
41
+ happyscript/splashmenu/exit.png
40
42
  happyscript/splashmenu/forms.py
41
43
  happyscript/splashmenu/splashmenuform.py
42
44
  happyscript/splashmenu/splashmenumain.py
43
45
  happyscript/testlog/global_log_handler.py
44
46
  happyscript/testlog/log_to_text.py
45
47
  happyscript/testlog/logtoxml.py
46
- happyscript/testlog/printredirect.py
48
+ happyscript/testlog/printredirect.py
49
+ happyscript/userpanel/userpanel.py
50
+ happyscript/userpanel/userpaneltimer.py
51
+ happyscript/userpanel/userpanelvalue.py
@@ -0,0 +1,2 @@
1
+ wxpython
2
+ numpy
@@ -17,14 +17,17 @@ build-backend = "setuptools.build_meta"
17
17
  [project]
18
18
  name = "happyscript"
19
19
  description = "Framework for running scripts"
20
- version = "0.0.27"
20
+ version = "0.0.34"
21
21
  readme = "README.md"
22
22
  requires-python = ">=3.5"
23
- dependencies = [ ]
23
+ dependencies = [ "wxpython", "numpy" ]
24
24
 
25
- [tool.setuptools]
26
- include-package-data = false
25
+ #[tool.setuptools]
26
+ #include-package-data = true
27
27
 
28
28
  [tool.setuptools.packages.find]
29
29
  include = ["happyscript*"]
30
30
  exclude = ["artwork*","demo*","examples*"]
31
+
32
+ [tool.setuptools.package-data]
33
+ "*" = ["*.png"]
File without changes
File without changes