Python教程

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

本文主要是介绍Python——逻辑异或运算及图示(采用逻辑异或运算方法实现)(tkinter实现),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

目录
  • 1.difortu.py
  • 2.结果示例

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

1.difortu.py

def difortu():
    import tkinter as tk
    windor=tk.Tk()
    windor.title('逻辑异或及图示')
    windor.geometry('500x500')
    def qor():
        tx5.delete(1.0,'end')
        tx6.delete(1.0,'end')
        tx7.delete(1.0,'end')
        tx.delete(0.0,tk.END)
        q=eval(ent1.get())
        p=eval(ent2.get())
        if q == p:
            tx.insert('insert',0)
            tx7.insert('insert',0)
        else:
            tx.insert('insert',1)
            tx7.insert('insert',1)
        tx5.insert('insert',q)
        tx6.insert('insert',p)
    lb1=tk.Label(windor,text='输入q值:',fg='blue',width=10,height=2)
    lb1.place(x=100,y=30)
    ent1=tk.Entry(windor,width=5)
    ent1.place(x=170,y=35)
    lbs=tk.Label(windor,text='⊕',fg='red')
    lbs.place(x=220,y=35)
    lb2=tk.Label(windor,text='输入p值:',fg='blue',width=10,height=2)
    lb2.place(x=235,y=30)
    ent2=tk.Entry(windor,width=5)
    ent2.place(x=300,y=35)
    bt1=tk.Button(windor,text='求解q⊕p',command=qor)
    bt1.place(x=200,y=70)
    lbf=tk.Label(windor,text='-----------------------------------------------')
    lbf.place(x=110,y=95)
    lb3=tk.Label(windor,text='q⊕p值为:',fg='blue',bg='yellow')
    lb3.place(x=200,y=120)
    tx=tk.Text(windor,width=2,height=1)
    tx.place(x=230,y=150)
    canvas=tk.Canvas(windor,bg='white',height=100,width=280)
    line=canvas.create_line(50,40,140,40)
    line=canvas.create_line(80,40,70,46)
    line=canvas.create_line(80,40,70,34)
    line=canvas.create_line(50,60,140,60)
    line=canvas.create_line(80,60,70,66)
    line=canvas.create_line(80,60,70,54) 
    arc = canvas.create_arc(100,25,140,75,start=270,extent=180,style=tk.ARC)

    arc = canvas.create_arc(80,25,130,75,start=270,extent=180,style=tk.ARC)
    
    #arc = canvas.create_arc(100,25,170,75,start=270,extent=180,style=tk.ARC)
    arc = canvas.create_arc(60,25,180,75,start=270,extent=180,style=tk.ARC)

    
    line=canvas.create_line(180,50,250,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(windor,text='q')
    lb4.place(x=135,y=210)
    lb5=tk.Label(windor,text='p')
    lb5.place(x=135,y=270)
    lb6=tk.Label(windor,text='q⊕p')
    lb6.place(x=280,y=220)
    tx5=tk.Text(windor,width=6,height=1)
    tx5.place(x=158,y=210)
    tx6=tk.Text(windor,width=6,height=1)
    tx6.place(x=158,y=270)
    tx7=tk.Text(windor,width=6,height=1)
    tx7.place(x=320,y=220)
    windor.mainloop

2.结果示例

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

这篇关于Python——逻辑异或运算及图示(采用逻辑异或运算方法实现)(tkinter实现)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!