<commit_before>#+TITLE: dynmen

* Introduction
/dynmen/ is a python library for dynamic menus like [[https://github.com/DaveDavenport/rofi][rofi]], [[http://tools.suckless.org/dmenu/][dmenu]], or [[https://github.com/junegunn/fzf][fzf]].

* Installation
You can install a released version using pip

#+BEGIN_SRC sh
pip install dynmen
#+END_SRC

Or the development version from github
#+BEGIN_SRC sh
git clone https://github.com/frostidaho/dynmen.git
pip install ./dynmen
# pip install --user ./dynmen
#+END_SRC

* Usage
#+BEGIN_SRC python :results output
  from dynmen.rofi import Rofi
  menu = Rofi()
  menu.font = 'monospace 20'
  menu.case_insensitive = True
  menu.prompt = "Name of person: "
  exdict = {
      '<NAME>': ('Brownmouth', '09044'),
      '<NAME>': ('Mikechester', '33477'),
      '<NAME>': ('North Gwendolynberg', '29053'),
      '<NAME>': ('Andrewsmouth', '72513'),
  }
  # Menus will accept a dict-like object
  print(menu(exdict))
  # Or a list-like object
  print(menu(['a', 'b', 'c']))
#+END_SRC

#+RESULTS:
: MenuResult(selected='<NAME>', value=('Brownmouth', '09044'), returncode=0)
: MenuResult(selected='c', value=None, returncode=0)

[[file:readme_example.gif]]

Please see the [[file:examples/][collection of examples]]<commit_msg>Update rofi example in README.org<commit_after>#+TITLE: dynmen

* Introduction
/dynmen/ is a python library for dynamic menus like [[https://github.com/DaveDavenport/rofi][rofi]], [[http://tools.suckless.org/dmenu/][dmenu]], or [[https://github.com/junegunn/fzf][fzf]].

* Installation
You can install a released version using pip

#+BEGIN_SRC sh
pip install dynmen
#+END_SRC

Or the development version from github
#+BEGIN_SRC sh
git clone https://github.com/frostidaho/dynmen.git
pip install ./dynmen
# pip install --user ./dynmen
#+END_SRC

* Usage
** Example using rofi
#+BEGIN_SRC python :results output :exports both
  from dynmen.rofi import Rofi
  import reprlib #reprlib is python3 only

  menu = Rofi()
  print(menu)
  print("All of Rofi's options & flags are available as attributes")
  rofi_options = reprlib.repr([x for x in dir(menu) if not x.startswith('_')])
  print('\t', rofi_options, sep='')
  print("For example, 'menu.font'", menu.font, sep='\n\t')

  menu.font = "sans 30"
  menu.lines = 4
  print("Set rofi's font and number of lines", menu, sep='\n\t')
  result = menu({'first': 'a', 'second': 'b', 'third': 'c'})
  print(result)
#+END_SRC

#+RESULTS:
: Rofi(dmenu=True)
: All of Rofi's options & flags are available as attributes
: 	['a', 'auto_select', 'bw', 'case_sensitive', 'click_to_exit', 'color_active', ...]
: For example, 'menu.font'
: 	Record(name='font', value=<Default.value: 1>, transformed=[], info='Font to use @@@ mono 12 (Default)')
: Set rofi's font and number of lines
: 	Rofi(dmenu=True, font='sans 30', lines=4)
: MenuResult(selected='first', value='a', returncode=0)

[[file:readme_example.gif]]

Please see the [[file:examples/][collection of examples]]
{'fraction_non_alphanumeric': 0.16677920324105333, 'fraction_numerical': 0.01350438892640108, 'mean_word_length': 4.798434442270059, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4568090', 'n_tokens_mistral': 1109, 'n_tokens_neox': 1047, 'n_words': 290}