On Dec 27, 2020, at 9:53 AM, Shoumik Das <shoum...@gmail.com> wrote:
Hi, I am building a simple Kivy app with a custom widget consisting of a horizontal box layout with an image and an image-button placed side-by-side. I am also trying to draw a line around each widget (image, image-button) to create borders. However, nothing is getting rendered on the screen. Can you please advise where I am going wrong?
--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/f8d93ebc-b01b-4222-9ce3-0d4ce7350616n%40googlegroups.com.

Code attached below. I made some changes to the canvas – but I think the issue was the name of some of the objects.
The python convention is that classes are in CamelCase. I have had issues where screens do not behave correctly if not in the CamelCase.
When I changed the names things appeared.
from kivy.config import Config
Config.set('graphics', 'resizable', True)
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.screenmanager import Screen
from kivy.uix.behaviors import ButtonBehavior
from kivy.uix.image import Image
from kivy.uix.actionbar import ActionBar, ActionItem
kv = """
<ImageButton>:
keep_ratio: True
<CustomActionButton>:
size_hint_x: 0.05
size_hint_min_x: '96dp'
<P3Page>:
orientation: 'horizontal'
size_hint_x: 0.95
size_hint_y: None
pos_hint: {'center_x':0.5}
height: '96dp'
# canvas.after:
# Color:
# rgba: 0,0,0,1 # 255/255, 255/255, 255/255, 1
# Line:
# width: dp(1)
# rectangle: (*self.pos, *self.size)
Label:
# source: 'images/picture-96.png'
# keep_ratio: True
text: 'The Image'
color: 1, 0, 0, 1
canvas.after:
Color:
rgba: 128/255, 128/255, 128/255, 1
Line:
width: dp(2)
rectangle: (*self.pos, *self.size)
Label:
size_hint_x: 0.4
text: 'The Image Button'
color: 1, 0, 0, 1
#source: {'normal': 'images/trash-96.png', 'down': 'images/trashgreen-96.png'} [self.state]
#on_release: root.delete_page()
canvas.after:
Color:
rgba: 128/255, 128/255, 128/255, 1
Line:
width: dp(2)
rectangle: (*self.pos, *self.size)
<P3MainScreen>: P3Page:
P3Page:
P3Page:
BoxLayout:
id: bottombar_layout
size_hint_y: None
height: '96dp'
orientation: 'horizontal'
ImageButton:
id: p3_add
size_hint_x: 0.05
size_hint_min_x: '96dp'
source: {'normal': 'images/plus-96.png', 'down': 'images/plusblue-96.png'} [self.state]
#on_release: root.add_image()
Label:
ImageButton:
id: p3_save
size_hint_x: 0.05
size_hint_min_x: '96dp'
source: {'normal': 'images/save-96.png', 'down': 'images/save-close-96.png'} [self.state]
#on_release: root.save_file()
P3MainScreen:
"""
class ImageButton(ButtonBehavior, Image):
pass
class CustomActionButton(ImageButton, ActionItem):
pass
class P3Page(BoxLayout):
pass
class P3MainScreen(Screen):
pass
class Silp3App(App):
def build(self):
return Builder.load_string(kv)
Silp3App().run()
From: Shoumik Das
Sent: Sunday, December 27, 2020 9:54 PM
To: Kivy users support
Subject: Re: [kivy-users] Border (outline) for custom widget with image and image-button
I can't see the screenshot embedded in my reply. Hence, re-attaching the file.
On Monday, December 28, 2020 at 10:20:49 AM UTC+5:30 Shoumik Das wrote:
Hi Elliot, I used the canvas on each widget but I still do not get any border. Does there have to be a line color? I am also not able to view the image and image-button that I defined in the widget (p3Page). I get a blank white screen. I am placing the custom widget inside a scrollview. Here is a screenshot. The updated kivy code is also shared.
Current Kivy Code
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/b65d3c7f-5ba4-486a-a8e4-92861431b89cn%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/90982787-428f-4fa2-be3b-2f9b10c49163n%40googlegroups.com.
There is not a mechanism built in. You can see the kv code used to create the default widgets in kivy/data/style.kv
Looking at the kv code, I created the code below. Use at your own risk. The kv code is unlikely to change – but I am using an undocumented id, to adjust the font size.
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.actionbar import ActionPrevious
from kivy.properties import NumericProperty
kv = """
BoxLayout:
orientation: 'vertical'
canvas:
Color:
rgb: .3, .3, .3
Rectangle:
size: self.size
pos: self.pos
ActionBar:
id: status_actionbar
ActionView:
use_separator: True
FSActionPrevious:
title: 'Action'
with_previous: False
font_size: 40
ActionOverflow:
ActionButton:
id: status-button
important: True
text: 'One'
ActionButton:
id: accounts-button
important: True
text: 'two'
ActionButton:
id: bot-button
important: True
text: 'three'
Label:
text: 'Action Bar Test'
Label:
text: 'height ' + str(status_actionbar.height)
"""
class FSActionPrevious(ActionPrevious):
font_size = NumericProperty(15)
def on_kv_post(self, base_widget):
self.ids.title.font_size = self.font_size
class ActionBarTestApp(App):
def build(self):
return Builder.load_string(kv)
ActionBarTestApp().run()
On Monday, December 28, 2020 at 10:20:49 AM UTC+5:30 Shoumik Das wrote:
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/CAH1Ve%3DS8602it9v1SFSHdzg1y7gh_2mh2_%3DOi8A%2B2YDESpu%3DGg%40mail.gmail.com.