Python 버전 2.7.8을 실행 중입니다. 나는 콤보 상자로 가져 오기 위해 노력하고있는 sqlite 데이터베이스에 프로젝트 제목을 저장하고있다. 나는 시도하고 콤보 상자에 SQLite 데이터베이스에서 프로젝트 타이틀을 가져 가져올 때 나는이 오류 : 형식 오류를 '유니 코드'객체는 호출하지 않습니다 여기에 Python 2.7.8 TypeError : 'unicode'객체를 호출 할 수 없습니다.
내 코드입니다 :main.py
from EvDB import EvDB
import wx
from ProjectsPanel import ProjectsPanel
class MyFrame(wx.Frame):
""" We simply derive a new class of Frame. """
def __init__(self, parent, ID, title):
wx.Frame.__init__(self, parent, ID, title=title, size=(650,725))
# Create Database Tables
self.db = EvDB(self)
self.db.createTbls()
main = wx.Panel(self)
self.projectsPg = ProjectsPanel(main, -1)
self.mainSizer = wx.BoxSizer(wx.VERTICAL)
self.mainSizer.Add(self.projectsPg, 1, wx.ALL|wx.EXPAND)
main.SetAutoLayout(True)
main.SetSizer(self.mainSizer)
self.mainSizer.Fit(main)
self.Layout()
self.Show()
self.UserID = 1
rows = self.db.getProjects(self.UserID)
print(rows)
print(str(rows))
self.projectsPg.cb.Value(rows)
app = wx.App(False)
ProjectsPanel.py
import wx
from EvDB import EvDB
import sqlite3 as lite
class ProjectsPanel(wx.Panel):
def __init__(self, parent, ID):
wx.Panel.__init__(self, parent, ID)
self.db = lite.connect('evDB.db')
self.cur = self.db.cursor()
self.db2 = EvDB(self)
sizer = wx.BoxSizer(wx.VERTICAL)
# the combobox Control
self.userProjects = ['Before1','Before2', 'Before3', 'Before4']
self.cb = wx.ComboBox(self, value='New', choices=self.userProjects, style=wx.CB_DROPDOWN)
sizer.Add(self.cb, 0, wx.EXPAND)
# Setting Layouts
self.SetAutoLayout(True)
self.SetSizer(sizer)
sizer.Fit(self)
EvDB.py
인쇄 결과: (u'Tests '), (u'Test1'), (u'Test2 '), (u'Test3')]
은 어떻게 추가 않는 내 콤보 상자에 내 sqlite 데이터베이스에 저장된 제목?
감사합니다.
편집 : 여기 콤보 객체 내 전체 역 추적
C:\Python27\python.exe C:/Users/xxx/xxx/xxx/main.py
[(u'Tests',), (u'Test1',), (u'Test2',), (u'Test3',)]
[(u'Tests',), (u'Test1',), (u'Test2',), (u'Test3',)]
Traceback (most recent call last):
File "C:/Users/xxx/xxx/xxx/main.py", line 43, in <module>
frame = MyFrame(None, -1, 'Small editor')
File "C:/Users/xxx/xxx/xxx/main.py", line 37, in __init__
self.projectsPg.cb.Value(rows)
TypeError: 'unicode' object is not callable
Process finished with exit code 1
질문을 업데이트하고 전체 추적을 추가하십시오. –