This looks like a nice example application for our wiki once it works.
> Thanks for the examples, Little Girl. I'm starting to, uh, see how much
> AutoHotkey handholds users through its built-in GUI
> <
https://www.autohotkey.com/docs/commands/Gui.htm>.
>
> Question 1
>
> I'm wanting to create an AutoKey GUI that spits out my address in a
> modular
> way (to send to people/when websites lack autofill or whatever; I use it
> surprisingly more often than one might expect):
>
> 123 XYZ Road
> City, ST 12345-6789
>
> The GUI would send, based on your radio-button and checkbox choices:
>
> 1. only the first line
> 2. the text above, exactly as is
> 3. same as above but all on one line (", " in place of the line break)
> 4. the text above, as is but without "-6789"
> 5. same as above but all on one line (", " in place of the line break)
>
> This is relatively lightning-quick to build in AutoHotkey, so I'm starting
> to get a bit simultaneously intimidated & disappointed by AutoKey...
This is a design trade-off. From what I have heard, AHK is a very nice
package, but it only allows you to do what it knows how to do.
AutoKey scripts are written in full native Python which can do almost
anything, limited only by your imagination and coding skills. There are
only a few low level things you can't do because they interfere with
AutoKey's operations. We run into those very rarely.
Since not everyone is a flash Python programmer (I'm a beginner), we
provide as much support as possible here and on Gitter.
>
> Question 2
>
> Another question I have is: is it possible to have AutoKey's GUI display
> with the first radio button (in, say, a GUI with only radio buttons)
> already selected?
>
> Question 3
>
> In your three-shapes example popup, the title of the GUI is: "Choose all
> shapes that have four sides." However, the GUI that actually appeared was
> too horizontally small and didn't display the title in its full length. Is
> it possible to customize the GUI so that it always wraps its starting
> horizontal dimension to whatever the length of the title is?
I'm not sure what the limitations of our dialog box interfaces are because
I only use them for very simple cases.
However, it is relatively easy to directly call the dialog manager of your
choice (or almost any other external program or script) using the
subprocess() module. With the proper calling sequence, you can retrieve
the exit status of the program and the output that it writes to stdout
(usually the terminal).
When you run dialogs this way, you have full access to all of the dialog
manager's options and settings, several of which will directly address the
issues you raise above.
I'm a big yad fan. It's a fork of Zenity which is what autokey-gtk uses
for dialogs, so the settings mentioned are for yad, but will probably also
work in Zenity. Kdialog, which is used by autokey-qt has similar settings
to yad/Zenity, but the calling sequences may vary a bit. Littlegirl is a
heavy Kdialog user, so she can address any specific differences as
necessary.
In yad, selection lists are tuples with a label, a value/expression, and a
preselected flag. If the preselected flag is "true" then the first such
option will be preselected as the default choice. (If multiple selections
are enabled, more than one choice can be preselected.)
The problem you describe would most easily be solved using one simple
single choice radio button selection list. If I were coding it, I would
have it just emit a choice number and pass that through one or more case
statements to select and assemble the desired address components in a
string variable. At the end, I would put the results into the clipboard
and paste them into the application window.
The default dialog box dimensions are frequently suboptimal. In
yad/Zenity, this can be adjusted using --height=# and --width=#, where #
is the desired number of pixels for that dimension. Start with something
like 300 each and then adjust as necessary if you don't want to calculate
the correct value in advance. After you've used it enough, you can usually
pick relatively good values to start with. Starting a bit too large, you
can halve or double the initial value until you get close and the go up or
down half that amount and repeat as necessary in sort of a binary search
for the optimal value.
If you want to, you can use the Python len() function to measure the
length of your title in characters. Then you have to convert that into
pixels (I'm not sure how to do that because it's font and font size
dependent.) and then add in a healthy margin for the borders of the dialog
box and for the fact that the title field is smaller than the whole width
of the box.
yad also has a word wrap option if you need it along with lots of other
options.
--wrap-width=NUMBER
Set the width of column before wrapping to NUMBER.
Another advantage of using an external dialog manager is that you can run
it standalone from the CLI (terminal). This allows you to run it many
times very quickly until you get it just right.
If you end up with a long command line with lots of text or options, you
can split it into multiple lines by making the last character on every
line except the last one a backslash. Extra white space between arguments
has no effect, so you can use it to make the command much more readable.
I create a bash script with the yad command in it and just run that
script. This way, I can repeatedly edit, save, and run. You can pass
arguments to the script such as the title as long as you are careful about
quoting/escaping things that bash might attempt to expand.
Once it works, you can call the script from within your AutoKey Python
script and provide the arguments from Python.
Joe
Good questions. You got me to write a "book" today to answer them. Maybe
some of it will end up in the wiki, so feedback is appreciated.
> --
> You received this message because you are subscribed to the Google Groups
> "autokey-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
autokey-user...@googlegroups.com.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/autokey-users/b75d6fd9-8e4c-4c9f-9574-bb045f864974n%40googlegroups.com.
>