【发布时间】:2011-07-21 17:07:31
【问题描述】:
class user_management(wx.Panel):
def login(self):
# Login Function can be later integrated to allow users access to your program
username = self.txt_Username.GetValue()
self.frame.SetStatusText("Welcome "+username+" to the system!!")
test = MyApp(0)
test.MainLoop()
如何在另一个类中访问变量用户名:
class wizard(wx.wizard.Wizard):
def on_finished(self, evt):
totalscore = self.totalscore
print "Final score: %s" % (totalscore)
user = "c1021358"
db_file="data/data.db"
database_already_exists = os.path.exists(db_file)
con = sqlite3.connect(db_file)
cur = con.cursor()
sql = "INSERT INTO scores (username,totalscore,topic) VALUES ('%s','%s','%s')" % (user,totalscore,tag)
目前用户是静态的,但是我想让这个用户变量等于从文本字段框中获取的用户名。
谁能告诉我该怎么做?
谢谢
【问题讨论】:
标签: python class methods static global