#afTest07.py in Desktop/PiIX07/ # on 2022BFeb27 by D@CC # my first working import of one of my Thonny packages # Import classes from your brand new package # Package folder PiIX01 contains __init__.py and Raspberry.py from PiIX07 import * #print(" by D@CC on 2022BFeb27") # Create an object of Raspberry class & call its method IX = Raspberry() #print("I created an object named IX") #print("I am not yet using the 4 models") # you may wish to uncomment the next statement #IX.outModels() print("getting ready to call show2()") isP=1 abcd="a12345b" # invoke # resultStr=IX.show2("abcd",isP) z="abcd"; IX.show2(z,eval(z),isP) # shows the variable named abcd print("calling show()") IX.show("abcd",abcd,isP) IX.modulesList() # you may wish to uncomment the next statement #IX.PiIX_help() print("end of afTest07.py") # #IX.PiIX_help() this help function works fine #IX.PiIX04A_help() this help worked??? #resultStr=IX.show2("efgh",isP) #print(resultStr) #from Cars.Audi.a8 import get_buy #IX:PiIX_help() #print("exit afTest07.py") #prerequisites in Thonny Package Library # folder PiIX07 # __init__.py # Raspberry.py # Source 1: http://geeksforgeeks.org/create-access-python-package # Title: Create and Access a Python Package # By: Chinmoy Lenka On 15 Feb, 2018 # Source 1 does not work for Thonny packages # Source 2 works for Thonny packages # Source 2: https://www.tutorialspoint.com/create-and-access-a-python-package # ThonnyPackageLibrary: /home/pi/.local/lib/python3.7/site-packages # To view Library a)thonny b)Tools c)Target: user site packages #Documentation: /home/pi/Desktop/PythonPackageCreation.txt # Note 3: I will develop afTest.py in Desktop/PiIX01/ # the package will be PiIX01 containing show2.py and outModels # their references will be PiIX01.show2 and PiIX01.outModels # One object will be created named IX of class Raspberry # This program, /Desktop/PiIX01/afTest.py, will be used for testing # Note 4 The names of the app folder and the package folder match. # See PythonPackagesNotes.txt # also changed the name of this app. # Note 5 I discovered that I could not use the editor while # Tools-Package was open. I needed to edit the package # routines elsewhere. I also discovered that it is not # the folder of the app that is "married" to the package. # It seems that the name of the app (or the contents of # the app were "married" to the package. So I changed # the name of the app to "force" a new marriage of the # app to the revised package. I wonder if it was really # necessary to change the name of the package, but I # did, just to be safe. It then worked with the newly # editted package. Sweet success at last! # I was able to edit the app and run it again using the # package. Note that I did not change the name of the app. # Note 6 The items in the Package List are not copies of the # the modules (e.g. Raspberry.py). The items are more # like pointers or links to the actual moduels that # are stored (and should be editted) elsewhere. # See HowToManageAThonnyPackage.txt #end of afTest07.py