2016-11-18 86 views
1

我有兩臺監視器。如果我運行我的項目,它會出現在主顯示器上。我可以通過以下方式調整窗口大小並使其全屏: - >點擊右上角的全屏按鈕 - >將其拉到屏幕的頂部第二臺顯示器上的監聽鍵和全屏幕

像往常一樣爲微軟-視窗。

但是,如果我在第二個窗口中拉我的應用程序,這將改變。通過點擊全屏圖標,或將其拉至頂我會收到以下錯誤消息:

[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() 

我在添加鍵盤收聽功能之前,它能夠在兩臺顯示器上全屏顯示。 你能告訴我如何在兩臺顯示器上全屏顯示嗎?

+1

我認爲你的「小樣本」的定義是不同於SO共識。 – Billy

+0

使它更小。 – picibucor

回答

0

我編輯了以下文件的行#1141:

C:\ Python34 \ LIB \站點包\ kivy \核心\ window__init __ PY

行:

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 
相關問題