我正在尝试创建一个命令import wx
import sqlite3
class Frame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None)
#Dummy database
self.data = [['1111','Lots'],['2222','Fast'],['3333','Low']]
self.db = sqlite3.connect("test1.db")
self.cursor = self.db.cursor()
self.cursor.execute('CREATE TABLE IF NOT EXISTS TEST(Id Text, Value Text)')
self.cursor.execute("select * from TEST");
test = self.cursor.fetchone()
if not test:
for i in self.data:
result = self.db.execute("insert into Test (Id, Value) values (?,?)",(i[0],i[1]))
self.db.commit()
wx.StaticText(self, -1, "1. Wind Speed", (35, 75))
wx.StaticText(self, -1, "2. Site Power", (35, 95))
wx.StaticText(self, -1, "Instant", (300, 45))
wx.StaticText(self, -1, "m/s", (340, 75))
wx.StaticText(self, -1, "kW", (340, 95))
self.wind = wx.TextCtrl(self, -1, pos=(35,200),style=wx.TE_RIGHT|wx.TE_PROCESS_ENTER)
a = self.retrieve_data_fromdb()
self.wind_spd_val = wx.StaticText(self, -1, a[1], (300, 75))
#Bind the callbacks for the timer and the update function
self.wind.Bind(wx.EVT_TEXT_ENTER, self.OnUpdate)
self.dbtimer = wx.Timer(self)
self.Bind(wx.EVT_TIMER,self.OnTimer, self.dbtimer)
self.dbtimer.Start(1000)
def retrieve_data_fromdb(self):
self.cursor.execute("SELECT * FROM Test where Id = ?",['2222'])
a = self.cursor.fetchone()
return a
def OnUpdate(self,event):
self.cursor.execute("update Test set Value=? where Id=?" , (self.wind.GetValue(),'2222'))
self.db.commit()
def OnTimer(self,event):
a = self.retrieve_data_fromdb()
self.wind_spd_val.SetLabel(a[1])
print("Updated with "+str(a[1]))
if __name__ == '__main__':
app = wx.App()
frame = Frame()
frame.Show()
app.MainLoop()
,该命令会将指定的用户移动到特定的语音通道。
我无法使其正常运行,我也不确定为什么会收到任何错误消息。
代码:
!move username
为什么不起作用?