我有两台显示器。如果我运行我的项目,它将出现在主监视器上。我可以通过以下方式调整窗口大小并使其全屏显示: - >单击右上角的全屏按钮 - >将它拉到屏幕顶部
与Microsoft-Windows一样。
但是如果我在第二个窗口中拉我的应用程序,这会改变。通过单击全屏图标,或将其拉到顶部,我将收到以下错误消息:
[INFO ] [Logger ] Record log in C:\Mirk\CETACal\logs\kivy_16-11-18_53.txt
[INFO ] [Kivy ] v1.9.2-dev0
[INFO ] [Python ] v3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 20:20:57) [MSC v.1600 64 bit (AMD64)]
[INFO ] [Factory ] 193 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_gif, img_sdl2, img_pil (img_ffpyplayer ignored)
[INFO ] [Text ] Provider: sdl2
[INFO ] [OSC ] using <thread> for socket
[INFO ] [Window ] Provider: sdl2
[INFO ] [GL ] GLEW initialization succeeded
[INFO ] [GL ] OpenGL version <b'4.3.0 - Build 10.18.14.4432'>
[INFO ] [GL ] OpenGL vendor <b'Intel'>
[INFO ] [GL ] OpenGL renderer <b'Intel(R) HD Graphics 4600'>
[INFO ] [GL ] OpenGL parsed version: 4, 3
[INFO ] [GL ] Shading version <b'4.30 - Build 10.18.14.4432'>
[INFO ] [GL ] Texture max size <16384>
[INFO ] [GL ] Texture max units <32>
[INFO ] [Window ] auto add sdl2 input provider
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
[INFO ] [Base ] Start application main loop
[INFO ] [GL ] NPOT texture support is available
[INFO ] [Base ] Leaving application in progress...
Traceback (most recent call last):
File "C:\Mirk\CETACal\cls\test4.py", line 67, in <module>
ChildApp().run()
File "C:\Python34\lib\site-packages\kivy\app.py", line 828, in run
runTouchApp()
File "C:\Python34\lib\site-packages\kivy\base.py", line 487, in runTouchApp
EventLoop.window.mainloop()
File "C:\Python34\lib\site-packages\kivy\core\window\window_sdl2.py", line 637, in mainloop
self._mainloop()
File "C:\Python34\lib\site-packages\kivy\core\window\window_sdl2.py", line 390, in _mainloop
EventLoop.idle()
File "C:\Python34\lib\site-packages\kivy\base.py", line 327, in idle
Clock.tick()
File "C:\Python34\lib\site-packages\kivy\clock.py", line 581, in tick
self._process_events()
File "kivy\_clock.pyx", line 368, in kivy._clock.CyClockBase._process_events (kivy\_clock.c:7392)
File "kivy\_clock.pyx", line 398, in kivy._clock.CyClockBase._process_events (kivy\_clock.c:7269)
File "kivy\_clock.pyx", line 396, in kivy._clock.CyClockBase._process_events (kivy\_clock.c:7190)
File "kivy\_clock.pyx", line 168, in kivy._clock.ClockEvent.tick (kivy\_clock.c:3300)
File "C:\Python34\lib\site-packages\kivy\core\window\__init__.py", line 543, in _upd_kbd_height
self._keyboard_changed = not self._keyboard_changed
File "kivy\properties.pyx", line 423, in kivy.properties.Property.__set__ (kivy\properties.c:5212)
File "kivy\properties.pyx", line 461, in kivy.properties.Property.set (kivy\properties.c:5973)
File "kivy\properties.pyx", line 516, in kivy.properties.Property.dispatch (kivy\properties.c:6637)
File "kivy\_event.pyx", line 1225, in kivy._event.EventObservers.dispatch (kivy\_event.c:13521)
File "kivy\_event.pyx", line 1131, in kivy._event.EventObservers._dispatch (kivy\_event.c:12723)
File "kivy\properties.pyx", line 1394, in kivy.properties.AliasProperty.trigger_change (kivy\properties.c:22410)
File "kivy\properties.pyx", line 1400, in kivy.properties.AliasProperty.trigger_change (kivy\properties.c:22301)
File "kivy\properties.pyx", line 516, in kivy.properties.Property.dispatch (kivy\properties.c:6637)
File "kivy\_event.pyx", line 1225, in kivy._event.EventObservers.dispatch (kivy\_event.c:13521)
File "kivy\_event.pyx", line 1131, in kivy._event.EventObservers._dispatch (kivy\_event.c:12723)
File "C:\Python34\lib\site-packages\kivy\core\window\__init__.py", line 778, in <lambda>
keyboard_height=lambda *dt: self.update_viewport())
File "C:\Python34\lib\site-packages\kivy\core\window\__init__.py", line 1141, in update_viewport
targettop = max(0, target.to_window(0, target.y)[1]) if target else 0
AttributeError: 'ChildApp' object has no attribute 'to_window'
这是一个小样本,仅用于演示我的问题:
from kivy.config import Config
Config.set('kivy', 'exit_on_escape', '0')
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.popup import Popup
from kivy.core.window import Window
from kivy.properties import ObjectProperty, ListProperty, StringProperty
from kivy.logger import Logger
class ChildApp(App):
def __init__(self, sys_path_list=None):
super(ChildApp, self).__init__()
# Hotkey
self.superkey = []
text = StringProperty()
keyboard = Window.request_keyboard(self._keyboard_released, self)
keyboard.bind(on_key_down=self._keyboard_on_key_down, on_key_up=self._keyboard_released)
def _keyboard_released(self, *args):
self.superkey = []
def _keyboard_on_key_down(self, window, keycode, text, super):
if 'lctrl' in self.superkey and keycode[1] == 's':
Logger.info('DO SOMETHING')
self.superkey = []
return False
elif 'lctrl' not in self.superkey and keycode[1] in ["lctrl"]:
self.superkey.append(keycode[1])
return False
else:
Logger.info("key {} pressed.".format(keycode))
return False
def build(self):
Window.bind(on_request_close=self.on_request_close)
return Label(text='Child')
def on_request_close(self, *args):
Logger.info('Are you sure?')
return True
if __name__ == '__main__':
ChildApp().run()
在添加按键功能之前,我能够在两台显示器上全屏显示。 你能告诉我怎么能在两台显示器上全屏显示它?
答案 0 :(得分:0)
我编辑了以下文件的第1141行:
C:\ Python34 \ LIB \站点包\ kivy \芯\ window__init __吡啶
行:
targettop = max(0, target.to_window(0, target.y)[1]) if target else 0
编辑为:
if target and 'to_window' in dir(target):
targettop = max(0, target.to_window(0, target.y)[1])
else:
targettop = 0