Here is some code to help you, but you need to do some work.

# define your own function that check for prime
def isPrime(x):
pass
def primeFactorization(num):
pfactors = []
while True:
j = 2
while j < num+1:
if num%j==0 and isPrime(j):
num = num/j
pfactors.append(j)
break
j+=1
if num==1:
break
return pfactors

You do not need to test all numbers neither test for prime as factorin wjile loop ensures prime. You can test for only valid prime candidates n * 6 +- 1 after testing with 2 and 3. BTW this is old solved thread and I do not know how much this post helps OP, make own thred with link to old one you read. !lso the function next_prime in your code does not exist.

I have the following problem.
when i pres buttun printpreview (button 5) the the print preview fires up.
and when i close the print preview without printing and minimize the ...