Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
A copy code button here in the forum.
-
@Phuket2
I will use SQLite. At first when I was learning I tried pickle, but SQLite is better in many ways! And it's not too difficult!I do have a thought about having data stored externally- and this would give a kind of "buffer" for the RSS data, and perhaps even a method of retrieving other information (like the thread url.) anyway- it would certainly solve the issue of having a limited RSS feed. Alternatively omz could change the feed to have more entries!
I also thought about @name mentions being useful in this thing, but for having 20 entries to read through, it may not be a big deal yet!
I currently don't store any snippets or notes about what I learn. I suppose I should!! There are many times that I'm typing out the same thing- but I guess that helps me remember it better too.
What could be done is an easy action extension that stores snippets (with SQLite) and then pulls them up in a tableview. When selecting a cell it inserts where your curser is. Check out editor module for that bit. You could even make it fancy with some categories!I'm not really sure what you mean about tableviewcell subtitle, value1, value 2....something I haven't seen. Do you have an example.
I just know I can set a simple label like <code>cell.text_label.text = ''</code>
If I could do a subtitle that'd be great!Also, in case you ever forget again- here's an easy way to remember how to put in your Dropbox inline image in markdown. That is- don't remember!!:
<pre><code>
import re
import clipboarda = clipboard.get()
if 'dropbox' in a:
a = '' % re.sub('dl=0','raw=1',a)
clipboard.set(a)
</code></pre>If you're really stuck in the future, you can get shirts printed with the text on it: ?raw=1
Should get some good attention! -
@cook
Yes, sure I agree SQLite is more flexible than pickle. Yes, I think SQLite is pretty easy also. But pickle serves a particular purpose as does a database. In my movie app I am making for my friend, I am just using pickle. Basically static lists of dicts. They are not huge, also they don't need updates , inserts etc. I will need to update his data from time to time, but I will just rewrite the whole file. Is super fast. I will also have a few dynamic files, but again, small and very quick. But of course scalability is an issue also. For the app I am doing, scalability is not an issue with the text data.the @name would be still useful if you are storing post entries. So if nothing was to change with the 20 items returned from the RSS feed, day one you have 20 items, day2 you have day 1 + the additional items and so on.. Hmmm, given you run your code often enough :) but, same as the movie, field of dreams, you build it they will come :) I am sure this will be overcome given the demand is there.
I see what you are saying about the snippets. For some reason, does not turn me on writing my own solution. There must be a app out there that can do it. Thanks for the code for Dropbox. I will copy it into OneNote, which is the latest thing I am trying for note taking about pythonista and python. :(
With the tableview, yes you can do a subtitle. I am not sure if you are using the standard ListDataSource or providing your own data_source. But once you have the hang of it, it's easy. I will follow up this post with an example.
-
@cook, I hope this example makes sense. Again, I am not sure how you are using tableview. This is a stupid example, but just to illustrate. I have copied all the methods into my custom class for the tableview's data_source and delegate. Just to be complete. But 90% of the code is not required for this simple example. Anyway, I hope it helps.
import ui, console class TestTableView(ui.View): def __init__(self): # crap data for the tableview self.data = range(100) #create tableview tv = ui.TableView() tv.name = 'tv' # name param does not work # the data/delagate methods called by # tableview will be called in this class tv.data_source = self tv.delegate = self # add the table self.add_subview(tv) def layout(self): self['tv'].frame = self.bounds # prototype methods copied from pytonista help file def tableview_number_of_sections(self, tableview): # Return the number of sections (defaults to 1) return 1 def tableview_number_of_rows(self, tableview, section): # Return the number of rows in the section return len(self.data) def tableview_cell_for_row(self, tableview, section, row): # Create and return a cell for the given section/row # IMPORTANT # ui.TableViewCell() has 4 params # empty = default # subtitle # value1 # value2 # beware, if you create a cell with no params # the default, cell.detail_text_label does # not exist and will produce an error if # you try and reference it! the other cell # types subtitle, value1, value2 have the # cell.detail_text_label. # you can also mix cell types, if it makes # sense. cell = ui.TableViewCell('subtitle') cell.text_label.text = 'row {}'.format(row) cell.detail_text_label.text = '{}'.format(row * 10) return cell def tableview_title_for_header(self, tableview, section): # Return a title for the given section. # If this is not implemented, no section headers will be shown. #return 'Some Section' pass def tableview_can_delete(self, tableview, section, row): # Return True if the user should be able to delete the given row. return True def tableview_can_move(self, tableview, section, row): # Return True if a reordering control should be shown for the given row (in editing mode). return True def tableview_delete(self, tableview, section, row): # Called when the user confirms deletion of the given row. pass def tableview_move_row(self, tableview, from_section, from_row, to_section, to_row): # Called when the user moves a row with the reordering control (in editing mode). pass # delegate method prototypes, copied from #pythonista help files def tableview_did_select(self, tableview, section, row): # Called when a row was selected. console.hud_alert('Row {} selected'.format(self.data[row]), duration = 1) #pass def tableview_did_deselect(self, tableview, section, row): # Called when a row was de-selected (in multiple selection mode). pass def tableview_title_for_delete_button(self, tableview, section, row): # Return the title for the 'swipe-to-***' button. return 'Delete' if __name__ == '__main__': ttv = TestTableView().present()
-
@cook, same example as above but with all the non required methods taken out. The above looks messy. A lot of comments and methods that don't need to be called.
One great thing I learned from @omz by mistake was setting the data_source and delegate to self in a custom class rather than writing explicit data_source and delegate objects. I think those with a greater understanding of Python than me would have got that, maybe you did also. I didn't. But makes supporting a tableview very simple. It's not to say to create those objects are difficult, but you end up passing data around and the more code you get, it seems more complicated. In actual fact, I don't think it is, just it feels that way. I don't know how many files you have in your project now, but is it getting overwhelming ? My projects have been overwhelming me. But, it's more about my approach and understanding. Long ago, I have written very big projects. Mixture of languages. We were not great at it, but for the times we were ok. Now i am struggling to keep everything together with very small apps. But as each day passes, learn more and more.
I find python very difficult in a sense. In c, you Learn to do things in a certain way and get used to it. Granted, the biggest problem can be that's it's hard to impossible for other programmers to read your code. I loved pointers in c, never used subscripts unless I had to. Python seems so powerful, at so many levels. But the felixibily of Python is somewhat scary. Maybe it sounds strange, given it calls c Libs, but I think python would scare a lot of c programmers at first. Well, that's what I think anyway.
import ui, console class TestTableView(ui.View): def __init__(self): # crap data for the tableview self.data = range(100) #create tableview tv = ui.TableView() tv.name = 'tv' # name param does not work # the data/delagate methods called by # tableview will be called in this class tv.data_source = self tv.delegate = self # add the table self.add_subview(tv) def layout(self): self['tv'].frame = self.bounds def tableview_number_of_rows(self, tableview, section): return len(self.data) def tableview_cell_for_row(self, tableview, section, row): cell = ui.TableViewCell('subtitle') cell.text_label.text = 'row {}'.format(row) cell.detail_text_label.text = '{}'.format(row * 10) return cell def tableview_did_select(self, tableview, section, row): console.hud_alert('Row {} selected'.format(self.data[row]), duration = 1) if __name__ == '__main__': ttv = TestTableView().present('sheet')