Python——逻辑非运算及图示(采用逻辑非运算方法实现)(tkinter实现)

本功能作者:
1.CSDN用户(philo42),philo42主页
2.CSDN用户(TDTX),TDTX主页
   博客园用户(TDTX),TDTX主页

1.fetu.py

def fetu():
    import tkinter as tk
    windfe=tk.Tk()
    windfe.title('逻辑非及图示')
    windfe.geometry('500x500')
    def qfe():
        tx5.delete(1.0,'end')
        tx6.delete(1.0,'end')
        tx7.delete(1.0,'end')
        tx8.delete(1.0,'end')
        tx1.delete(0.0,tk.END)
        tx2.delete(0.0,tk.END)
        q=eval(ent1.get())
        p=eval(ent2.get())
        if q==0:
            tx1.insert('insert',1)
            tx7.insert('insert',1)
        elif q!=0:
            tx1.insert('insert',0)
            tx7.insert('insert',0)
        if p==0:
            tx2.insert('insert',1)
            tx8.insert('insert',1)
        elif p!=0:
            tx2.insert('insert',0)
            tx8.insert('insert',0)
        tx5.insert('insert',q)
        tx6.insert('insert',p)
    lb1=tk.Label(windfe,text='输入q值:',fg='blue',width=10,height=2)
    lb1.place(x=100,y=30)
    ent1=tk.Entry(windfe,width=5)
    ent1.place(x=170,y=35)
    lb2=tk.Label(windfe,text='输入p值:',fg='blue',width=10,height=2)
    lb2.place(x=230,y=30)
    ent2=tk.Entry(windfe,width=5)
    ent2.place(x=300,y=35)
    bt1=tk.Button(windfe,text='求解!q和!p',command=qfe)
    bt1.place(x=200,y=70)
    lbf=tk.Label(windfe,text='-----------------------------------------------')
    lbf.place(x=110,y=95)
    lb3=tk.Label(windfe,text='!q值为:',fg='blue',bg='yellow')
    lb3.place(x=100,y=120)
    tx1=tk.Text(windfe,width=2,height=1)
    tx1.place(x=130,y=150)
    lb4=tk.Label(windfe,text='!p值为:',fg='blue',bg='yellow')
    lb4.place(x=230,y=120)
    tx2=tk.Text(windfe,width=2,height=1)
    tx2.place(x=260,y=150)
    canvas=tk.Canvas(windfe,bg='white',height=100,width=280)
    line=canvas.create_line(50,50,140,50)
    line=canvas.create_line(80,50,70,56)
    line=canvas.create_line(80,50,70,44)
    line=canvas.create_line(140,70,140,30)
    line=canvas.create_line(140,70,178,51)
    line=canvas.create_line(140,30,178,49)
    x0=180
    y0=50
    canvas.create_oval(x0-3,y0-3,x0+3,y0+3)
    line=canvas.create_line(183,50,280,50)
    line=canvas.create_line(210,50,200,56)
    line=canvas.create_line(210,50,200,44)
    canvas.place(x=100,y=200)
    lb4=tk.Label(windfe,text='q')
    lb4.place(x=135,y=210)
    lb5=tk.Label(windfe,text='p')
    lb5.place(x=135,y=270)
    lb6=tk.Label(windfe,text='!q')
    lb6.place(x=280,y=220)
    lb7=tk.Label(windfe,text='!p')
    lb7.place(x=280,y=260)
    tx5=tk.Text(windfe,width=6,height=1)
    tx5.place(x=158,y=210)
    tx6=tk.Text(windfe,width=6,height=1)
    tx6.place(x=158,y=270)
    tx7=tk.Text(windfe,width=6,height=1)
    tx7.place(x=300,y=220)
    tx8=tk.Text(windfe,width=6,height=1)
    tx8.place(x=300,y=260)
    windfe.mainloop

2.结果示例

在这里插入图片描述
在这里插入图片描述

posted @ 2021-11-23 17:19  TDTX  阅读(391)  评论(0编辑  收藏  举报