我在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通知
任何与此相关的帮助.
谢谢
我想创建一个将使用一个程序os来做出ls一个目录,然后把文件阵列英寸 然而,ls没有一一列出名字,所以我有点卡住了,因为没有什么恒定的可以告诉我下一个名字是什么时候开始的。
这是实际的代码:
import os
cd = input("Change directory to: ")
while cd != "x":
os.chdir(cd)
command = os.popen('ls')
ls = command.read()
print(ls)
cd = input("Change directory to: ")
count = 0
word = ""
for character in ls:
while count == 0 :
if character!= " ":
count = 1
word += character
elif character == " ":
print(word)
Run Code Online (Sandbox Code Playgroud)
所以这个想法是,当程序启动时,它应该询问您要更改到哪个目录,然后ls在该目录上运行。然后,如果您输入 back x,它应该只将第一个目录打印到屏幕上。但是,正如我所说,它只是打印整个列表。
有人可以帮我解决这个问题吗?
任何帮助表示赞赏。谢谢!
所以我想构建一个 kivy 程序,它基本上只是倒计时特定的分钟和秒。
这是我走了多远:
from kivy.app import App
from kivy.uix.label import Label
from kivy.clock import Clock
from datetime import datetime, date, time
class IncrediblyCrudeClock(Label):
a = time(0, 1, 1)
def update(self, *args):
self.text = str(self.a)
print(str(self.a))
self.a = datetime.combine(date.today(), self.a) - datetime.combine(date.today(), time(0,0,1))
class TimeApp(App):
def build(self):
crudeclock = IncrediblyCrudeClock()
Clock.schedule_interval(crudeclock.update, 1)
return crudeclock
if __name__ == "__main__":
TimeApp().run()
Run Code Online (Sandbox Code Playgroud)
问题是,当我尝试从新时间中扣除旧时间时,显示的时间减少了 1 秒,出现以下错误:
self.a = datetime.combine(date.today(), self.a) datetime.combine(date.today(), time(0,0,1))
TypeError: combine() argument 2 must be datetime.time, not datetime.timedelta
Run Code Online (Sandbox Code Playgroud)
这让我觉得,在第一次 sustraction 之后, …
我是面向对象编程的新手,我想做什么基本上是在一个类里面打印一个变量,我认为这可能是一个非常简单的答案,但我只是想弄清楚,谢谢你的帮助,继承人我的代码:
class test():
def test2():
x = 12
print(test.test2.x)
Run Code Online (Sandbox Code Playgroud)
这给了我以下错误:
Traceback (most recent call last):
File "/home/vandeventer/x.py", line 4, in <module>
print(test.test2.x)
AttributeError: 'function' object has no attribute 'x'
Run Code Online (Sandbox Code Playgroud)
当我尝试:
class test():
def test2():
x = 12
print(test.x)
Run Code Online (Sandbox Code Playgroud)
我得到:
Traceback (most recent call last):
File "/home/vandeventer/x.py", line 4, in <module>
print(test.x)
AttributeError: type object 'test' has no attribute 'x'
Run Code Online (Sandbox Code Playgroud)
任何帮助都会受到欢迎
python ×4
kivy ×2
android ×1
class ×1
datetime ×1
function ×1
python-3.4 ×1
python-3.x ×1
time ×1