RemovedMoney326 / Hubble-Pi

Documentation, Resources and Python Codes for portable Astrophotography and KStars Setup with Raspberry Pi 4 and HQ 12MP Camera Module
MIT License
181 stars 22 forks source link

Following along #2

Closed sirfressh closed 4 years ago

sirfressh commented 4 years ago

Hey man, hope you are doing well. I am attempting this project mashed up with the 3d printable pikon telescope.

I am currently having an issue running the Astrocam correctly. I have moved the text files from the github on to my display and have set them to be executable by anyone. when i click on the shortcuts it shows a loading icon but never pops up on to screen. through ssh terminal im getting this error

pi@raspberrypi:~/AstroCameraApp/PythonScripts $ python3 AstroCam.py Traceback (most recent call last): File "AstroCam.py", line 12, in from PIL import ImageTk, Image ImportError: cannot import name 'ImageTk' from 'PIL' (/usr/lib/python3/dist-pack ages/PIL/init.py)

kstars is working and running on my touchscreen display along with the shortcut for the camera preview, im using a 2.8" tft resistive touch screen from adafruit and it measures 320x240 and was trying to figure out how to edit that in the settings as mentioned in your pdf but am having issues there as well. Im not sure if the screen size difference is the issue with it not loading up or not! Im not to experienced in python but am a slightly capable with rpi's.

hope to hear from you soon!

sirfressh commented 4 years ago

if i try to run it with python it gives this error

~/AstroCameraApp/PythonScripts $ python AstroCam.py Traceback (most recent call last): File "AstroCam.py", line 10, in import tkinter as Tkinter ImportError: No module named tkinter

sirfressh commented 4 years ago

its saying the tk is already newest version in both pythons.

pi@raspberrypi:~ $ sudo apt-get install python-tk Reading package lists... Done Building dependency tree Reading state information... Done python-tk is already the newest version (2.7.16-2). 0 upgraded, 0 newly installed, 0 to remove and 53 not upgraded. pi@raspberrypi:~ $ sudo apt-get install python3-tk Reading package lists... Done Building dependency tree Reading state information... Done python3-tk is already the newest version (3.7.3-1). 0 upgraded, 0 newly installed, 0 to remove and 53 not upgraded.

it wont allow me to import the tkinter at all

RemovedMoney326 commented 4 years ago

Hi sirfressh :)

It looks like the issue lies in your Tkinter installation, although from your last comment it looks like you already have it installed, which is.. a little odd then. What Python version are you using it with? Make sure you have Tkinter installed for Python 3 (I think you needed to use the pip3 package manager to install Python 3 packages specifically) and in case that doesn't work, try checking the name your installation uses for the Tkinter package and swap that with "tkinter" at the "import tkinter as Tkinter" line.

Regarding the screen size, fortunately I can assure you that once the Tkinter package issue is resolved, there you should be no code-breaking bug occurring due to the window sizes (aside from them not fitting on your lower res and smaller screen at least).

You can change the individual window sizes by modifying the .geometry lines below (lines 139-151 in the code) within your AstroCam.py file. Tkinter uses a format of ("width x height + displacement of the window to the right + displacement of the window horizontally") in pixels for defining the window geometry, meaning that you will for example want to set the height to the same as your screens vertical resolution (240) and split up the horizontal resolution of (320) between the tkTop and previewWin width values. You can then move their starting positions on the touchscreen by modifying the displacement values, although here I simply recommend to set the right displacement value for the tkTop window to the same value as your previewWin chosen width.

tkTop = Tkinter.Tk() tkTop.wm_title("Settings") tkTop.geometry("130x300+350+0") #Main Settings Window Size

previewWin = Tkinter.Toplevel(tkTop) previewWin.title('AstroCam') previewWin.geometry('350x300+1+0') #Preview Window Size previewPanel = Tkinter.Label(previewWin) previewPanel.pack(side = "bottom", fill = "both", expand = "yes")

tkBottom = Tkinter.Toplevel(tkTop) tkBottom.wm_title("Advanced Settings") tkBottom.geometry("610x300+0+330") #Advanced Window Size (not as important, as this one is only intended for remote desktop usage, but you can modify it to fit the other two once you are done with the resizing so as to make it look better)

You also might need to tinker a bit with the

SCALE_WIDTH = 130; SCALE_LENGHT = 250

values on lines 165-166 to get all of the relevant settings and functions to fit on the smaller screen of your Raspberry Pi, as they don't automatically scale to fit within the window sizes. Also, make sure to set all the "camera.resolution = (350, 300)" lines to the (width x height) size of your previewWin.

