2

App icon

I have designed a sample code in which I am using my app icon but it looks very tiny. Right now my icon size is 100 x 36. When I run the program, icon looks really very tiny. I am trying to increase the size of it so it should be visible to us.

Border Box around the Text

And also I need to border the text only with box but the border is created to whole label area.

Problems

  • Is it possible to increase the size of icon?
  • I need only to box the label text.

My sample code:

from kivy.uix.floatlayout import FloatLayout
from kivy.app import App
from kivy.lang import Builder

Builder.load_string('''
<MainScreen>:
    GridLayout:
        orientation: 'vertical'
        cols: 1
        canvas.before:
            Color:
                rgba: 1, 1, 1, 1  
            Rectangle:
                pos: self.pos
                size: self.size
        GridLayout:
            padding: [10, 10, 10, 10]
            spacing: [10,10]
            orientation: 'vertical'
            cols: 1
            size_hint: 1, .1
            canvas:
                Color:
                    rgba: .1, .1, 1, .9
                Line:
                    width: 1.
                    rectangle: (self.x, self.y, self.width, self.height)
            Label:                 
                text: 'INPUTS'  
                color: 0,0,0,1 
        GridLayout:
            padding: [10, 10, 10, 10]
            spacing: [10,10]          
            orientation: 'vertical'
            cols: 1
            size_hint: 1, .1
            canvas:
                Color:
                    rgba: .1, .1, 1, .9
                Line:
                    width: 1.
                    rectangle: (self.x, self.y, self.width, self.height)
            Label:                 
                text: 'OUTPUTS' 
                color: 0,0,0,1 
''')
class MainScreen(FloatLayout):
    def __init__(self, **kwargs):
        super(MainScreen, self).__init__(**kwargs)

class TestApp(App):
    def build(self):
        self.icon = 'fif.png'
        self.title = 'sample_v_1.1'
        return MainScreen()

if __name__ == "__main__":
    TestApp().run()
Community
  • 1
  • 1
pashaa
  • 90
  • 9

1 Answers1

2

App Icon Size

I don't think that you can change the icon's size for your application.

Application » icon

icon

Icon of your application. The icon can be located in the same directory as your main file.

Recommended 256x256 or 1024x1024? for GNU/Linux and Mac OSX 32x32 for Windows7 or less. <= 256x256 for windows 8 256x256 does work (on Windows 8 at least), but is scaled down and doesn’t look as good as a 32x32 icon.

Box Border around Text

To draw a box surrounding the text use the following:

Snippet - kv file

        Label:
            canvas:
                Color:
                    rgba: .1, .1, 1, .9
                Line:
                    width: 1.
                    rectangle: (int(self.center_x - self.texture_size[0] / 2.), int(self.center_y - self.texture_size[1] / 2.), self.texture_size[0], self.texture_size[1])

Example

main.py

from kivy.app import App
from kivy.uix.floatlayout import FloatLayout
from kivy.lang import Builder

Builder.load_string('''
<MainScreen>:
    inputs: inputs
    outputs: outputs

    GridLayout:
        orientation: 'vertical'
        cols: 1
        canvas.before:
            Color:
                rgba: 1, 1, 1, 1  
            Rectangle:
                pos: self.pos
                size: self.size

        GridLayout:
            padding: [10, 10, 10, 10]
            spacing: [10,10]
            orientation: 'vertical'
            cols: 1
            size_hint: 1, .1

            Label:
                canvas:
                    Color:
                        rgba: .1, .1, 1, .9
                    Line:
                        width: 1.
                        rectangle: (int(self.center_x - self.texture_size[0] / 2.), int(self.center_y - self.texture_size[1] / 2.), self.texture_size[0], self.texture_size[1])
                id: inputs                 
                text: 'INPUTS'  
                color: 0,0,0,1 

        GridLayout:
            padding: [10, 10, 10, 10]
            spacing: [10,10]          
            orientation: 'vertical'
            cols: 1
            size_hint: 1, .1

            Label:
                canvas:
                    Color:
                        rgba: .1, .1, 1, .9
                    Line:
                        width: 1.
                        rectangle: (int(self.center_x - self.texture_size[0] / 2.), int(self.center_y - self.texture_size[1] / 2.), self.texture_size[0], self.texture_size[1])
                id: outputs                 
                text: 'OUTPUTS' 
                color: 0,0,0,1 
''')


class MainScreen(FloatLayout):
    pass


class TestApp(App):
    icon = 'ac013.png'
    title = 'sample_v_1.1'

    def build(self):
        return MainScreen()


if __name__ == "__main__":
    TestApp().run()

Output

Img01 - Box surround text

ikolim
  • 15,721
  • 2
  • 19
  • 29
  • oh thank you really I was struggling a lot for it thanks for your contribution. I need one more if possible please help me I have used buttons also which covers whole area of grid layout suppose I have used grid layout with 4 columns and near by 8 buttons they cover all area on screen I just need that buttons to cover only text or make all buttons of same size. Thank you very much. – pashaa Aug 31 '18 at 02:40
  • Could you please provide a sketch. – ikolim Aug 31 '18 at 18:43