Я разработал образец кода, в котором я использую значок своего приложения, но он выглядит очень крошечным. Сейчас мой размер значка - 100 х 36. Когда я запускаю программу, значок выглядит очень крошечным. Я пытаюсь увеличить его размер, чтобы он был видимым для нас.
А также мне нужно очертить текст только полем, но граница создана для всей области метки.
Мой пример кода:
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()
Я не думаю, что вы можете изменить размер значка для своего приложения.
icon
Икона вашего приложения. Значок может быть расположен в том же каталоге, что и ваш основной файл.
Рекомендуемые 256x256 или 1024x1024? для GNU/Linux и Mac OSX 32x32 для Windows7 или менее. <= 256x256 для окон 8 256x256 действительно работает (по крайней мере в Windows 8), но уменьшен и не выглядит так же хорошо, как значок 32x32.
Чтобы нарисовать поле, окружающее текст, используйте следующее:
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])
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()