python - kivy, do 2 def in class
问题描述
what i want to do is run two defs but the second def is never executed.
In short, how can I execute the lines named 'print('sj')' in this code?
class Welcome(GridLayout):
def __init__(self, **kwargs):
super(Welcome, self).__init__(**kwargs)
self.cols = 2
self.add_widget(Label(text='[color=256bdb]Hoş[/color][b] geldin![/b]', font_size='31sp', halign="left", markup = True))
def sj():
print("sj")
print("sj")
print("sj")
print("sj")
print("sj")
print("sj")
print("sj")
print("sj")
print("sj")
###
class MyApp(App):
def build(self):
return Welcome()
###
if __name__ == '__main__':
MyApp().run()
解决方案
Good day. the sj()
function has several potential issues with it. It's either out of scope (indented when it suppose to be near the edge) or ill defined as a method (missing self
as in def sj(self):
)
Choose either solution and your program should work.
推荐阅读
- python - 添加到 manytomany 字段返回空查询集
- node.js - 我每次都会生成一个新的 PKCE 挑战,还是可以存储它?
- sql - 每晚 SQL 数据库到 Postgres RDS 实例
- java - 使用 gradle 启动项目时,如何消除错误 Process 'command' finished with non-zero exit value 1?
- android - Jetpack Compose - LazyColumn 进行无限次数的重组
- javascript - 对 GraphQL 的 POST 请求返回 400
- php - php返回重定向功能
- android - 是什么导致 ANR 在主线程上没有长任务?
- sockets - 拦截 tls.Conn 的 Read() 和 Write(),同时保留 tls.Conn 功能
- javascript - 有没有办法让 Material-UI 中的点徽章变大?