我想在函数中生成一个随机数组。之后,我想在另一个函数中对该数组进行排序。如何在第二个函数中访问数组?
from tkinter import *
import array as arr
import numpy as np
import random
root = Tk()
Array_Size=IntVar()
Minim_Elem=IntVar()
Maxim_Elem=IntVar()
def Genera_Array():
ArraySize=Array_Size.get()
MinimumElement=Minim_Elem.get()
MaximumElement=Maxim_Elem.get()
Arr=[ArraySize]
for H in range(0, ArraySize):
Arr.append(random.randint(MinimumElement,MaximumElement))
for A in range(0,ArraySize):
Output_1.insert(END,Arr[A])
Output_1.insert(END, " ")
return Arr,ArraySize
def QuickSort():
print("Array before sorting")
for A in range(0,ArraySize):
print(Arr[ArraySize], end=" ")
Gene_Array=Button(text="Generate Array", command=Genera_Array)
Gene_Array.pack()
Gene_Array.place(x=295,y=245, width=240,height=40)
Quick=Button(text="Quick Sort", command=QuickSort)
Quick.pack()
Quick.place(x=410,y=410, width=120,height=40)
Output_1=Text(root, width=56, height=3, bd=5, font=("Time new roman",12,"bold"))
Output_1.place(x=150,y=300)
root.mainloop()