먼저 내가 아마추어 프로그래머임을 밝히는 것이 중요합니다.wxPython, 가져온 클래스의 필드 사용
파이썬에서 개인 소프트웨어를 구축/wxPython을은 MySQL의 DB
내 문제에 연결 :
가져온 파일에서 클래스에 액세스 할 하나의 양식을 작성하려고. 이 양식은 데이터베이스에서 관련 테이블을 한 번에 4 개 액세스합니다.
이 테이블 중 3 개는 항상 같습니다. 네 번째 테이블은 두 개의 테이블 중 하나 일 수 있습니다.
항상 액세스 테이블 : 세션, 심장 및 있습니다 다를 수 있습니다 표 노트 : 나는 위에서 언급 한 각 테이블에 대한 wx.Panel 클래스의 데이터 필드를 배치 한 물리적 또는 기계
가. mainForm의 메뉴는 물리적 또는 기계 매개 변수에 대한 참조와 함께 입력 양식을 호출합니다. 해당 양식이 해당 데이터 필드와 함께 표시됩니다.
내 문제는 데이터베이스에서 데이터를로드하기 위해 가져온 필드에 액세스 할 수 없다는 것입니다. 내 코드의
섹션 :
Mainform : dailyResultsV2.py
import inputForm as IF
# Menu Event:
데프 OnShowBikeRecs (자체 이벤트) :
self.bikeedit = IF.inputForm(None, -1, "Bike Record Management", size=(925,650), name="bike")
self.bikeedit.Show()
self.bikeedit.Center()
호출 형태 : inputForm.py
class inputForm(wx.Frame):
def __init__(self, parent, *args, **kwargs):
wx.Frame.__init__(self, parent, *args, **kwargs)
self.EXERCISE = kwargs['name']
# create a panel
self.panel = wx.Panel(self)
self.panel.BackgroundColour = (200, 230, 250)
self.filterSetup()
self.sessionSection = IFC.tblSession(self.panel,-1)
self.sessionSection.BackgroundColour = (200, 230, 250)
if self.EXERCISE == 'walk':
self.physicalSection = IFC.tblPhysical(self.panel,-1)
else:
self.machineSection = IFC.tblMachine(self.panel,-1)
self.cardioSection = IFC.tblcardio(self.panel,-1)
self.notesSection = IFC.tblNotes(self.panel,-1)
self.buttonSetup()
self.topsizer()
eding 클래스는 실제 테이블 또는 머신 테이블의 모든 필드를 포함하는 입력 양식을 작성합니다.
내 문제 데이터베이스에 데이터를 추가하거나 데이터베이스를 업데이트하기 위해이 필드에 액세스하는 방법에 관한 문제입니다. (한 쪽 메모는 신체적 훈련 데이터베이스입니다.) 가져온 클래스의
예 :
class tblMachine(wx.Panel):
def __init__(self, parent, *args, **kwargs):
wx.Panel.__init__(self, parent, *args, **kwargs)
self.BackgroundColour = (200, 230, 250)
# The columns
# machine_ID - not displayed machine_session_FK - not displayed machine_level - not displayed
# machine_Type_FK machine_Distance machine_AvgSpeed machine_MaxSpeed machine_Duration machine_ODO machine_RunFK - ComboBox
self.runNames = [] # ComboBox List
self.machineLabel_st = wx.StaticText(self, -1, "Machine", style=wx.ALIGN_LEFT)
self.machineType_st = wx.StaticText(self, -1, "Type", style=wx.ALIGN_LEFT)
self.machineType_tc = wx.TextCtrl(self, -1, value="Biking", style=wx.TE_CENTRE)
self.machineDistance_st = wx.StaticText(self, -1, "Distance", style=wx.ALIGN_LEFT)
self.machineDistance_tc = wx.TextCtrl(self, -1, style=wx.TE_CENTRE)
self.machineAvgSpeed_st = wx.StaticText(self, -1, "Avg. Speed", style=wx.ALIGN_LEFT)
self.machineAvgSpeed_tc = wx.TextCtrl(self, -1, style=wx.TE_CENTRE)
self.machineMaxSpeed_st = wx.StaticText(self, -1, "Max Speed", style=wx.ALIGN_LEFT)
self.machineMaxSpeed_tc = wx.TextCtrl(self, -1, style=wx.TE_CENTRE)
self.machineDuration_st = wx.StaticText(self, -1, "Duration", style=wx.ALIGN_LEFT)
self.machineDuration_mtc = masked.TimeCtrl(self, -1, fmt24hr=True)
self.machineODO_st = wx.StaticText(self, -1, "Odometer", style=wx.ALIGN_LEFT)
self.machineODO_tc = wx.TextCtrl(self, -1, style=wx.TE_CENTRE)
self.machineRun_st = wx.StaticText(self, -1, "Run", style=wx.ALIGN_LEFT)
self.machineRun_cbo = wx.ComboBox(self, -1, choices = self.getRunNames(self.runNames), style=wx.CB_READONLY) # get the list of runs for comboBox
# create machine sizer
self.MachineSizer = wx.GridBagSizer(hgap=5, vgap=5)
inputFormClasses.py
어떻게 예를 들어 액세스합니다 : self.machineType_tc를 내 양식에?
입력 용 Lance. 나는 분명치 않다. 내 데이터베이스에 액세스하는 데 문제가 없습니다. 내 문제는 프로그래밍 된 데이터 양식에 액세스하는 것이 었습니다. 나는 내 자신의 문제를 해결했다고 믿는다. 클래스의 특정 변수에 액세스하려면 컨트롤 변수 이름 앞에 클래스를 인스턴스화하는 변수를 추가해야합니다. (나는이 말을 바랄 뿐이다) –