Menu

custom configurations

James Waldby

Setting up custom configuration files

Configuration files for qenqote are XML files. In such files, application-
defined tags are used to communicate data structures. XML files for qenqote contain tags of form <qenqote>, <at>, <def>, <key>, <line>, </line></key></def></at></qenqote>

<main>, and <mode>, and matching forms with slashes added, for example </mode></main>. Tags must always appear in properly nested matched pairs. The basic form of a submenu button definition is: **

       <line> <key>aButtonName</key> <def>somePythonCode</def> </line>

**

If you are familiar with writing Python code, you probably can copy and adapt an existing qenqote setup file for your own purposes without reading the Details section. The rest of this section is an overview of how qenqote works and provides the basic level of understanding needed for customizing qenqote setup files.

A qenqote script, or setup file, contains names of buttons, code snippets to implement button functions, and mode settings. Modes determine menu layout and specify operational aspects like click to operate, enter to operate, and leave to operate. By its nesting order, a script specifies which menu or submenu each button belongs to.

Each code snippet executes when its portion of the menu operates. Top level code (i.e. code defined by those <def></def> pairs outside of any

<main> pairs) executes at startup, before any menu is displayed. <main></main> level code executes when its main menu button operates. <line></line> level code executes when its submenu button operates. Some scripts contain no top or intermediate level code, leaving all the work for bottom level code to do. Others have code at multiple levels. In Example 1, the first two <def></def> lines are top level code, and the others are submenu level.

Example 1:

**

<qenqote>
  <def>def C(x): subprocess.call(['firefox',x])</def>
  <def>def T(x,y): C('http://%s%s' % (x,y))</def>
  <main><key>Call-Demo</key>
    <line><key>Wiktionary</key><def>T('en.wiktionary.org/wiki/',qi)</def></line>
    <line><key>Wikipedia</key><def>T('en.wikipedia.org/wiki/',qi) </def></line>
    <line><key>To German</key><def>T('dictionary.reverso.net/english-german/',qi)</def></line>
    <line><key>Exit</key><def>sys.exit(0)</def></line>
  </main>
</qenqote>

The above code is part of file qset-call.xml. When you run it (via, e.g. qenqote qset-call.xml), functions C(x) and T(x,y) are immediately defined by def C(x): and def T(x,y):** snippets. They are defined in the same namespace that will be used later when executing submenu-button code.

When you click Example 1's Call-Demo button, qenqote will pop up a menu with names Wiktionary, Wikipedia, To German, Exit, and half a dozen buttons described later. If you then click the Wikipedia button, qenqote will execute code T('en.wikipedia.org/wiki/',i), which in turn will create a URL and call C() with it.

When a submenu button operates, clipboard text is delivered to the button's code in variable qi, with modified forms supplied in other variables qf,qv,qt,qu (see Standard Conversions below). To put text on the clipboard, user code should compute a result x and say qput(x), as illustrated in this example:

      **<def>qput('Simon says "%s".' % qi)</def>**

If the clip is Stand up straight when this code runs, the qput() call
will put result Simon says "Stand up straight". back on the clipboard. On the other hand, the code in Example 1 doesn't call qput(), so it doesn't change clipboard contents.

</main>