Last active
March 12, 2016 10:51
-
-
Save wradlib/9037b8a67dfbcff3b7de to your computer and use it in GitHub Desktop.
Simple TreeView using traits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# adapted with help from | |
# http://stackoverflow.com/questions/15023333/simple-tool-library-to-visualize-huge-python-dict | |
from traits.api import HasTraits, Instance | |
from traitsui.api import View, VGroup, Item, ValueEditor | |
from wradlib.io import read_Rainbow | |
def ex_load_rainbow(): | |
filename = '/path/to/your/rainbow5-file' | |
# load rainbow file contents to dict | |
rbdict = read_Rainbow(filename, loaddata=False) | |
class DictEditor(HasTraits): | |
Object = Instance(object) | |
def __init__(self, obj, **traits): | |
super(DictEditor, self).__init__(**traits) | |
self.Object = obj | |
def trait_view(self, name=None, view_elements=None): | |
return View( | |
VGroup( | |
Item('Object', | |
label='Debug', | |
id='debug', | |
editor=ValueEditor(), # ValueEditor() | |
style='custom', | |
dock='horizontal', | |
show_label=False), ), | |
title='Dictionary Editor', | |
width=800, | |
height=600, | |
resizable=True) | |
def dic(my_data): | |
b = DictEditor(my_data) | |
b.configure_traits() | |
dic(rbdict) | |
# ======================================================= | |
if __name__ == '__main__': | |
ex_load_rainbow() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment