我正在关注这本kivy书,虽然我可以理解如何更改按钮的背景颜色,但我还没有找到关键字来更改文本颜色.
#!/usr/bin/kivy
import kivy
kivy.require('1.7.2')
from random import random
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.gridlayout import GridLayout
from kivy.graphics import Color, Ellipse, Rectangle
class MinimalApp(App):
title = 'My App'
def build(self):
root = RootLayout()
return(root)
class RootLayout(GridLayout):
pass
if __name__ == '__main__':
MinimalApp().run()
Run Code Online (Sandbox Code Playgroud)
#:kivy 1.7.2
#:import kivy kivy
<RootLayout>:
rows: 1
Label:
text: "Why does this not work?"
# rgba: 1,0,1,1 # doesn't work
# Color: # doesn't …Run Code Online (Sandbox Code Playgroud) 我决定在Kivy跨平台上做一些编程,并成功地在我的计算机上安装了Kivy.问题是,当我运行我的代码时,我收到此错误:
[INFO ] [Kivy ] v1.9.1
[INFO ] [Python ] v3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 20:20:57) [MSC v.1600 64 bit (AMD64)]
[INFO ] [Factory ] 179 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_gif, img_sdl2 (img_pil, img_ffpyplayer ignored)
[INFO ] [OSC ] using <thread> for socket
[INFO ] [Window ] Provider: sdl2
[INFO ] [GL ] GLEW initialization succeeded
[INFO ] [GL ] OpenGL version <b'1.1.0'>
[INFO ] [GL ] OpenGL vendor <b'Microsoft Corporation'>
[INFO ] [GL ] …Run Code Online (Sandbox Code Playgroud) 我无法让Kivy在Windows 7上使用PyCharm.我已经设法通过File> Settings> Python interpreters> Paths Tab添加大多数外部库.
我正在使用Kivy版本的Python.当我在PyCharm中使用[右键单击>发送到> kivy.bat]方法运行一个可以正常运行的Kivy应用程序时,它会给我这个错误:
Failed modules
Python 2.7.3 (C:/Python27/python.exe)
_imagingtk
dde
gtk._gtk
pangocairo
Generation of skeletons for the modules above will be tried again when the modules are updated or a new version of generator is available
Run Code Online (Sandbox Code Playgroud)
我认为问题可能与cython有关,因为我的文件无法识别kivy.properties文件,这是Cython*.pxd格式.
如果有人可以请我指向PyCharm和Kivy的Windows配置教程或给我解决我的问题,我将不胜感激!
我正在尝试制作一个表单应用程序,但我不明白错误:
TypeError: object.__init__() takes exactly one argument (the instance to initialize)
Run Code Online (Sandbox Code Playgroud)
代码在这里;
class Myapp(App):
def build(self):
return Grid1()
class Grid1(GridLayout):
def __init__(self,**kwargs):
super(Grid1,self).__init__(**kwargs)
self.cols=1
self.inside=GridLayout()
self.inside.cols=2
self.inside.add_widget(Label(text="Your name is :"))
self.name=TextInput(multiline=False)
self.inside.add_widget(self.name)
self.inside.add_widget(Label(text="Your Last name is :"))
self.lastname=TextInput(multiline=False)
self.inside.add_widget(self.lastname)
self.inside.add_widget(Label(text="Your email is :"))
self.email=TextInput(multiline=False)
self.inside.add_widget(self.email)
self.submit=Button(text="Submit",font=40)
self.add_widget(self.submit)
if __name__=="__main__":
Myapp().run()
Run Code Online (Sandbox Code Playgroud)
File ".\kivyprima.py", line 38, in <module> Myapp().run()
File "C:\Users\Alex\AppData\Local\Programs\Python\Python37\lib\site-packages\kivy\app.py", line 829, in run root = self.build()
File ".\kivyprima.py", line 10, in build return Grid1()
File ".\kivyprima.py", line 34, in …Run Code Online (Sandbox Code Playgroud) 我已经从 Kivy 在 Python 中安装了所有必要的代码,但是我需要的最后一个是python -m pip install kivy给我一个这样的错误:
ERROR: Dependency for context.pyx not resolved: config.pxi
ERROR: Dependency for compiler.pyx not resolved: config.pxi
ERROR: Dependency for context_instructions.pyx not resolved: config.pxi
ERROR: Dependency for fbo.pyx not resolved: config.pxi
ERROR: Dependency for gl_instructions.pyx not resolved: config.pxi
ERROR: Dependency for instructions.pyx not resolved: config.pxi
ERROR: Dependency for opengl.pyx not resolved: config.pxi
ERROR: Dependency for opengl_utils.pyx not resolved: config.pxi
ERROR: Dependency for shader.pyx not resolved: config.pxi
ERROR: Dependency for stencil_instructions.pyx not resolved: …Run Code Online (Sandbox Code Playgroud) 我想知道如何使用Python更改Kivy语言内部标签的文本.就像我如何将来自python的用户输入作为kivy中的标签文本.(顺便说一句,我在实际程序中的格式是正确的,但我把它粘贴到stackoverflow)如果我想让代码中的标签文本是python中生成的随机数,我该怎么做呢?那?
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.graphics import Color, Rectangle
from kivy.properties import ObjectProperty
# Create both screens. Please note the root.manager.current: this is how
# you can control the ScreenManager from kv. Each screen has by default a
# property manager that gives you the instance of the ScreenManager used.
Builder.load_string("""
<ButImage@ButtonBehavior+AsyncImage>
<TutImage@ButtonBehavior+AsyncImage>
<MenuScreen>:
GridLayout:
cols: 4
row_force_default: True
col_default_width: 175
row_default_height: 150
padding: 15
spacing: 15
canvas.before:
BorderImage:
# …Run Code Online (Sandbox Code Playgroud) 我正在尝试在Kivy中开发一个电子邮件应用程序,基本上只是作为一个练习来学习框架的内部和外部......我正在尝试创建初始窗口并且已经达到了一个绊脚石!我们的想法是,它只会在收件箱中显示电子邮件列表,就像移动设备上的任何基本电子邮件应用程序一样.
我遇到的问题是我无法弄清楚如何正确对齐每个列表项(这只是一个按钮)的文本.在我的按钮中使用"halign ='left'"将使文本左对齐,但仅相对于每个按钮; 它仍然位于每个按钮的中心位置.
我的实际应用程序有点大,所以这是一个快速而肮脏的例子我用Kivy股票的例子.(我意识到这段代码并不完美......就像我说的那样快速而又脏兮兮......虽然它确实有用!)正如你所看到的,每个按钮上的两行文字相互对齐,但是它们并非全部一致.任何人都可以建议我做什么来使所有文本对齐,比如说,从每个按钮的左边10px?我确实在StackOverflow上找到了一个相对的声音项目,但它没有真正回答问题,例如,它似乎更多地使用按钮上的图像.我是Kivy的新手,但我已经阅读了教程和文档,以及广泛搜索Google - 所以任何帮助将不胜感激!
import kivy
kivy.require('1.0.8')
from kivy.app import App
from kivy.core.window import Window
from kivy.uix.button import Button
from kivy.uix.scrollview import ScrollView
from kivy.uix.gridlayout import GridLayout
import random
class ScrollViewApp(App):
def build(self):
# create a default grid layout with custom width/height
layout = GridLayout(cols=1, spacing=10, size_hint=(None, None),
width=Window.width)
# when we add children to the grid layout, its size doesn't change at
# all. we need to ensure that the height will be the …Run Code Online (Sandbox Code Playgroud) 我想在kivy中创建一个实时图表.我怎样才能实现这一目标?我是kivy的新手.请帮我.
我在kivy写一个python应用程序.
这个想法是允许用户让用户记录某些日期的预订,然后程序应该在当天向他们发送关于预订的通知.
这可能是一个简单的方法,我正在使用plyer.
from plyer import notification
notification.notify(title="Kivy Notification",message="Plyer Up and Running!",app_name="Waentjies",app_icon="icon.png",timeout=10)
Run Code Online (Sandbox Code Playgroud)
这工作,每当我调用该函数时,我都会收到通知,但是,当应用程序未运行时,我无法找到任何方式发送此通知,我知道还有其他一些问题似乎可以回答这个问题,但他们不这样做,他们只是在后台运行一个应用程序,我不想这样做,我想要的就像你的部队准备战斗时的部落冲突通知,或当某人喜欢你的帖子时的facebook通知
任何与此相关的帮助.
谢谢
kivy ×10
python ×8
python-2.7 ×2
python-3.x ×2
android ×1
eclipse ×1
graph ×1
opengl ×1
opengl-es ×1
pycharm ×1
pydev ×1
pypy ×1
python-3.8 ×1
windows ×1
windows-10 ×1