0% found this document useful (0 votes)
77 views3 pages

Apb Test

This document defines a GUI application that draws lines on a canvas to represent a cone. It includes sliders to adjust the angle and width of the cone, and buttons to save the parameters of the cone to a data file for different prior and posterior prompts. Functions are defined to update the lines on the canvas when the sliders change, and to save the data on button clicks. The application sets up the window, canvas, lines, sliders and buttons to allow interactive adjustment and saving of the cone parameters.

Uploaded by

api-610082175
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views3 pages

Apb Test

This document defines a GUI application that draws lines on a canvas to represent a cone. It includes sliders to adjust the angle and width of the cone, and buttons to save the parameters of the cone to a data file for different prior and posterior prompts. Functions are defined to update the lines on the canvas when the sliders change, and to save the data on button clicks. The application sets up the window, canvas, lines, sliders and buttons to allow interactive adjustment and saving of the cone parameters.

Uploaded by

api-610082175
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

from tkinter import *

import math
import filterpy.stats

# Make the display window


display = Tk()
display.title("Line Draw Test")
display.geometry("500x500")

canvas = Canvas(display,width=500,height=350)
canvas.pack()

# Create all the lines and variables


liney = canvas.create_line(250,50,250,350,fill="white",width=2)
linex = canvas.create_line(75,200,425,200,fill="white",width=2)
Coneframetop = canvas.create_line(250,200,400,350,fill="white",width=2)
Coneframebottom = canvas.create_line(250,200,400,50,fill="white",width=2)

line = canvas.create_line(250,200,500,350,fill="green",width=5)
Conelowerbound = canvas.create_line(250,200,450,200,fill="red",width=5)
Coneupperbound = canvas.create_line(250,200,250,50,fill="red",width=5)

xcord = 0
ycord = 0
Lowerx = 0
Lowery = 0
Upperx = 0
Uppery = 0
thetaval = 1
sigmaval = 1
CurrentSlope = 45
Varience = 1
PosteriorOne = 1
PosteriorTwo = 1

# The command to adjust the main line


def lineupdate(angle):
global xcord
global ycord
global Lowerx
global Lowery
global Upperx
global Uppery
global thetaval
global sigmaval
global CurrentSlope
global Varience
# Update the position of the main line based on the slider input
CurrentSlope = angle
xcord = int(250+200.0*math.cos(float(angle)*3.1415/180.0))
ycord = int(200.0*math.sin(float(angle)*3.1415/180.0))
canvas.coords(line,250,200,xcord,200-ycord)
# Update the displayed slope variable
thetaval = math.tan(float(angle)*3.1415/180.0)
slopenum.config(text = thetaval)
# Move the upper and lower bound along with the main line
Lowerx = int(250+200.0*math.cos((float(angle)-Sigma)*3.1415/180.0))
Lowery = int(200.0*math.sin((float(angle)-Sigma)*3.1415/180.0))
canvas.coords(Conelowerbound,250,200,Lowerx,200-Lowery)
Upperx = int(250+200.0*math.cos((float(angle)+Sigma)*3.1415/180.0))
Uppery = int(200.0*math.sin((float(angle)+Sigma)*3.1415/180.0))
canvas.coords(Coneupperbound,250,200,Upperx,200-Uppery)
sigmaval = math.tan((float(Sigma)*3.1415/180.0))
Varience = (sigmaval/2)*(sigmaval/2)
PosteriorOne = filterpy.stats.mul(thetaval, Varience, -0.7, 0.000441)
PosteriorTwo = filterpy.stats.mul(thetaval, Varience, 0.7, 0.000441)

# Add a slider to adjust the Main line


slopeslider = Scale(display,from_=-45,to_=45, orient=HORIZONTAL,command=lineupdate,length=200)
slopeslider.set(45)
slopeslider.pack(side=BOTTOM)

Sigma = 0

# The command to update the cone based on the slider input


def coneupdate(angle):
global Sigma
global xcord
global ycord
global Lowerx
global Lowery
global Upperx
global Uppery
global sigmaval
global Varience
# Update the position of the upper and lower lines based on the slider input
Sigma = int(float(angle))
Lowerx = int(250+200.0*math.cos((float(CurrentSlope)-Sigma)*3.1415/180.0))
Lowery = int(200*math.sin((float(CurrentSlope)-Sigma)*3.1415/180.0))
canvas.coords(Conelowerbound,250,200,Lowerx,200-Lowery)
Upperx = int(250+200.0*math.cos((float(CurrentSlope)+Sigma)*3.1415/180.0))
Uppery = int(200.0*math.sin((float(CurrentSlope)+Sigma)*3.1415/180.0))
canvas.coords(Coneupperbound,250,200,Upperx,200-Uppery)
sigmaval = math.tan((float(Sigma)*3.1415/180.0))
Varience = (sigmaval/2)*(sigmaval/2)

# Add a slider to adjust the cone


coneslider = Scale(display,from_=0,to_=90,orient=HORIZONTAL,command=coneupdate,length=200)
coneslider.pack(side=BOTTOM)

# Display the slope value of the main line


slopeval = Label(display,text = "Slope:")
slopeval.pack(side=LEFT)

thetaval = 0
slopenum = Label(display,text = thetaval)
slopenum.pack(side=LEFT)

# Create the prior and posterior buttons and export the data to a document
def Savepriorone():
file_object = open('Data.txt', 'a')
file_object.write("\n \n Entry Prior prompt 1- Mean: " + str(thetaval) +
" 2*Sigma: " + str(sigmaval) + " Varience: "
+ str(Varience) + " Posterior: " + str(PosteriorOne))
file_object.close()

def Saveposteriorone():
file_object = open('Data.txt', 'a')
file_object.write("\n Entry Posterior prompt 1- Mean: " + str(thetaval) +
" 2*Sigma: " + str(sigmaval))
file_object.close()

def Saveposteriortwo():
file_object = open('Data.txt', 'a')
file_object.write("\n Entry Posterior prompt 2- Mean: " + str(thetaval) +
" 2*Sigma: " + str(sigmaval))
file_object.close()

def Savepriortwo():
file_object = open('Data.txt', 'a')
file_object.write("\n Prior Prompt 2- Mean: " + str(thetaval) +
" 2*Sigma: " + str(sigmaval) + " Varience: "
+ str(Varience) + " Posterior: " + str(PosteriorTwo))
file_object.close()

Posterior2 = Button(display, text = "Posterior Two", command = Saveposteriortwo)


Posterior2.pack(side=RIGHT)

Prior2 = Button(display, text = "Prior Two", command = Savepriortwo)


Prior2.pack(side=RIGHT)

Posterior1 = Button(display, text = "Posterior One", command = Saveposteriorone)


Posterior1.pack(side=RIGHT)

Prior1 = Button(display, text = "Prior One", command = Savepriorone)


Prior1.pack(side=RIGHT)

display.mainloop()

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy