如何在kivy中更改窗口图标的大小

问题描述 投票:1回答:1

App icon

我设计了一个示例代码,其中我使用的是我的应用程序图标,但它看起来非常小。现在我的图标大小是100 x 36.当我运行程序时,图标看起来非常小。我正在尝试增加它的大小,以便我们可以看到它。

Border Box around the Text

而且我还需要将文本与框边界边框,但边框创建到整个标签区域。

Problems

  • 是否可以增加图标的大小?
  • 我只需要打开标签文字。

我的示例代码:

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()
python kivy border box
1个回答
2
投票

App Icon Size

我认为您不能更改应用程序的图标大小。

Application » icon

icon

您的应用程序的图标。该图标可以与主文件位于同一目录中。

推荐256x256或1024x1024?适用于Windows7或更低版​​本的GNU / Linux和Mac OSX 32x32。 <= 256x256 for windows 8 256x256确实有效(至少在Windows 8上),但是按比例缩小并且看起来不如32x32图标。

Box Border around Text

要绘制文本周围的框,请使用以下内容:

片段 - kv文件

        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

卖弄.朋友

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

© www.soinside.com 2019 - 2024. All rights reserved.