0
基本上我寫了一個圖形用戶界面,使數學遊戲,並將其鏈接到我的microsft訪問數據庫使用sql,但我無法得到我的問題打印到我的標籤,任何想法?。另外,如何從我的問題列表中生成一個隨機數字,因爲您可以看到我的jim語句不起作用。麻煩顯示我的問題從我的數據庫
import Tkinter
import Databaseconnector
class simpleapp_tk(Tkinter.Tk):
def __init__(self,parent):
Tkinter.Tk.__init__(self,parent)
self.parent = parent
self.initialize()
def initialize(self):
jim = randomnumber()
SQL = 'SELECT * FROM tblQuestion'
cursor = Databaseconnector.SELECT(SQL)
rows = cursor.fectchall()
for row in rows:
print row.Question, row.Hint, row.A1, row.A2, row.A3, row.A4, row.CorrectAnswer
alabel2.set("Question: " + (row.question)(jim).Item(1))
def create_widgets(self):
# create welcome label
label1 = Tkinter.Label(self, text = "Question Game !")
label1.grid(row = 0, column = 1, columnspan = 2, sticky = 'W')
# create intruction label
alabel2 = Tkinter.Label(self, text = "")
alabel2.grid(row = 1, column = 0, columnspan = 2, sticky = 'W')
a1loginbutton = Tkinter.Button(self, text = "Enter",)
a1loginbutton.grid(row = 9, column = 1, sticky = 'W')
label3 = Tkinter.Label(self, text = "")
label3.grid(row = 10, column = 0, columnspan = 2, sticky = 'W')
a2loginbutton = Tkinter.Button(self, text = "Enter",)
a2loginbutton.grid(row = 11, column = 1, sticky = 'W')
a3loginbutton = Tkinter.Button(self, text = "Enter",)
a3loginbutton.grid(row = 9, column = 3, sticky = 'E')
a4loginbutton = Tkinter.Button(self, text = "Enter",)
a4loginbutton.grid(row = 11, column = 3, sticky = 'E')
label4 = Tkinter.Label(self, text = "")
label4.grid(row = 12, column = 0, columnspan = 2, sticky = 'W')
hiloginbutton = Tkinter.Button(self, text = "Hint",)
hiloginbutton.grid(row = 13, column = 3, sticky = 'E')
label5 = Tkinter.Label(self, text = "Score:")
label5.grid(row = 14, column = 1, columnspan = 5, sticky = 's')
def close_page(self):
self.destroy()
if __name__ == "__main__":
app = simpleapp_tk(None)
app.title('my application')
app.geometry("150x200")
app.mainloop()
據somethging我寫:DBFILE = 'E:\ COMPUTING課程\ OI OI \ FinallyWorking \工作\ Mathsvaders.accdb' 康恩= pyodbc.connect('DRIVER = {Microsoft Access驅動程序(* .MDB * .ACCDB)}; DBQ ='+ DBFILE) 光標= conn.cursor() #def DBCONNECT(): DEF SELECT(SQL): 打印(SQL) 返回cursor.execute(SQL) – 2013-02-20 10:26:08
我改變了cursor.fetchall的東西,但它不讓我把它放在標籤中 – 2013-02-20 10:43:46