-
smath
Are you wanting to add a watermark to an existing PDF, or make a new PDF with a watermark? If you're making a new document you might want to check out reportlab.
-
smath
@JonB Just have to know where to look. II guess I haven't poked around the new version yet.
@ccc Good point. Fixed.
-
smath
@JonB, Thanks for the help. I admit I still don't totally understand how this is works. I haven't been able to find the source code for the ui module. Below is my working code. As with most of my code, I'm sure there's many ways to improve it. I had to change to using an
OrderedDict
so the order of elements would be preserved.import ui from collections import OrderedDict class MyTableViewDataSource (object): def tableview_number_of_sections(self,tableview): return len(self.data.keys()) def tableview_title_for_header(self,tableview,section): return self.data.keys()[section] def tableview_number_of_rows(self,tableview,section): key = self.data.keys()[section] return len(self.data[key]) def tableview_cell_for_row(self, tableview, section, row): # Create and return a cell for the given section/row key = self.data.keys()[section] cell = ui.TableViewCell() cell.text_label.text = self.data[key][row] return cell def fill_data(self, tableview, data): self.data = data multi_section = ui.TableView() multi_section.width = 400 multi_section.height = 400 table = OrderedDict([('Header1', ['element1', 'element2', 'element3']), ('Header2', ['element3', 'element4', 'element5']), ('Header3', ['element6', 'element7', 'element8']), ('Header4', ['element9', 'element10'])]) data = MyTableViewDataSource() multi_section.data_source = data data.fill_data(multi_section, table) multi_section.present('sheet')
-
smath
With the unfortunate demise of computable, an iPython notebook with pandas would be awesome.
-
smath
I'm working on this right now. My understanding is that the trick is making the right data source class as
ListDataSource
isn't made for multi section data. There is an example in the docs for this that I'm trying to work with, but for some reason my code is not working. I've been able to make a hard coded list that has multiple sections, but I'm trying to make a class to which I can feed a dictionary of the type shown in the code below and have it populate a tableview. Any ideas?# coding: utf-8 import ui class MyTableViewDataSource (object): def tableview_number_of_sections(self, tableview): # Return the number of sections (defaults to 1) return 0 def tableview_number_of_rows(self, tableview, section): # Return the number of rows in the section #print section return 0 def tableview_cell_for_row(self, tableview, section, row): # Create and return a cell for the given section/row cell = ui.TableViewCell() print 'cell name: ', row cell.text_label.text = row 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. print 'section: ', section return section def tableview_can_delete(self, tableview, section, row): # Return True if the user should be able to delete the given row. return False 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 False def fill_data(self, tableview, data): for section in data: self.tableview_title_for_header(tableview, section) for row in data[section]: self.tableview_cell_for_row(tableview, section, row) multi_section = ui.TableView() multi_section.width = 400 multi_section.height = 400 list = {'Header1': ['element1', 'element2', 'element3'], 'Header2': ['element3', 'element4', 'element5'], 'Header3': ['element6', 'element7', 'element8'], 'Header4': ['element9', 'element10']} data = MyTableViewDataSource() multi_section.data_source = data data.fill_data(multi_section, list) multi_section.present('sheet')
-
smath
Seems like submitting smaller reviews would be a faster way to find out what makes it past review. Then again, if a feature that Apple might not like got buried among a huge amount of other changes... I guess I can see an argument for larger releases. ;-)
-
smath
I'd be all about smaller realeses more often. I've been waiting for a long time for some of the features I've seen talked about on the forum. I've put myself on the list for the beta multiple times, but to no avail.
-
-
smath
For reference against the other iPad 3s, here's one that's still on ios 8.3.
import platform >>> platform.platform() 'Darwin-14.0.0-iPad3,1-32bit' >>> import timeit >>> timeit.timeit('import sympy') >>> 21.3953218460083
-
smath
Has anyone installed ios9 while runing pythonista 1.5 who can verify that ios9 won't break it? I seem to remember seeing a while back that one of the beta builds was addressing something having to do with ios9.
-
smath
If you have the workflow app, here's another solution for bringing in files that are open in other apps.
-
smath
@omz - You've likely already thought of doing this, but I wanted to see what your thoughts are. I would love to be able to see my code side by side (or top and bottom) with the console. This would be great for debugging purposes. Obviously, this would work best on an iPad with the bigger screen.
-
smath
Pythonista is still killed after a couple minutes of running in the background.
-
smath
I'm working on a script that takes a long time to run, and I'd like to make an action menu item to allow running any script in the background, but the following isn't working:
# coding: utf-8 import editor import notification import sound import os import urllib # download a silent mp3 if it's not there yet: if not os.path.exists('silence.mp3'): urllib.urlretrieve('http://www.xamuel.com/blank-mp3-files/1sec.mp3', 'silence.mp3') player = sound.Player('silence.mp3') player.number_of_loops = -1 # repeat forever player.play() # run the currently open file. I know execfile isnt ideal, but the other option I found is os.system, which didn't work, I think because it uses subprocessing.' execfile(editor.get_path()) # notify the user when the script is done. notification.schedule('Your script is done running', delay=0)
Thoughts?
-
smath
The code for the tabs in editmenu would probably be a good starting point. You just need something persistent like a shelve to remember what tabs you had open. The UI would likely need an overhaul to make sense for 1.6. The sidebar configuation wouldn't really make sense as you don't really need a persistent UI anymore. I'm on 1.5, so I don't know if sidebar UIs are even allowed anymore as I know omz had talked about getting rid of them.
-
smath
I'm working on a joystick UI element, and have run into some behavior I don't understand. For one, I find that the touch location seems to jump back and forth between the actual touch location, and some other location. The other is that I can pull the stick beyond the lower right boundry of the parent view even though the movement is successfully restricted in other directions.
Edit: fixed formatting. Thanks guys.
import ui from math import sin, cos, atan2, sqrt, pi class joystick(ui.View): #Sets up a view for the outside frame and one for the actual stick def __init__(self, stick_size, width): self.width = width self.height = width self.background_color = 'grey' self.corner_radius = self.width/2 self.border_width = 1 stick = ui.View() stick.width, stick.height = stick_size, stick_size stick.x, stick.y = self.width/2 - stick.width/2, self.width/2 - stick.width/2 stick.background_color = 'blue' stick.corner_radius = stick_size/2 stick.name = 'stick' self.pos = (0,0) self.add_subview(stick) def calc_pos(self, touch): x_comp = touch.location[0] - self.width/2 y_comp = self.width/2-touch.location[1] max_dist = self.width/2 - self['stick'].width/2 dist = sqrt(x_comp**2 + y_comp**2) #If the stick is not being pulled beyond the edge of the parent view, we just need to return the touch location if dist < max_dist: self.pos = (x_comp, y_comp) return touch.location #If the stick is pulled beyond the parent view boundry, limit the movement to the edge of the parent view else: angle = atan2(y_comp, x_comp) new_x = max_dist*cos(angle) new_y = max_dist*sin(angle) x_display = self.width/2 - self['stick'].width/2 + new_x y_display = self.width/2 - self['stick'].width/2 - new_y self.pos = (new_x, new_y) return x_display, y_display def touch_moved(self, touch): self['stick'].x, self['stick'].y = self.calc_pos(touch) def touch_ended(self, touch): self['stick'].x, self['stick'].y = self.width/2 - self['stick'].width/2, self.width/2 - self['stick'].width/2 stick = joystick(100, 200) stick.present('popover')
-
smath
I am on 1.5, so that's possible. I put my name on the list for the beta a while back but never heard anything in response.
-
smath
@ywang, I like your solution alot. I wish I'd known it could be that simple. Thanks!
@ccc, I'd like to simplify it, but self.bounds.center throws an error because the bounds attribute doesn't have a center attribute. I'm confused as to why I can't just do:
self['stick'].center = self.center