Unfortunately, this was my first project using Tkinter and thus I didn't implement any proportion based scaling to make the app easily compatible across multiple screen sizes, which is why this is such a pain to set up. As I am still a newbie at making GUIs and originally intended the AstroCam script for only my personal use with my specific setup before deciding to publish it here due to the huge amount of positive feedback it received, this didn't seem like an urgent issue at first but... I will try to look into it now during the next few weeks as I try to make further improvements to the code, so feel free to keep an eye out for further updates too.

I hope this answer can be of help to you. Should any further issues come up, do not hesitate to write back too, as the more issues are found, the further I can improve my project for other people to have a smoother experience when trying to reproduce it like you are, and thus the more helpful it can be to others :)

With kind regards, Santiago

sirfressh commented 4 years ago

Thanks for the quick response! I will try to install tkinter through pip3 and see if that works and then work on the screen adjustments. I appreciate your help! If you could possible link me the screen you're using and where I can buy one possible that would be great as well! I'd enjoy a bigger screen myself!!

On Tue, Jul 7, 2020, 3:35 PM Santi notifications@github.com wrote:

Hi sirfressh :)

It looks like the issue lies in your Tkinter installation, although from your last comment it looks like you already have it installed, which is.. a little odd then. What Python version are you using it with? Make sure you have Tkinter installed for Python 3 (I think you needed to use the pip3 package manager to install Python 3 packages specifically) and in case that doesn't work, try checking the name your installation uses for the Tkinter package and swap that with "tkinter" at the "import tkinter as Tkinter" line.

Regarding the screen size, fortunately I can assure you that once the Tkinter package issue is resolved, there you should be no code-breaking bug occurring due to the window sizes (aside from them not fitting on your lower res and smaller screen at least).

You can change the individual window sizes by modifying the .geometry lines below (lines 139-151 in the code) within your AstroCam.py file. Tkinter uses a format of ("width x height + displacement of the window to the right + displacement of the window horizontally") in pixels for defining the window geometry, meaning that you will for example want to set the height to the same as your screens vertical resolution (240) and split up the horizontal resolution of (320) between the tkTop and previewWin width values. You can then move their starting positions on the touchscreen by modifying the displacement values, although here I simply recommend to set the right displacement value for the tkTop window to the same value as your previewWin chosen width.

tkTop = Tkinter.Tk() tkTop.wm_title("Settings") tkTop.geometry("130x300+350+0") #Main Settings Window Size

previewWin = Tkinter.Toplevel(tkTop) previewWin.title('AstroCam') previewWin.geometry('350x300+1+0') #Preview Window Size previewPanel = Tkinter.Label(previewWin) previewPanel.pack(side = "bottom", fill = "both", expand = "yes")

tkBottom = Tkinter.Toplevel(tkTop) tkBottom.wm_title("Advanced Settings") tkBottom.geometry("610x300+0+330") #Advanced Window Size (not as important, as this one is only intended for remote desktop usage, but you can modify it to fit the other two once you are done with the resizing so as to make it look better)

You also might need to tinker a bit with the

SCALE_WIDTH = 130; SCALE_LENGHT = 250

values on lines 165-166 to get all of the relevant settings and functions to fit on the smaller screen of your Raspberry Pi, as they don't automatically scale to fit within the window sizes. Also, make sure to set all the "camera.resolution = (350, 300)" lines to the (width x height) size of your previewWin.

Unfortunately, this was my first project using Tkinter and thus I didn't implement any proportion based scaling to make the app easily compatible across multiple screen sizes, which is why this is such a pain to set up. As I am still a newbie at making GUIs and originally intended the AstroCam script for only my personal use with my specific setup before deciding to publish it here due to the huge amount of positive feedback it received, this didn't seem like an urgent issue at first but... I will try to look into it now during the next few weeks as I try to make further improvements to the code, so feel free to keep an eye out for further updates too.

I hope this answer can be of help to you. Should any further issues come up, do not hesitate to write back too, as the more issues are found, the further I can improve my project for other people to have a smoother experience when trying to reproduce it like you are, and thus the more helpful it can be to others :)

With kind regards, Santiago

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/RemovedMoney326/Hubble-Pi/issues/2#issuecomment-655117416, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP3MEF2OHXJOZ7W2GF2WOJDR2OBJVANCNFSM4OTGZRMQ .

sirfressh commented 4 years ago

