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.
Latest posts made by peiriannydd
RE: Custom views with bold text and rounded corners
Custom views with bold text and rounded corners
- 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?
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')
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()