Tweaking ZeroPhone UI

From ZeroPhone
Revision as of 19:12, 9 October 2017 by Admin (talk | contribs) (Created page with "Sometimes, the stock UI just isn't good enough - you might want it to look a little different, or maybe behave differently. Here's one of the ways to do that (more to be added...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Sometimes, the stock UI just isn't good enough - you might want it to look a little different, or maybe behave differently. Here's one of the ways to do that (more to be added later).

Tweaking UI element representation

pyLCI allows having different UI representations (views) for different UI elements. It uses JSON-based configuration files, so that one can define, which view is used for a specific UI element or just UI element type, as well as which view is the default for UI element families or specific UI elements. The information about used views is stored in the ui/configs directory, in .json files. The main file is base_config.json, which contains defaults that are shipped with pyLCI. This file is stored in pyLCI git repository and will be updated from time to time to accomodate new apps, so changing it is highly unadvised (since then there might be merge conflicts on next update from git). Instead, all the keys&values in the base_config.json file can be overridden by creating a ########config_sdfsdsdf.json file in the same folder, where ######sdfsdsdf is anything you want it to be, so resulting filenames could look like "config_my_tweaks.json" or "config_readability.json".

I've made a simple JSON-based configuration way, so that it's easy to to define, which view is used for this specific UI element or just UI element type, as well as which view is the default. tl;dr just create one more file in ui/configs/ folder, for it to be automatically picked up.

An example base config

This is an example base config file (base_config.json), which will have its values overridden by any additional config files.

   {"list_ui_base":{
      "custom_views":{
          "Systemctl: all unit list menu": "SimpleGraphicalView",
          "Systemctl: filtered unit list menu": "SimpleGraphicalView",
          "NMap: select port types": "SimpleGraphicalView"
      },
      "default":"PrettyGraphicalView"
    }
   }

(taken from git on 09.10.17)

Replacing view for one specific element

Let's create a config_tweak_one.json file, to override one view that we don't like the default view for:

   {"list_ui_base":{"custom_views":{"NMap: select port types": "PrettyGraphicalView"}}}

where the "NMap: select port types" key is the UI element name, passed to the UI element constructor, like this:

   chosen_ports = Checkbox(heuristic_ports, i, o, name="NMap: select port types", final_button_name="Run scan").activate()

Resulting config that'll be used by the UI elements:

   {"list_ui_base":{
      "custom_views":{
          "Systemctl: all unit list menu": "SimpleGraphicalView",
          "Systemctl: filtered unit list menu": "SimpleGraphicalView",
          "NMap: select port types": "PrettyGraphicalView"
      },
      "default":"PrettyGraphicalView"
    }
   }

Replacing the default view for one type of UI elements

 config_readability.json

In the future, passing args and kwargs to the view constructors will be supported.

Example config one might use

 config_my_tweaks.json


UI element view descriptions

Right now, there aren't many views available. For example, for ListViewUIElements, available views are:

  1. TextView
  2. SimpleGraphicalView
  3. PrettyGraphicalView