Kivy调用Pygame程序时界面偏移缩放及关闭无响应问题求助
问题说明
- 在Kivy开发的项目中调用Pygame程序后,Pygame窗口尺寸与代码定义一致,但界面元素出现轻微缩小并向左上方偏移的异常。
- Kivy与Pygame界面同时运行时,Pygame窗口的关闭按钮点击无响应。
界面对比
- 与Kivy界面同时运行时:

- Pygame独立运行时:

相关代码片段
import os from kivy.uix.screenmanager import Screen from kivy.uix.boxlayout import BoxLayout from kivy.uix.button import Button from kivy.metrics import dp class Corrections(Screen): pass class Correc(BoxLayout): def __init__(self,**kwargs): self.pp = open("corrections.txt", "r") super().__init__(**kwargs) self.orientation = "vertical" self.spacing = dp(5) self.pos_hint = {"top":1} for i, line in enumerate(self.pp.readlines()): b = Button( text=line, size_hint=(.8, None), pos_hint={"x": .1}, height=dp(40), on_press=lambda x:self.transit() ) self.add_widget(b) def opener(self, line): u = r"C:\myown\computer\Assassin simulate" + line.rstrip("\n") + ".pdf" os.startfile(u)
内容的提问来源于stack exchange,提问作者Lord vic
相关产品推荐
相关产品推荐

