从另一个班级从Tkinter班级获取输入

时间:2020-07-13 03:57:05

标签: python oop tkinter

我正在尝试将tkinter代码与另一个程序连接。也就是说,我试图从其他程序调用GUI文件并从GUI程序接收输入,但是我遇到了问题。 这是称为BayeGUI的GUI代码

from tkinter import *
import tkinter.simpledialog
class BayeGUI:
    def __init__(self):
        window = Tk()
        window.title('Graphical User Interface Designed by Gideon')
        self.input = 'I am fine Thank you' 
        frame1 = Frame(window)
        frame1.pack()
        self.v1 = StringVar()
        scrollbar = Scrollbar(frame1)
        scrollbar.pack(side = RIGHT, fill = Y)
        self.text = Text(frame1, width = 100, height = 30,wrap = WORD, yscrollcommand = scrollbar.set)
        scrollbar.config(command = self.text.yview)
        self.text.pack()
        
        frame2 = Frame(window)
        frame2.pack()
        testbtn = Button(frame2,text = 'Test Algorithm',command = self.testAlgorithm)
        testbtn.grid(row = 1, column = 1)
        
        return self.input
        window.mainloop()
        
        

    def testAlgorithm(self):
        isYes = tkinter.messagebox.askyesno('askyesno', 'Do you want to Test the Algorithm?')
        if isYes == True:
            self.input = self.text.get("1.0",'end-1c') #This is the input I need
BayeGUI()

这是我试图从Baye GUI获得价值的主要代码。

from BayeGUI import BayeGUI

emails = BayeGUI()
print(emails)

0 个答案:

没有答案
相关问题