NVM I just noticed you linked the screen in your pdf!!!! Thanks again for your help!

On Tue, Jul 7, 2020, 3:51 PM Matthew Gaither matthewjgaither@gmail.com wrote:

Thanks for the quick response! I will try to install tkinter through pip3 and see if that works and then work on the screen adjustments. I appreciate your help! If you could possible link me the screen you're using and where I can buy one possible that would be great as well! I'd enjoy a bigger screen myself!!

On Tue, Jul 7, 2020, 3:35 PM Santi notifications@github.com wrote:

Hi sirfressh :)

It looks like the issue lies in your Tkinter installation, although from your last comment it looks like you already have it installed, which is.. a little odd then. What Python version are you using it with? Make sure you have Tkinter installed for Python 3 (I think you needed to use the pip3 package manager to install Python 3 packages specifically) and in case that doesn't work, try checking the name your installation uses for the Tkinter package and swap that with "tkinter" at the "import tkinter as Tkinter" line.

Regarding the screen size, fortunately I can assure you that once the Tkinter package issue is resolved, there you should be no code-breaking bug occurring due to the window sizes (aside from them not fitting on your lower res and smaller screen at least).

You can change the individual window sizes by modifying the .geometry lines below (lines 139-151 in the code) within your AstroCam.py file. Tkinter uses a format of ("width x height + displacement of the window to the right + displacement of the window horizontally") in pixels for defining the window geometry, meaning that you will for example want to set the height to the same as your screens vertical resolution (240) and split up the horizontal resolution of (320) between the tkTop and previewWin width values. You can then move their starting positions on the touchscreen by modifying the displacement values, although here I simply recommend to set the right displacement value for the tkTop window to the same value as your previewWin chosen width.

tkTop = Tkinter.Tk() tkTop.wm_title("Settings") tkTop.geometry("130x300+350+0") #Main Settings Window Size

previewWin = Tkinter.Toplevel(tkTop) previewWin.title('AstroCam') previewWin.geometry('350x300+1+0') #Preview Window Size previewPanel = Tkinter.Label(previewWin) previewPanel.pack(side = "bottom", fill = "both", expand = "yes")

tkBottom = Tkinter.Toplevel(tkTop) tkBottom.wm_title("Advanced Settings") tkBottom.geometry("610x300+0+330") #Advanced Window Size (not as important, as this one is only intended for remote desktop usage, but you can modify it to fit the other two once you are done with the resizing so as to make it look better)

You also might need to tinker a bit with the

SCALE_WIDTH = 130; SCALE_LENGHT = 250

values on lines 165-166 to get all of the relevant settings and functions to fit on the smaller screen of your Raspberry Pi, as they don't automatically scale to fit within the window sizes. Also, make sure to set all the "camera.resolution = (350, 300)" lines to the (width x height) size of your previewWin.

Unfortunately, this was my first project using Tkinter and thus I didn't implement any proportion based scaling to make the app easily compatible across multiple screen sizes, which is why this is such a pain to set up. As I am still a newbie at making GUIs and originally intended the AstroCam script for only my personal use with my specific setup before deciding to publish it here due to the huge amount of positive feedback it received, this didn't seem like an urgent issue at first but... I will try to look into it now during the next few weeks as I try to make further improvements to the code, so feel free to keep an eye out for further updates too.

I hope this answer can be of help to you. Should any further issues come up, do not hesitate to write back too, as the more issues are found, the further I can improve my project for other people to have a smoother experience when trying to reproduce it like you are, and thus the more helpful it can be to others :)

With kind regards, Santiago

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/RemovedMoney326/Hubble-Pi/issues/2#issuecomment-655117416, or unsubscribe https://github.com/notifications/unsubscribe-auth/AP3MEF2OHXJOZ7W2GF2WOJDR2OBJVANCNFSM4OTGZRMQ .

RemovedMoney326 commented 4 years ago

No problem! If possible, do let me know if it works once you install the Tkinter package so I can then close the issue, otherwise you can also post any further issues you might have here and I will try to help out as best I can.

sirfressh commented 4 years ago

hey so i went ahead and ordered the same screen that you had just so i wouldnt have to worry about adjusting anything in the python script. I was able to figure out what the issue was with it not wanting to load up. It was unable to import tkinter from PIL so i was able to update and install the packages with this command.

sudo apt-get install python3-pil python3-pil.imagetk

it installed the python3-pil.imagetk which i guess was the problem. after it installed i opened python and imported PIL and tkinter again.

rebooted and now it comes up as it should and shows video feed.