python中將十六進位制轉化為二進位制、python中變更button的text和bg
def SpeedTobyte(self):
#print(self.Eabs.get())
byte = float(self.Eabs.get())/0.05625
#print("byte =",end ='')
#print(int(byte))
#print(hex(int(byte)))
b = '{:013b}'.format(int(byte),16)
#print("b =",end ='')
#print(b)
ButtonLS[43]['text'] = b[12:13]
ButtonLS[44]['text'] = b[11:12]
ButtonLS[45]['text'] = b[10:11]
ButtonLS[46]['text'] = b[9:10]
ButtonLS[47]['text'] = b[8:9]
ButtonLS[32]['text'] = b[7:8]
ButtonLS[33]['text'] = b[6:7]
ButtonLS[34]['text'] = b[5:6]
ButtonLS[35]['text'] = b[4:5]
ButtonLS[36]['text'] = b[3:4]
ButtonLS[37]['text'] = b[2:3]
ButtonLS[38]['text'] = b[1:2]
ButtonLS[39]['text'] = b[0:1]
ButtonLS[43]['bg'] = 'black'
ButtonLS[44]['bg'] = 'black'
ButtonLS[45]['bg']= 'black'
ButtonLS[46]['bg']= 'black'
ButtonLS[47]['bg'] = 'black'
ButtonLS[32]['bg'] = 'black'
ButtonLS[33]['bg'] = 'black'
ButtonLS[34]['bg'] = 'black'
ButtonLS[35]['bg']= 'black'
ButtonLS[36]['bg'] = 'black'
ButtonLS[37]['bg'] = 'black'
ButtonLS[38]['bg'] = 'black'
ButtonLS[39]['bg'] = 'black'