Skip to main content

Posts

Oscillator not stoppingor ramping down in Web Audio API

I am trying to make a metronome as part of a bigger app by using an oscillator that switches on and off at set intervals in Web Audio Api, I have tried both the Start()/Stop() method and the LinearRampToValue(), in the code below. The oscillator plays at the correct bpm/interval but it won't leave a silent gap between clicks (I hope it makes sense)...what am I doing wrong? it's more of a pulse than a click with gaps as of now. Thanks! function startMetronome() { document.getElementById("startStopButton").innerText = "Stop"; document.getElementById("startStopButton").style.background = "black"; playingMetronome = true; const bpm = parseInt(bpmInput.value); const interval = (60 / bpm) * 1000; oscillator = audioContext.createOscillator(); oscillator.frequency.value = 440; oscillator.type = "triangle"; let gainNode = audioContext.createGain(); oscillator.connect(gainNode); gainNode.conn...

How can i nest a function inside an outer function?

I'm trying to design a function that will display the coordinates of the canvas so i wrote this function inside another function which is the canvas for the solar system simulation. Here is my code: def solar_system(): top2 = Toplevel() top2.title("Solar system simulation") #window title canvas = tk.Canvas(top2, width=1500, height=900, bg = "black") #making the canvas canvas.pack() def display_xy_coordinates(event): #function for displaying x and y widgetxy["text"]=f"x,{event.x} y,{event.y}" display_xy_coordinates(event) widgetxy = Label(canvas, font = "Calibri 10", fg = "white", bg = "black") #colour and font for label showing xy coordinates canvas.bind("<Button-1>", display_xy_coordinates) #Buton-1 = left click on the mouse. This calls the display xy coordinates function widgetxy.pack() #this label needs to be packed in order to show canva...

How to extract UTM parameters properly in React to auto-submitted the data within a form

When I'm sending the data with my code the inputs fields (utm_source, utm_medium and utm_campaign) are empty, but the email input is working, I don't really know what I'm doing wrong in my code. Note: The connection to sending the data is working properly, the problem seems to be in the React code, that is sending empty values of utm_source, utm_medium and utm_campaign. Code: import { useRef, useEffect, useState } from "react" export default function Testing_Form() { const [utmSource, setUtmSource] = useState("") const [utmMedium, setUtmMedium] = useState("") const [utmCampaign, setUtmCampaign] = useState("") const [defaultEmail, setDefaultEmail] = useState("") const [formSubmitted, setFormSubmitted] = useState(false) const btnRef = useRef(null) const submitForm = () => { console.log("Submited!") } useEffect(() => { const urlParams = new URLSearchPara...

Cancel long running action with multiple dialogs in PyQt6

I'm having an personal issue with threads in PyQt6. I have used the great example in the solution of How to stop a QThread from the GUI and rebuilt it with a separate dialog and a finished event. In theory, what I am trying to create is a Connection Dialog which opens a database connection with oracledb. Although, if I click on the connection in the connection dialog, it should not connect silently, but it rather should display a Cancel Dialog, where if I want, I can choose to cancel the current connection attempt. This functionality should later then be used for every query against the database in my program, the connection dialog was just an example. My current issue is, that the button on the Cancel Dialog is not displayed. Somehow the Cancel Dialog is frozen even though I use threads for the worker to connect. For this I have created the following reduced code example: import time from PyQt6.QtCore import * from PyQt6.QtGui import * from PyQt6.QtWidgets import * class C...

How to return x y coordinates of the selection box in Plotly JavaScript?

I would like to retrieve the coordinates generated by Box Select from a chart made with Plotly JavaScript , but looking in the documentation it seems there is no attribute for the layout.selections.path , how can I retrieve the x.min , x.max , y.min and y.max coordinates of a selection box? Thanks! Via Active questions tagged javascript - Stack Overflow https://ift.tt/gwQANlT

I can't get access to OAUTH 2.0 Python, requests

I need to get access token to moving in the site with request i do the same thigs but i have troubles and than enter image description here also tested on postman but got the same error, but in the develp. it's look like this enter image description here What am i doing wrong? enter image description here And also i tried that way enter image description here and that enter image description here source https://stackoverflow.com/questions/75495778/i-cant-get-access-to-oauth-2-0-python-requests

My Python imports don't work as they should according to tutorials

Introduction I'm having problems with importing my own modules/packages so I searched up some tutorials (written and youtube) and was trying to solve my problems. However nothing really worked so I recreated the structure of a tutorial to follow it step by step ( sweetcode.io ). I'm using Python 3.9.13 installed via anaconda on a win10 machine Structure of the sample project -- tutorial |-- subfolder1 | |-- subfolder2 | | |-- __init__.py | | |-- student.py | | `-- user.py | |-- __init__.py | `-- item.py |-- subfolder3 | |-- __init__.py | |-- accounts.py | `-- registration.py |-- __init__.py `-- security.py I could follow the tutorial up to the part where they talk about importing a module backwards, so say from student.py import the module security.py . However as soon as I try to do that I get an error message. Attempt 1: code in student.py : import tutorial.security powershell command (currently i...