python - 如何修复更改值 def 以便当我按下它的按钮时,我的所有其他按钮都不会被清除?
问题描述
def change_value():
global value
value -= 1
enteredText = str(Entry.get(spkInpt))
if value == 0:
p1.show
displayMain.insert(END, "User:" + enteredText + '\n')
displayMain.configure(state='normal')
readInput()
spkInpt.delete(0, 'end')
value = 1
elif value == 1:
p1.show
displayMain.configure(state='disabled')
else:
pass
def speakButton():
spkBtn=Button(root, text='send', bg='green', font=('Arial',15), command=change_value)
spkBtn.place(relheight=0.1, relwidth=0.2, relx= 0.2, rely=0.9)
#check if enter is pressed (not completed !!!!!)
if keyboard.is_pressed('return'):
spkBtn()
else:
pass
#Sidebar -------------------------------------------------------------------------------------------------------------------------------------
def mathButton():
mathButton=Button(self, text="Math", bg='red', font=("Arial", 15), command=p2.show)
mathButton.place(relheight=0.1, relwidth=0.2, relx=0, rely=0.1)
def connectedDevices():
conDev=Button(self, text="Connected Devices", bg="grey", font=("Arial", 15))
conDev.place(relheight=0.1, relwidth=0.2, rely=0, relx=0)
def sidebar():
mathButton()
connectedDevices()
我能对 displayMain.insert(END...) 做些什么吗,因为当我按下 speakButton 时,它也会擦除我所有的其他按钮,但是当我只是在没有 change_value 命令的情况下执行按钮时,什么都不会发生,我的按钮保持不变,那又怎样?我是否要阻止我的按钮被擦拭。
解决方案
推荐阅读
- python - 在 google colab 中与其他协作者共享文件
- c++ - 我应该如何使用epoll从同一个FD读取和写入
- reactjs - React:使用索引作为列表中项目的键
- php - 我需要一个域来设置 Apache 服务器吗?
- javascript - 如何在 xslt 脚本中导入 Javascript 对象
- python - Python-AttributeError: 'NoneType' 对象没有属性 'find';;;
- java - Spring Cloud AWS SQS 无法在本地连接到服务端点
- angular - HttpParams 在 Angular 中不起作用,出现 502 错误
- python - 在Python中查找曲线中最近点到有界n维空间中任意点的距离
- flutter - 从 Map Markers 到 Detail 页面的 Flutter Hero 动画