Yes, thank you, this solved my problems, although using a label since <system-bold> doesn’t work with ui.draw_string seems like a bug workaround.
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.
Latest posts made by peiriannydd
-
RE: Custom views with bold text and rounded corners
-
Custom views with bold text and rounded corners
Two issues:
- When I try to create a custom view with the pyui I am unable to created rounded corners, but if instead I create the custom view without the pyui I get rounded corners.
- When I try to use <system-bold> font in a custom view the text is not bold.
How do I solve this? Thanks for any help!
Here is an example that illustrates both:
import ui class customButton(ui.View): def __init__(self,frame=(0,0,300,100)): self.corner_radius = 8 self.frame = frame self.text = 'why does only one of these have rounded corners and neither have bold text?' def draw(self): path = ui.Path.rounded_rect(0,0, self.width,self.height,self.corner_radius) ui.set_color('green') path.fill() ui.draw_string(self.text,(0,0,self.width,self.height),('<system-bold>',20),'black',ui.ALIGN_CENTER) #the pyui file consists of a single custom view, with # x=20 # y=200 # width=300 # height=100 # custom view class = customButton v = ui.load_view() cbn = customButton() v.add_subview(cbn) v.present('fullscreen')
-
RE: tableview.selected_row ambiguity?
Now instead of reading (0,0) when no rows are selected I read (0,<last_selected_row>) when no rows are selected
-
RE: tableview.selected_row ambiguity?
Sorry, I lost the indent tabs on the def: above
-
RE: tableview.selected_row ambiguity?
If you press the ‘check’ button when no rows are selected, it shows (0,0), the same as when the first row is selected:
import ui def check_selected_row(sender): #print(tbl.selected_row) lbl.text = str(tbl.selected_row) tbl.reload_data() v = ui.View(bg_color='white') tbl = ui.TableView(frame=(50,0,100,180)) data = ('zero','one','two') tbl.data_source=ui.ListDataSource(data) btn = ui.Button(frame=(250,100,0,0),bg_color='yellow',title='check',action=check_selected_row) lbl = ui.Label(frame=(50,220,100,100)) v.add_subview(btn) v.add_subview(tbl) v.add_subview(lbl) v.present('fullscreen')
-
tableview.selected_row ambiguity?
If I read tableview.selected_row, it returns (0,0) if the first row is selected, but it also returns (0,0) if no rows are selected. How can I tell whether the first row of a tableview is selected or not?
-
RE: ui.view.close() not working as expected
Thank you JonB! I knew I must be missing something, and I never would have figured that out.
-
ui.view.close() not working as expected
I’m sorry if this has an obvious answer, but I am unable to get this to work. I want to use a custom close button but it doesn’t work for me. What am I missing? Thank you!
v = ui.View()
b1 = ui.Button(title = "why doesn't this close button work?")
b1.frame = (50,100,270,50)
b1.background_color = '#d0d0d0'
b1.action = v.close()v.add_subview(b1)
v.present('fullscreen', hide_title_bar=True)``` -
RE: UI label with italics?
@mikael fantastic! Thank you so much. It works great. I really appreciate your time and @cvp to help out an inexperienced python user like me.