Home > Back-end >  Can I run KIVY like Tkinter?
Can I run KIVY like Tkinter?

Time:09-26

I wanna learn kivy. But on youtube, everyone run it by creating class and have to run it by classname().run(). I want to simplify to run kivy like tkinter, I always use root=Tk() to create and design window. Can anyone know how to use kivy like tkinter/root=Tk()??

Here is my code, which I always use with tkinter:

from tkinter import *

root=Tk()
root.title('Stackoverflow')
root.config(bg='white')
root.geometry('400x400')
Label(root,text='Welcome to This Question, Please Answer This',font='20',bg='white').place(x=30,y=170)
root.mainloop()

CodePudding user response:

No, Kivy doesn't have the same API as tkinter and I'm not aware of anyone having written a wrapper package to expose a similar API.

Also, I would encourage you not to worry about this - it's normal that different packages have different APIs, and in general these APIs are designed to efficiently express how the toolkit should be used. It is normal to expect to learn how a new package works.

CodePudding user response:

Installing Kivy

python -m pip install --upgrade pip setuptools virtualenv

python -m virtualenv kivy_program

kivy_program/Scrtips/activate

source kivy_program/Scripts/activate

source kivy_program/Scripts/activate

python -m pip install kivy[base] kivy_example


Code

from kivy.app import App

class myapp(App):
     pass
     # Code

if __name__ == '__main__':
  window = myapp()
  • Related