• keys = "C3 C3# D3 D3# E3 F3 F3# G3 G3# A3 A3# B3 C4 C4# D4 D4# E4 F4 F4# G4 G4#" piano_klist = [f"piano:{key}" for key in keys.split()]
  • Thank you @cvp for all your help and @Phuket2 for filtering code.
    I have put up the fully working version below.
    I use this to order a lot of books for our bookstore.
    I have the csv data file with a few thousand records of book title and book author.

    import ui items = [ ['Pretty Woman', 'Julia Roberts'], ['Seven Year Itch', 'Marilyn Monroe'], ['Casablanca' , 'Ingrid Bergman'], ['Roman Holiday','Audrey Hepburn'], ['African Queen','Katherine Hepburn'], ['Out Of Africa','Meryl Streep'], ['Cleopatra','Elizabeth Taylor'], ['Titanic','Kate Winslet'], ['Apartment','Shirley MacLaine'], ['West Side Story','Natalie Wood'], ['Rear Window','Grace Kelly'], ['Pillow Talk','Doris Day'], ['Sound Of Music','Julie Andrews'], ['Love Story','Ali McGraw'], ['You Got Mail','Meg Ryan'], ['Clueless','Alicia Silverstone'], ['Great Gatsby','Mia Farrow'], ['Mask','Cameron Diaz'], ['Kill Bill', 'Uma Thurman'], ] w,h = ui.get_screen_size() h=h-64 gap = 5 fontsize = 15 if w<750 else int((w / 75) + 16) class MyTableViewDataSource (object): def tableview_cell_for_row(self, tableview, section, row): row_title, row_description = tableview.data_source.items[row] # 'subtitle'-style cells come with a built-in secondary label cell = ui.TableViewCell('subtitle') cell.text_label.text = row_title cell.text_label.text_color = 'blue' cell.detail_text_label.text = row_description cell.detail_text_label.text_color = 'slateblue' return cell def tableview_number_of_rows(self, tableview, section): return len(tableview.data_source.items) class MyTableViewDelegate (object): def tableview_did_select(self, tableview, section, row): main, desc = tableview.data_source.items[row] print(f'{main}, {desc}') class MyTextFieldDelegate (object): items = items or [] def textfield_did_change(self, textfield): self.filter_data(textfield.text) def filter_data(self, filter_text=''): ft = filter_text.lower() if not len(ft): tbl.data_source.items = self.items tbl.reload() else: tbl.data_source.items = [s for s in self.items if (ft in s[0].lower()) or (ft in s[1].lower())] tbl.reload() view = ui.View(name='Filter Items', frame =(0,0,w,h), bg_color='slateblue') tf = ui.TextField(frame=(gap,gap,w-gap*2,32), flex='w', placeholder='Search', clear_button_mode='always') tf.delegate = MyTextFieldDelegate() view.add_subview(tf) tbl = ui.TableView(frame=(gap,42,w-gap*2,h-42), corner_radius=3, flex='wh') tbl.row_height=fontsize*2.5 tbl.name = 'Item Table' tbl.separator_color = 'grey' tbl.data_source = MyTableViewDataSource() tbl.data_source.items = items tbl.delegate = MyTableViewDelegate() view.add_subview(tbl) view.present('sheet', title_bar_color= 'slateblue')
  • @ramvee , you are welcome. I did remember posting that after seeing this msg. But for sure, @omz, @JonB or @ccc helped me to get to the point to write it. I remember struggling with the ui.ImageContext and after some guidance was able to put that post together. Mind you its all in the docs, but some times even if the docs are well written it can be hard to get the idea.
    You are right the forum is difficult to search.
    But its worth using some google search tricks to search the forum. Gives you a lot better results. One example "forum search site:forum.omz-software.com ui.ImageContext", there are other syntax's for using googles search methods for sites. I dont really know them.
    I have to get back in touch with a user from this forum called @cook. He made a Pythonista forum search browser that you launch from the wrench menu and opens up a browser in a panel in Pythonista. When he was building it, I was helping him, mainly testing it, offering suggestions. The version I have is not 100% polished but still works well enough. He did some things with .js and some other tricks to allow you keep searching google without it shutting you down as google does if you query it too many times through an API. I will try and touch base with him again to see if it actually did more work on it, or see if he is willing for it to be shared so maybe some others could contribute to it. I dont think its rocket science, but there is stuff in there I dont understand. You can also copy the python code blocks to the clipboard.
    Seems like Pythonista could use a very polished version of something like this.

  • Thank you very much @ccc for your constant support and prompt help.

    Yes, I found some old file, i had named matplotlib.py ,
    I have renamed it and now everything works fine.
    Silly mistake on my part when i started with pythonista.

  • @Phuket2
    Very nice example, my friend thank you!
    I will try and learn it!
    Grateful 😁

  • @cvp , lol, I get your meaning. But the list is a lot longer. Many helpful guys here. I read a lot of the posts, but I just don't know the answer so I can't help. I am sure many others the same. But I get more help than I give. Just works out that way :)
    Regardless, the bottom line is it's a great community here.

  • @JonB
    Thank You For Your Prompt Reply_/_
    Works Perfectly Now!
    Namaste !

  • Thank You @dgelessus ,
    I have been sitting and editing JSON data files manually, inserting \n \b..

  • @JonB Thank You For Prompt Reply, JSON module, works perfectly for me. Grateful _/_

  • Thank You For The Helpful Options @dgelessus !
    Finally I am getting somewhere.. with UI module in Pythonista!

  • @ramvee Whoops, you are correct. looks like your code works as written.

  • @ramvee , I did make an error by referring to parent views. Technically it's correct, but the superview property is the parent view when it comes to ui.Views. Eg, you create a ui.View/element, the superview property will be None until you call the add_subview() method. But it would have been more correct to talk about superviews rather than a parent view.

Internal error.

Oops! Looks like something went wrong!