操作系统上机作业

操作系统上机作业:生产者,消费者算法(python,tkinter写)

import tkinter as tk
root = tk.Tk()
root.title("生产者消费者问题")
root.geometry('800x400')
on_hit1 = False
on_hit2 = False
on_hit3 = False
on_hit4 = False
on_hit5 = False
on_hit6 = False

def del_num():
    text1.delete(0)
    text1.insert(0,text2.get())
    text2.delete(0)
    text2.insert(0,text3.get())
    text3.delete(0)
    text3.insert(0,block1.get())
    block1.delete(0)
    block1.insert(0,block2.get())
    block2.delete(0)
    block2.insert(0,block3.get())
    block3.delete(0)

def del_xb():
    xb1.delete(0,2)
    xb1.insert(0,xb2.get())
    xb2.delete(0,2)
    xb2.insert(0,xb3.get())
    xb3.delete(0,2)

def insert_num1():
    global on_hit1,on_hit2,on_hit3,on_hit4,on_hit5,on_hit6
    if xb1.get() == '消1':
        del_xb()
        xbt1.config(state='normal')
    elif xb1.get() == '消2':
        del_xb()
        xbt2.config(state='normal')
    elif xb1.get() == '消3':
        del_xb()
        xbt3.config(state='normal')
    elif on_hit1 == False:
        text1.insert('insert',1)
        on_hit1 = True
    elif on_hit2 == False:
        text2.insert('insert',1)
        on_hit2 = True
    elif on_hit3 == False:
        text3.insert('insert',1)
        on_hit3 = True
    elif on_hit4 == False:
        block1.insert('insert',1)
        sbt1.config(state='disabled')
        on_hit4 = True
    elif on_hit5 == False:
        block2.insert('insert',1)
        sbt1.config(state='disabled')
        on_hit5 = True
    elif on_hit6 == False:
        block3.insert('insert',1)
        on_hit6 = True
        sbt1.config(state='disabled')
        sbt2.config(state='disabled')
        sbt3.config(state='disabled')
        
def insert_num2():
    global on_hit1,on_hit2,on_hit3,on_hit4,on_hit5,on_hit6
    if xb1.get() == '消1':
        del_xb()
        xbt1.config(state='normal')
    elif xb1.get() == '消2':
        del_xb()
        xbt2.config(state='normal')
    elif xb1.get() == '消3'
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值