我们目前正在使用python-kivy项目的小组工作,在该项目中,我们开发了一个旨在使用XCode为iOS发行的应用程序。目前,我们面临的问题是,我们使用kivy,比例尺和对象在设备上以不同的方式构建的GUI。我们在小组中使用Windows和macOS(都使用相同的Python版本3.7.5和kivy 1.11.1)。奇怪的是,即使在我们的两个macOS设备之间,也有一些小部件,例如TextInput(微调器图像)的缩放比例不同。
受影响的“不良”窗口小部件的编写与看起来没有任何问题的窗口小部件没有什么不同。尤其是猕猴桃Popups的大小非常凌乱。在一台Macbook上,它占据了大约一半的屏幕,而另一台Macbook上则覆盖了整个屏幕,这使得无法关闭弹出窗口,从而导致应用程序出现故障。
这样,几乎不可能只有一个人就能完成所有调整,而要像一个小组那样从事一个项目。关于如何解决此问题,是否有解决方案或建议?我们已经包含Window.size参数,并禁用了调整预览窗口大小的功能,以在所有设备上具有相同的分辨率。这是.kv文件之一的示例,其中微调器的自定义图像缩放比例不同,并且文本线在我们所有设备中的位置完全不同。对于该示例,我删除了所有功能(on_release,id等),因为它们不会影响格式。屏幕构建(上下):2个微调器,1个TextInput,3个按钮,NavigationBar incl。 2个按钮。
<EditLocation>:
FloatLayout:
#Background color
canvas:
Rectangle:
size: self.size
pos: self.pos
source: "graphics/background/background_main.png"
#Display of ID and input fields
GridLayout:
cols: 1
size_hint: 1, .25
pos_hint: {"top": 1, "right": 1}
GridLayout:
cols: 2
SpinnerWidget:
text: "Select Country"
background_normal: 'graphics/buttons/dropdown_country.png'
background_down: 'graphics/buttons/dropdown_country_pressed.png'
SpinnerWidget:
text: "Select City"
background_normal: 'graphics/buttons/dropdown_city.png'
background_down: 'graphics/buttons/dropdown_city_pressed.png'
Label:
text: "Location"
TextInput:
hint_text: "Name of Location"
multiline: False
canvas.before:
Color:
rgba: 1, 1, 1, 1
Line:
points: self.x + 5, self.y +30, self.x + self.width, self.y +30
width: 1
#Delete and Update
GridLayout:
cols: 3
pos_hint: {"top": .22, "right": 1}
size_hint: 1, .2
ImageButton:
source: "graphics/buttons/delete.png" if self.state == 'normal' else "graphics/buttons/delete_pressed.png"
ImageButton:
source: "graphics/buttons/update.png" if self.state == 'normal' else "graphics/buttons/update_pressed.png"
ImageButton:
source: "graphics/buttons/undo.png" if self.state == 'normal' else "graphics/buttons/undo_pressed.png"
#Navigation Bar Background
LabelButton:
pos_hint: {"top": .0925, "right": 1}
size_hint: 1, .1
canvas.before:
Color:
rgb: utils.get_color_from_hex("#fafafa")
Rectangle:
size: self.size
pos: self.pos
#Navigation Bar (5 Image Buttons)
GridLayout:
cols: 2
pos_hint: {"top": .0825, "right": 1}
size_hint: 1, .0725
ImageButton:
source: "graphics/navigation/add_person.png" if self.state == 'normal' else "graphics/navigation/add_person_pressed.png"
ImageButton:
source: "graphics/navigation/back.png" if self.state == 'normal' else "graphics/navigation/back_pressed.png"
我们正在与PyCharm合作,问题出现在预览窗口中。 谢谢!