Posts

Showing posts from May, 2019

Python Tkinter example

Image
This example demonstrates Python Tkinter GUI example. The code fetches weather information from URL, based on the location that is entered. You can get your API key from Openweathermap . Note: Make sure you included a background image in the path. In this case mine is called sky.jpg. import tkinter as tk from tkinter import font import PIL . Image import PIL . ImageTk import requests API_KEY = 'INSERT API KEY' # TODO insert API key from Openweathermap.com #functions def test_function ( entry ) : print ( "button clicked" , entry ) def format_response ( weather ) : try : name = weather [ 'name' ] description = weather [ 'weather' ] [ 0 ] [ 'description' ] temperature = weather [ 'main' ] [ 'temp' ] final_str = 'City: %s \n Conditions: %s \n Temperature (F): %s' % ( name , description , temperature ) except : final_str = 'There wa

Blender Python Examples

Image
Blender Python Generate 50 cubes at random positions. import bpy from random import randint for i in range ( 50 ) : bpy . ops . mesh . primitive_cube_add ( location = [ randint ( - 10 , 10 ) for axis in 'xyz' ] ) Generate cubes that follow a sin curve. import bpy from math import sin for i in range ( 50 ) : x , y , z = 0 , i , sin ( i ) bpy . ops . mesh . primitive_cube_add ( location = [ x , y , z ] )