python - 防止 Kivy 留下调试信息

标签 python user-interface debugging terminal kivy

我有一个简单的 Kivy 界面,它也使用终端。

示例代码:

import kivy

kivy.require('1.0.6')

from kivy.app import App
from kivy.uix.label import Label

class MyApp(App):
    def build(self):
        return Label(text = 'Hello')

MyApp().run()

问题是,每当我启动脚本时,我都会得到这个:

[INFO   ] [Logger      ] Record log in C:\Users\Simon\.kivy\logs\kivy_18-05-12_37.txt
[INFO   ] [Kivy        ] v1.10.0
[INFO   ] [Python      ] v3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)]
[INFO   ] [Factory     ] 194 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[INFO   ] [Text        ] Provider: sdl2
[INFO   ] [OSC         ] using <thread> for socket
[INFO   ] [Window      ] Provider: sdl2
[INFO   ] [GL          ] Using the "OpenGL" graphics system
[INFO   ] [GL          ] GLEW initialization succeeded
[INFO   ] [GL          ] Backend used <glew>
[INFO   ] [GL          ] OpenGL version <b'4.5.13467 Compatibility Profile Context 21.19.414.1280'>
[INFO   ] [GL          ] OpenGL vendor <b'ATI Technologies Inc.'>
[INFO   ] [GL          ] OpenGL renderer <b'AMD Radeon R7 Graphics'>
[INFO   ] [GL          ] OpenGL parsed version: 4, 5
[INFO   ] [GL          ] Shading version <b'4.50'>
[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...

我发现这是Kivy的自动调试信息。我该如何阻止它们(或至少隐藏以便我可以使用终端)?

最佳答案

docs所示,您应该只执行以下操作:

import os
os.environ["KIVY_NO_CONSOLELOG"] = "1"

import kivy
...

关于python - 防止 Kivy 留下调试信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50308757/

相关文章:

python - 遇到从 Dataflow 管道向 BigQuery 进行缓慢流式写入的问题?

python - Django 和 Oracle DB 失去联系

java - 如何在javafx中绘制一条直线,当用户移动鼠标时它会自行更新?

Eclipse Luna 在调试遇到断点时给出 NullPointerException

debugging - 如何记录 CLR/.Net 中的所有垃圾收集事件?

debugging - ANTLR “Cannot launch the debugger. Time-out waiting to connect to the remote parser.”

python - 如何从 C 代码调用 Python 代码?

python - 如何从调用者访问变量,即使它不是封闭范围(即实现动态范围)?

android - textView 动态更改为较短的文本而不是椭圆大小

java - 我无法从 AbstractAction 内部类中声明的 actionPerformed 设置不可见的 JFrame,如何解决?