Feature: Embed python shell
Hey,
I think about feature that will makes the editor easier to use: python shell for scripting!
the benefits:
- editing in real time
- load structs
- binary data
- stream data to editor (file or socket with Rebuffered)
In these days construct-editor requires knowledge in wxPython library, I don't think that users of construct have any knowledge in this library, for make the application(or library) be use by more people around the world I think that would be better to find a way to make some generic API for construct-editor (easy to extendable) without know any knowledge in GUI.
for example of usage of python shell in construct-editor:

changed lines in main.py file:
class ConstructGallery(wx.Panel):
.......
#line 296:
def display_binary(self, data: bytes) -> None:
"""display binary data to screen
Args:
data (bytes): bytes to load
"""
self.construct_hex_editor.binary = data
self.construct_hex_editor.refresh()
def on_load_binary_file_clicked(self, event):
with wx.FileDialog(
self,
"Open binary file",
wildcard="binary files (*.*)|*.*",
style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST,
) as fileDialog:
if fileDialog.ShowModal() == wx.ID_CANCEL:
return # the user changed their mind
# Proceed loading the file chosen by the user
pathname = Path(fileDialog.GetPath())
with open(pathname, "rb") as file:
self.display_binary(file.read())
in main function:
frame = ConstructGalleryFrame(None)
import __main__
main_locals = __main__.__dict__
main_locals["construct_gallery"] = frame.main_panel.construct_gallery
main_locals["load_binary"] = lambda data: frame.main_panel.display_binary(data)
pyshell = wx.py.shell.ShellFrame(locals=main_locals)
pyshell.Show()
frame.Show(True)
if wit is not None:
wit.InspectionTool().Show()
app.MainLoop()
if __name__ == "__main__":
main()
Add me on discord of you want to communicate there
I like your idea with scripting. I also thought about a similar feature but with a small code editor, so that it is easy to modify the construct and then see what is happening. But for loading binaries as in your example the shell is better. Maybe a mix of both of the are the way to go.
The public api is also a good idea. There also has to be an api for custom constructs eg adapters.
Unfortunately I dont have so much time to realize the ideas... But when I have a little bit free time I will look into it.