Create visual scratch-like diagrams from code - diagram

I'm making a user guide for a program I made and I want to explain what it does step by step. I want to create some kind of code diagram that visually shows my code. I don't need it to be automatically generated or anything. Just looking for something like scratch but without the actual programming part, more like being able to put my own text in any block and connecting it to other blocks, all visually. Like pseudocode but more visual.

Perhaps Snap! is appropriate here?
With Snap, you can make your own blocks of any category (e.g. motion, control) and any shape (e.g. stack, reporter, C-style like "if"). And you can right-click on a script and click "script pic...", which will download a screenshot of the script on a transparent background, handy for embedding into a paint editor.
Those "script pics" look like this:

Related

Godot: Is there any way I can invoke a method in my Script from the editor? (for testing purposes)

I come from Unity, and there you can use ContextMenu method attribute. It will add a button in the editor you can click and the method in your script will be invoked.
This is very helpful for testing/debugging purposes. When you are testing a functionality and you want an easy way to trigger it.
Is there something similar in Godot, or any workaround I can use?
(Godot 3.5 here)
There are multiple ways to run code in the editor.
In fact, Godot games and the Godot editor are built on the same core. One way to say is that Godot is build on Godot… But a more accurate way to say it is that your games are Godot without the editor, plus whatever you built on top.
As a consequence, you have a lot of freedom when extending the Godot editor.
For starters you will be making a tool script. To do that you the tool keyword on the top of the script file. This allows the script to run in the editor.
Warning: Remember that in Godot the Game is not running inside the Editor. Anything that your script moves while running in the Editor would be a modification to the project, for good or ill. And it does not come with build-in undo functionality. It is possible to add undo functionality (with the UndoRedo class), but that is also something you would have to program.
By the way, you might want to know if your code is running on the editor or not. For that, you can check Engine.editor_hint which will be true in the editor.
Read more on the article Running code in the editor.
Since the tool script modify the project. What I present below is more often used to setup parts of the scene or to automate parts of the development workflow. Not for testing features. However since the linked documentation about ContextMenu mentions that it is useful for…
automatically setting up Scene data from the script
I believe what present below is not out of place.
With that said, some modifications of the editor are harder than others. I believe you don't really want to go into the trouble of adding a button to the editor (which is perfectly possible) or an option to the menus (which is also possible, but not everywhere, at least not easily). Instead, I'll stay with the easy options for this answer:
You can make an EditorScript. That is a script that extends the EditorScript class and overrides the _run method. For example:
tool
extends EditorScript
func _run():
print("Hello from the Godot Editor!")
To execute it, have it open in the Script Editor, and to the File menu, and select Run. You can also use secondary click on the script on the "Scripts Panel (on the left of the Script Editor) and select Run in the contextual menu.
The drawback is that is script does not work in the game. It is only for the editor.
Although Godot 3.x does not have official (there is a plugin) support for inspector actions (it might land in Godot 4), we can workaround that. What we will do is export a bool property, and handle (with a setter, which we specify with setget) what happens when you set it. Like this:
tool
extends Node # or whatever
export var do_something:bool setget on_do_something
func on_do_something(_mod_value:bool) -> void:
# do whatever you want
pass
The property should show up as a checkbox in the Inspector panel when the node is selected. And clicking the checkbox will trigger the setter method on_do_something… Which will do whatever you want it to do. Notice also that I'm discarding the value that Godot is trying to set to the property (_mod_value) so it will remain false.
This pattern has got popularity among Godot developers.
If you want to add elements to the Godot UI you would have to make an EditorPlugin (see the Editor Plugins section in the documentation).
Alright but, since the tool script could cause modifications to the project, which might be a problem for testing… What do we do for testing?
Well, I will remind you that you can tell Godot to execute specific scenes (it does not have to run the main scene), and that can another way to test your code.
Furthermore, when your game is running you can go to the Scene panel and select the Remote tab to see the Nodes that exist in the game. Which will allow you to select them, which shows their properties in the Inspector, which would be able to modify (having an effect in real time on the executing game).
… And thus something similar to what I described above about using a setter would work. Except it does not need the tool keyword since it won't be running in the editor:
# No tool
extends Node # or whatever
export var do_something:bool setget on_do_something
func on_do_something(_mod_value:bool) -> void:
# do whatever you want
pass
By the way, in the inspector, when the game is executing and you have the relevant Node selected, you will see your property twice. The first one will trigger the setter, while the second one bypasses it. So pay attention which one you are using.
You might also be interested in the "Project Camera Override" feature, which allows you to freely move the game camera from the editor. You access the feature via the top bar in the editor.
You will also find that it is possible to modify Resources in the editor and see the effect in real time while the game is running. And a Script is a Resource… However pause the game from the Debugger panel (or use a breakpoint) and make sure the script you want to modify is not being executed before you modify it.

