Package: python-fx
PyfxA python-native JSON Viewer TUI, inspired byfx.Pyfxsupports:Read JSON files in terminal from several sources (file, pipe or clipboard).Query JSON files using JSONPath query.Table of ContentPrerequisiteInstallationPIPBuild from SourceQuick StartCLIPython ModuleConfigurationDefault ConfigurationLicenseChangelogHow to ContributePrerequisitesOS: MacOS / Linuxpython: >= 3.8pipInstallationPippipinstallpython-fxBuild from SourceClone the thisrepo, change directory into the project and runpipinstall-Uautopep8toxbuild
makeinstallLocal DevelopmentClone the thisrepo, change directory into the project and runpipinstall-Upipenv
pipenvinstall--devQuick StartYou can usePyfxin two ways:A standalone CLI toolA python module which can be integrated in any python CLI applicationFor details, please check the hosteddocumentation.CLICheckKey Bindingssection for default key bindings.Pyfxcomes with a CLI, use itTo open a JSON filepyfxJSON_FILETo read JSON data from pipecatJSON_FILE|pyfxTo read JSON data from clipboardpyfx-x/--from-clipboardPython ModuleCheckKey Bindingssection for default key bindings.Directly AttachPyfxSimple TUIDirectly integratePyfx's TUI into your own project.frompyfximportPyfxAppdata=[1]# data is the JSON data to be rendered in the TUIPyfxApp(data=data).run()Integrate with Your Own Urwid-based TUIIntegratePyfxnative JSON widgets into your own urwid-based TUI.frompyfx.view.json_libimportJSONListBox,JSONListWalkerdata=[1]# 1. create JSONListBox from datalistbox=JSONListBox(JSONListWalker(data))# 2. use listbox in your own TUIConfigurationPyfxis configured using YAML. There are two ways to provide a configuration file:Pass directly through CLI option (-c|--config).Create a config file in predefined folders andPyfxwill load it with best effort.The predefined folders are searched in following order, with the first exist one has high priority.~/.config/pyfx/config.ymlsrc/pyfx/config/yaml/config.ymldefault configFor available configuration, seeconfiguration.Default ConfigurationThemeAlternative key bindings, seeTheme Configuration.NameDescriptionForeground ColorbodyPyfx body (JSON Browser)terminal defaultfootPyfx footer (Query Bar and Help Bar)grayfocusedfocused displaygrayAuto Complete PopUpautocomplete_popupautocomplete popupblackautocomplete_popup_focusedfocused display for autocomplete popupwhiteJSON Browserjson_keyobject keybluejson_stringstringtype valuegreenjson_integerintegertype valuecyanjson_numericnumerictype valuecyanjson_boolbooleantype valueyellowjson_nullnulltype valueredjson_focusedfocused display for JSONgrayKey BindingsAlternative key bindings, seeKey Bindings Configuration.KeyFunctionqexit pyfx (except in Query Bar)?open help page (except in Query Bar)JSON Browserupmove cursor up one linedownmove cursor down one lineeexpand allccollapse allentertoggle expansion.enter query window (used to input JSONPath query)Query Barenterapply JSONPath query and switch to JSON Browseresccancel query and restore to state before queryAutocomplete PopUpupmove cursor up one linedownmove cursor down one lineenterselect option and complete the queryescclose pop upHelp PopUpupmove cursor up one linedownmove cursor down one lineescclose the help popupKnown LimitationWhen open with very large JSON files, Pyfx will freeze on JSONPath query.The following statistics is tested at a MacBook Air (1.1GHz Quad-Core Intel Core i5
and 8GB RAM).File SizeFunctionalityUsability57MBDisplay JSONFairly good^^Query AutocompleteLatency <= 200ms^^Query JSONPathRoughly 1~2s latency570MBDisplay JSONSlow loading^^Query AutocompleteLatency <= 200ms. Give up with large data^^Query JSONPathUI may freeze depend on the search spaceLicenseThe code is underThe MIT License.ChangelogSee thechangelogfor a history of notable changes toPyfx.ContributorsAvery (@nullableVoidPtr)Zephyr Lykos (@mochaaP)How to ContributeIf you run into any issues, please let me know by creating a GitHub issue.