button updaters and indicators + toggle for fisheye

This commit is contained in:
Technoduck 2024-11-19 10:30:23 -05:00
parent 49ae57d551
commit c035ec05da

51
app.py
View file

@ -31,6 +31,10 @@ class renderedImageZoom:
self.root = root self.root = root
self.root.geometry(f"{1000}x{700}") self.root.geometry(f"{1000}x{700}")
self.root.title("map_view_simple_example.py") self.root.title("map_view_simple_example.py")
self.temperature = 5
self.pressure = 720
self.set_sun(90)
self.fisheye = False
self.aerosol_window = aerosol_window self.aerosol_window = aerosol_window
# create map widget # create map widget
@ -112,27 +116,41 @@ class renderedImageZoom:
environemnt_info_text = tkinter.Label(self.aerosol_window, text="Please enter the temperature and pressure (in C, and mmHg)") environemnt_info_text = tkinter.Label(self.aerosol_window, text="Please enter the temperature and pressure (in C, and mmHg)")
environemnt_info_text.grid(column=0,row=6,columnspan=2,pady=20,padx=10) environemnt_info_text.grid(column=0,row=6,columnspan=2,pady=20,padx=10)
def t_update(value,label):
self.set_temp(value)
label.config(text=str(sorted([-270,int(value),100])))
t_frame = tkinter.Frame(self.aerosol_window) t_frame = tkinter.Frame(self.aerosol_window)
text_t = tkinter.Text(t_frame,height=1,width=10) text_t = tkinter.Text(t_frame,height=1,width=10)
submit_t_button = tkinter.Button(t_frame,text="set temperature",command=lambda: self.set_temp(text_t.get("1.0","end-1c"))) submit_t_button = tkinter.Button(t_frame,text="set temperature",
command=lambda: [self.set_temp(text_t.get("1.0","end-1c")),t_label.config(text=str(sorted([-270,int(value),100])[1])+" C")])
#submit_t_button = tkinter.Button(t_frame,text="set temperature",command=lambda: [print("what"),t_label.config(text="bruh")])
t_label = tkinter.Label(t_frame,text="5 C")
text_t.pack(side=tkinter.LEFT) text_t.pack(side=tkinter.LEFT)
t_label.pack(side=tkinter.RIGHT)
submit_t_button.pack(side=tkinter.RIGHT) submit_t_button.pack(side=tkinter.RIGHT)
t_frame.grid(column=0,row=7,columnspan=2,padx=20) t_frame.grid(column=0,row=7,columnspan=2,padx=20)
p_frame = tkinter.Frame(self.aerosol_window) p_frame = tkinter.Frame(self.aerosol_window)
text_p = tkinter.Text(p_frame,height=1,width=10) text_p = tkinter.Text(p_frame,height=1,width=10)
submit_p_button = tkinter.Button(p_frame,text="set pressure",command=lambda: self.set_press(text_p.get("1.0","end-1c"))) submit_p_button = tkinter.Button(p_frame,text="set pressure",command=lambda: [self.set_press(text_p.get("1.0","end-1c")),
p_label.config(text=str(sorted([400,int(text_p.get("1.0","end-1c")),900])[1]) +" mmHg")])
p_label = tkinter.Label(p_frame,text="720 mmHg")
text_p.pack(side=tkinter.LEFT) text_p.pack(side=tkinter.LEFT)
p_label.pack(side=tkinter.RIGHT)
submit_p_button.pack(side=tkinter.RIGHT) submit_p_button.pack(side=tkinter.RIGHT)
p_frame.grid(column=0,row=8,columnspan=2,padx=20) p_frame.grid(column=0,row=8,columnspan=2,padx=20)
s_frame = tkinter.Frame(self.aerosol_window) s_frame = tkinter.Frame(self.aerosol_window)
text_s = tkinter.Text(s_frame,height=1,width=10) text_s = tkinter.Text(s_frame,height=1,width=10)
submit_s_button = tkinter.Button(s_frame,text="set direction of the sun",command=lambda: self.set_sun(text_s.get("1.0","end-1c"))) submit_s_button = tkinter.Button(s_frame,text="set direction of the sun",command=lambda: [self.set_sun(text_s.get("1.0","end-1c")),
sun_dir_label.config(text=str(sorted([0,int(text_t.get("1.0","end-1c")),90])[1])+" degrees")])
sun_dir_label = tkinter.Label(s_frame,text="90 degrees")
text_s.pack(side=tkinter.LEFT) text_s.pack(side=tkinter.LEFT)
sun_dir_label.pack(side=tkinter.RIGHT)
submit_s_button.pack(side=tkinter.RIGHT) submit_s_button.pack(side=tkinter.RIGHT)
s_frame.grid(column=0,row=9,columnspan=2,padx=20) s_frame.grid(column=0,row=9,columnspan=2,padx=20)
@ -171,13 +189,24 @@ class renderedImageZoom:
#self.tk_image = ImageTk.PhotoImage(width=256,height=256,image=self.img) #self.tk_image = ImageTk.PhotoImage(width=256,height=256,image=self.img)
#img = ImageTk.PhotoImage(Image.open("highpress_camera.png")) #img = ImageTk.PhotoImage(Image.open("highpress_camera.png"))
def cam_toggle():
if cam_fish_toggle.config('text')[-1] == "cam view":
cam_fish_toggle.config(text="fisheye")
self.fisheye = True
else:
cam_fish_toggle.config(text="cam view")
self.fisheye = False
#self.canvas.create_image(0,0, anchor="center", image=self.tk_image) #self.canvas.create_image(0,0, anchor="center", image=self.tk_image)
zoom_in_button = tkinter.Button(self.image_window, text="Zoom In", command=self.zoom_in) zoom_in_button = tkinter.Button(self.image_window, text="Zoom In", command=self.zoom_in)
zoom_out_button = tkinter.Button(self.image_window, text="Zoom Out", command=self.zoom_out) zoom_out_button = tkinter.Button(self.image_window, text="Zoom Out", command=self.zoom_out)
render_button = tkinter.Button(self.image_window,text="render",command=self.render) render_button = tkinter.Button(self.image_window,text="render",command=self.render)
cam_fish_toggle = tkinter.Button(self.image_window,text="cam view", command=cam_toggle)
zoom_in_button.pack(side=tkinter.LEFT) zoom_in_button.pack(side=tkinter.LEFT)
zoom_out_button.pack(side=tkinter.LEFT) zoom_out_button.pack(side=tkinter.LEFT)
render_button.pack(side=tkinter.RIGHT) render_button.pack(side=tkinter.RIGHT)
cam_fish_toggle.pack(side=tkinter.RIGHT)
self.canvas.bind("<Button-4>",self.zoom_in) self.canvas.bind("<Button-4>",self.zoom_in)
self.canvas.bind("<Button-5>", self.zoom_out) self.canvas.bind("<Button-5>", self.zoom_out)
@ -190,6 +219,7 @@ class renderedImageZoom:
self.temperature = 0 self.temperature = 0
else: else:
self.temperature = int(temp) self.temperature = int(temp)
print("temperature set at ",temp)
def set_sun(self,angle): def set_sun(self,angle):
@ -208,11 +238,10 @@ class renderedImageZoom:
def set_press(self,press): def set_press(self,press):
if press is None: if press is None:
self.pressure = 720 self.pressure = 720
elif int(press) < 100 or int(press) > 1300: elif int(press) < 400 or int(press) > 900:
print("pressure unrealistic, resetting to 720 mmHg") pressure = sorted([400,int(press),900])[1]
self.pressure = 720 print("pressure unrealistic, resetting to clamped value {}".format(pressure))
else: self.pressure = pressure
self.pressure = int(press)
def get_image_average(self,color,low, high): def get_image_average(self,color,low, high):
@ -231,8 +260,10 @@ class renderedImageZoom:
def render(self): def render(self):
#adding button to switch between #adding button to switch between
self.image = skydome.renderFromCamera(self.coords,self.betaM,self.g,self.altitude,self.temperature,self.pressure,self.sunDir) if self.fisheye:
#self.image = skydome.renderSkydome(self.coords,self.betaM,self.g,self.altitude,self.temperature,self.pressure,self.sunDir) self.image = skydome.renderSkydome(self.coords,self.betaM,self.g,self.altitude,self.temperature,self.pressure,self.sunDir)
else:
self.image = skydome.renderFromCamera(self.coords,self.betaM,self.g,self.altitude,self.temperature,self.pressure,self.sunDir)
self.img = Image.fromarray(self.image,mode="RGB") self.img = Image.fromarray(self.image,mode="RGB")
self.tk_image = ImageTk.PhotoImage(width=256,height=256,image=self.img) self.tk_image = ImageTk.PhotoImage(width=256,height=256,image=self.img)
#img = ImageTk.PhotoImage(Image.open("highpress_camera.png")) #img = ImageTk.PhotoImage(Image.open("highpress_camera.png"))