我应该检测选定的输入框

问题描述 投票:0回答:1
import matplotlib.pyplot as plt
import numpy as np
import tkinter as tk
from tkinter import *
root = tk.Tk()
root.config(bg='white')
root.state('zoomed')
x = np.arange(-10, 11, 1)
root.title('Fonksiyonlar')
c1 = Canvas(height=600, width=1100, bg='gray97')
import time

errortext = tk.Label(text='Girdiğiniz Sayıları Kontrol Ediniz', font='Calibri 25')

def gos():
    errortext.place_forget()

def b1c():
    def b3g():
        for i in e1.get():
            if i != '0' or '1' or '2' or '3' or '4' or '5' or '6' or '7' or '8' or '9' or '0' or '.':
                e1.delete(0, END)

                errortext.place(x=300, y=200)
                root.after(3000, gos)

    bbir.destroy()
    biki.destroy()
    c1.destroy()

    e1 = tk.Entry(highlightcolor='blue', bg='pink', font='Calibri 40')
    e1.place(width=230, height=230, x=80, y=300)
    bşş = tk.Button(text='TAMAM', command=b3g)
    bşş.pack()
    lx2 = tk.Label(text='x² + ', font='Calibri 150', bg='white')
    lx2.place(x=350, y=300)
    e2 = tk.Entry(highlightcolor='blue', bg='pink', font='Calibri 40')
    e2.place(width=230, height=230, x=700, y=300)
    lx3 = tk.Label(text='x +', font='Calibri 150', bg='white')
    lx3.place(x=1000, y=300)
    e3 = tk.Entry(highlightcolor='blue', bg='pink', font='Calibri 40')
    e3.place(width=230, height=230, x=1280, y=300)
    lx4 = tk.Label(text='=', font='Calibri 150', bg='white')
    lx4.place(x=1550, y=300)
    e4 = tk.Entry(highlightcolor='blue', bg='pink', font='Calibri 40')
    e4.place(width=230, height=230, x=1680, y=300)
    b1 = tk.Button(text='1', padx=20, pady=20, font='Calibri 20')
    b1.place(x=850, y=570)
    b2 = tk.Button(text='2', padx=20, pady=20, font='Calibri 20')
    b2.place(x=950, y=570)
    b3 = tk.Button(text='3', padx=20, pady=20, font='Calibri 20')
    b3.place(x=1050, y=570)
    b4 = tk.Button(text='4', padx=20, pady=20, font='Calibri 20')
    b4.place(x=850, y=700)
    b5 = tk.Button(text='5', padx=20, pady=20, font='Calibri 20')
    b5.place(x=950, y=700)
    b6 = tk.Button(text='6', padx=20, pady=20, font='Calibri 20')
    b6.place(x=1050, y=700)
    b7 = tk.Button(text='7', padx=20, pady=20, font='Calibri 20')
    b7.place(x=850, y=820)
    b8 = tk.Button(text='8', padx=20, pady=20, font='Calibri 20')
    b8.place(x=950, y=820)
    b9 = tk.Button(text='9', padx=20, pady=20, font='Calibri 20')
    b9.place(x=1050, y=820)
    b0 = tk.Button(text='0', padx=75, pady=20, font='Calibri 15')
    b0.place(x=850, y=930)
    beş = tk.Button(text='=', padx=22, pady=20, font='Calibri 20')
    beş.place(x=1050, y=930)
    bar = tk.Button(text='+', padx=20, pady=20, font='Calibri 20')
    bar.place(x=1150, y=570)
    bek = tk.Button(text='-', padx=22, pady=20, font='Calibri 20')
    bek.place(x=1150, y=700)
    bb = tk.Button(text='/', padx=22, pady=20, font='Calibri 20')
    bb.place(x=1150, y=930)
    bç = tk.Button(text='*', padx=20, pady=20, font='Calibri 20')
    bç.place(x=1150, y=820)

    print(e1.select_present())

c1.place(x=420, y=170)
bbir = Button(text='1.dereceden denklemler', bg='gray91', padx=300, pady=30, font='Calibri 30', command=b1c)
bbir.place(x=450, y=300)
biki = Button(text='2.dereceden denklemler', bg='gray91', padx=300, pady=30, font='Calibri 30')
biki.place(x=450, y=500)

def hesapla(a, b, c):

    return a * x ** 2 + b * x + c

m = 0.5 * x + x ** 2 + 5

plt.plot(x, hesapla(0, 0, 0))
plt.grid()

plt.show`)

我已经尝试过

selectionpresent()
但不适合

python tkinter
1个回答
0
投票

如果你想在 Tkinter 中检测选中的输入框,可以使用 focus_get() 方法。它返回当前具有焦点的小部件。

© www.soinside.com 2019 - 2024. All rights reserved.