Skip to main content

How to make calculator in python kivy

  How make calculator in python We make a calculator in python using kivy module . Kivy module helps us to make android apps . First wait , If you run a kivy program in your terminal then you see a error like this To solve this problem you have to go kivy docs and follow the instruction of kivy docs.  First we have to make a virtual environment and then in the virtual environment you have to install kivy . After that you have to write  kivy_venv\Scripts\activate in your terminal and then run the file . If this method not work then write the comment below. LETS START CODING First we import kivy .For this we hve to write  from  kivy.app  import  App from  kivy.uix.label  import  Label from  kivy.uix.button  import  Button from  kivy.core.window  import  Window from  kivy.uix.gridlayout  import  GridLayout from  kivy.uix.widget  import  Widget from  kivy.lang  import ...

HOW TO MAKE 3D MODEL OF MOON MOVE AROUND THE EARTH IN PANDA3D

How to make 3d model of moon which move around the earth in panda 3d

We make 3d model of moon which move around the earth with help of panda3d . 

We write some lines of code in python to make the model of moon .

LETS START CODING

First we have to from direct.showbase.ShowBase import ShowBase

from panda3d.core import PointLight , AmbientLight

After this we have to make class which inherit from a ShowBase class. After this we have to make constructor .

Now , we have to load the model of earth and moon and the texture of earth. For this we have to write 


        self.moon = self.loader.loadModel("models/sphere")
        self.moon.setScale(3,3,3)
        self.moon.reparentTo(self.render)
        

        self.tex=self.loader.loadTexture("world.jpg")
        self.earth=self.loader.loadModel("models/sphere")
        self.earth.setTexture(self.tex)
        self.earth.setScale(5,5,5)
        self.earth.reparentTo(self.render)


After load models and texture we have to make moon light . For this we have to write

       plight = PointLight("plight")
        plight.setColor((1,1,1,1))     
        self.plnp=self.moon.attachNewNode(plight)
        self.earth.setLight(self.plnp)

        alight=AmbientLight("alight")
        alight.setColor((0.8,0.8,0.8,1))
        self.alnp = self.render.attachNewNode(alight)
        self.earth.setLight(self.alnp)


Now , we have to make three variables 

        self.angle=0
        self.speed=2  

These variables are used in a function which help the moon to move around the earth. For this we have to write a function which move the moon around the earth. So, we have to write 


     def update(self,task):
        
        ft= globalClock.getFrameTime()

        self.moon.setPos(cos(ft)*13,sin(ft)*14,cos(ft)*3)
        self.earth.setH(self.angle)
        self.angle += self.speed * 2
        
        return task.cont


After making class we have to make a object of class and run the program. For this we have to write 

moon=moon()
moon.run()

HERE ARE THE CODE




OUTPUT