What code is used in python to have a pop up asking the user whether they want to exit the programme?
There should be a button to click 'ok' and another to click 'cancel' and return back to the current loop.
See also questions close to this topic
Showing all the images with matplotlib
I'm using numpy and matplotlib to read all the images in the folder for image processing techniques. Although, I have done the part of reading image dataset from folders and process it with numpy array. But the problem, I'm facing is of showing all the images with matplotlib.imshow function. Everytime I want to show all the images with imshow function, unfortunately it just give me first image nothing else. My code is below:
import os import numpy as np import matplotlib.pyplot as mpplot import matplotlib.image as mpimg images =  path = "../path/to/folder" for root, _, files in os.walk(path): current_directory_path = os.path.abspath(root) for f in files: name, ext = os.path.splitext(f) if ext == ".jpg": current_image_path = os.path.join(current_directory_path,f) current_image = mpimg.imread(current_image_path) images.append(current_image) for img in images: print len(img.shape) i = 0 for i in range(len(img.shape)): mpplot.imshow(img) mpplot.show()
I will be thankful if somebody can help me in this.
P.S. I'm pretty new with python, numpy and also at stackoverflow. So, please don't mind if the question is unclear or not direct.
Tkinter, changing a button and its command
We have a button that calls function A. We want function A to change the image of that button and to change its command to call function B instead of A. How to do that? We can't have two buttons at the same time.
Thank you in advance.
SYN flooding in Python
Is there any way to perform SYN flooding on a target ip address? I have tried many programs but none of them have seem to flood the targeted ip addresses. Kindly help.
My note detection algorithm is failing on few cases?
I am using a simple approach to find out the musical note using FFT in python steps involved are:
- Reading the sound file(.wave)
- Detecting silence in the file(by computing square sum of squared elements of input falling within the window)
- Detecting the location of notes using data obtained from (2)
- Calculating the frequency of each detected note by using DFT
- Matching the calculated frequency to the standard frequencies of notes to identify the note that is being played.
but in a case where the note should come out to be A4/440hz, I am getting a huge variation(2K Hz) is there any fundamental error in my approach?
UPDATE: how can I pass my audio.wav file to this frequency estimator?
the complete python code is here
window_size = 2000 # Size of window to be used for detecting silence beta = 1 # Silence detection parameter max_notes = 100 # Maximum number of notes in file, for efficiency sampling_freq = 44100 # Sampling frequency of audio signal threshold = 200 # traversing sound_square array with a fixed window_size while(i<=len(sound_square)-window_size): s = 0.0 j = 0 while(j<=window_size): s = s + sound_square[i+j] j = j + 1 # detecting the silence waves if s < threshold: if(i-k>window_size*4): dft = np.array(dft) # applying fourier transform function dft = np.fft.fft(sound[k:i]) dft = np.argsort(dft) if(dft>dft[-1] and dft>dft[-1]): i_max = dft[-1] elif(dft>dft and dft[-1]>dft): i_max = dft else : i_max = dft # claculating frequency frequency.append((i_max*sampling_freq)/(i-k)) dft =  k = i+1 i = i + window_size
check if letters of a string are in sequential order in another string
If it were just checking whether letters in a test_string are also in a control_string,
I would not have had this problem.
I will simply use the code below.
if set(test_string.lower()) <= set(control_string.lower()): return True
But I also face a rather convoluted task of discerning whether the overlapping letters in the
control_string are in the same sequential order as those in test_string.
test_string = 'Dih' control_string = 'Danish' True test_string = 'Tbl' control_string = 'Bottle' False
I thought of using the for iterator to compare the indices of the alphabets, but it is quite hard to think of the appropriate algorithm.
for i in test_string.lower(): for j in control_string.lower(): if i==j: index_factor = control_string.index(j)
My plan is to compare the primary index factor to the next factor, and if primary index factor turns out to be larger than the other, the function returns False.
I am stuck on how to compare those index_factors in a for loop.
How should I approach this problem?
Multiply the rows with dates in aws glue
I'm new to aws glue.
Is there a way to get the expected output from this input using python?
INPUT (csv file has following input)
DATE (yyyymmdd) | ip | FINISHED ( 1:finished; 0: not finish) 2017-01-01 | 111 | 1 2017-01-01 | 222 | 1 2017-01-02 | 333 | 1 2017-01-03 | 444 | 1
DATE (yyyymmdd) | ip | FINISHED ( 1:finished; 0: not finish) 2017-01-01 | 111 | 1 2017-01-01 | 222 | 1 2017-01-01 | 333 | 0 2017-01-01 | 444 | 0 2017-01-02 | 111 | 1 2017-01-02 | 222 | 1 2017-01-02 | 333 | 1 2017-01-02 | 444 | 0 2017-01-03 | 111 | 1 2017-01-03 | 222 | 1 2017-01-03 | 333 | 1 2017-01-03 | 444 | 1