How can I quickly capture a websites MathML to use in Word?

I create mathematics workbooks in Microsoft Word. Typing in each equation is slow but faster than LaTex. So, I often copy content from a website like LibreTexts. If I copy a section that contains equations it comes out garbled. So, I go to each equation, right click, hover over Show Math As, select MathML code, select all (Ctrl+a), copy (ctrl+c), close window (Ctrl+w), go to word (Alt-Tab), paste as plain text (Ctrl+Shift+v), go back to Chrome browser (Alt-Tab), then repeat the process.
This can be faster than typing by hand, but there has to be an easier way. There was a post similar to this one, but I don't know what extension was referred to and I don't know java.
If your solutions contains the step "learn basic Java here", that is fine. If this is the incorrect Stack Exchange, please suggest the correct one.
Thank you.

How should I create a desktop mockup?

I want to create a desktop mockup on Elementary OS 0.2. By "mockup" I mean something that shows off the aesthetic of the mockup, mostly just showing what selecting/clicking/hovering over a button or widget does to that particular part of the UI. I'm thinking about creating the various parts on GIMP and coding animation and transition logic into the final result. I know that something like this can be done in HTML/JS, but I want to avoid using those. Is there anything optimized for a project like this? I'm open to most languages.
Try WireframeSketcher wireframing tool. Unlike Gimp or PowerPoint, WireframeSketcher is designed specifically to help you create mockups and wireframes. It comes pre-packaged for Debian systems and can also be found in Software Center and so it works on Elementary OS too. Note that it's a commercial tool, but you can try it freely for 14 days.
Most PMs at large companies mock these things up using a presentation package like PowerPoint. If you know the routine and where to click it can look fantastic with minimal effort.
MockupUI does both wireframe and Windows native looking mockups. It uses your desktop's visual style which makes screens and widgets look as a standard Windows application. MockupUI lets you export screens as individual images, docx, pdf or html.
Actions/interactions can be explained by highlighting widgets and adding text annotations.

How can I insert text into another application?

To scratch a personal itch, I'm writing something like a cross between a character map and an on-screen keyboard. When the user selects a character, I'd like to insert it into another application, specifically, the application that would next receive focus if my application were closed. Is there any way to do this? Right now, I work around it by just putting the character into the clipboard and terminating, leaving the user to hit paste in the other application, but usage would be far more streamlined if I could just insert the text programmatically.
I'm doing this in GTK and expect to run it only on Linux. But cross-platform solutions are also appreciated, and if GTK can't do it but some other toolkit can, I'll gladly switch.
This sounds like you should use libwnck, which is a GTK-related library that lets you manipulate windows on the desktop. The documentation is a little sparse, but the function wnck_screen_get_previously_active_window() seems promising.
From a WnckWindow you can get an X window ID, and perhaps from there you can use the X libraries to send a paste message (or even send it a "Ctrl-V" keypress event), perhaps with XSendEvent().
Very good question, by the way. I wish I could answer it more knowledgeably.

How to modify menus items in WMD editor forks?

I am just getting into the WMD editor varieties out there :) Of all of them I like MarkEdit because of the ability to modify the menu items quite easily, but it doesn't do a couple of things that I really like in a couple of forks, for example, http://github.com/openlibrary/wmd.
Ideally my perfect WMD editor would:
create list items automatically on pressing return when in a list block (not implemented in MarkEdit)
allow the removal of menu items (implemented in MarkEdit)
the cheat of making a newline without the need for two spaces (implemented in MarkEdit)
As point 1. and 2. are both quite important to me, but I imagine 1. is harder to implement, I may have to use the forks such as the openlibrary-wmd rather than my preferred choice of MarkEdit.
How can I modify the menu buttons in a fork like openlibrary-wmd? The configuration function no longer seems to work as described for the original.
I recently used the markitup editor and found the skin implementation pretty useful. Each skin has its own images and styles which you can easily override if you need to. The editor is also jQuery-driven, which is nice if you're used to that syntax. Check it out

Resources