ich habe eine PropertyPage und die einzelnen Tabs sollen miteinander kommunizieren können. Allerdings bekomme ich immer folgenden Fehler wenn ich etwas auf dem zweiten Tab ändern will.
Es handelt sich um eine PropertyPage, die zwei Tabs beinhaltet.
In einem Tab habe ich ein Eingabefeld, ein Label und zwei Buttons.
Ein Button schreibt den Text aus dem Eingabefeld in das Label, der andere soll den Text in ein Label auf Tab2 schreiben. Und genau dort tritt der Fehler auf.
Ich bin eigendlich davon ausgegangen, daß die Controls überall bekannt sind, da sie als private deklariert wurden. Dem scheint aber leider nicht so zu sein.
(null)
Traceback (most recent call last):
File "E:\Eclipse_3.2_Workspace\Area54\src\TC.py", line 43, in OnSend
self.GetDlgItem(IDC_OUT).SetWindowText(Text)
win32ui: No dialog control with that ID
(null)
win32ui: Error in Command Message handler for command ID 1002, Code 0
Code: Alles auswählen
import win32con
import win32api
import win32ui
from pywin.mfc import dialog
IDC_IN = 1000
IDC_OUT = 1001
IDC_SEND = 1002
IDC_SENDOWN = 1003
IDC_OUTOWN = 1004
_IDL_LISTPAGE1 = [
["Input", (0, 0, 250, 150), win32con.WS_CAPTION, None, (10, "MS Sans Serif")],
["Edit", None , IDC_IN , (10, 10, 150, 10), win32con.WS_TABSTOP | win32con.WS_VISIBLE | win32con.WS_BORDER],
["Static", None, IDC_OUTOWN, (10, 30, 150, 10), win32con.WS_VISIBLE | win32con.WS_BORDER],
["Button", "Send own", IDC_SENDOWN, (10, 70, 50, 15), win32con.WS_TABSTOP | win32con.WS_VISIBLE | win32con.BS_NOTIFY],
["Button", "Send other", IDC_SEND, (70, 70, 50, 15), win32con.WS_TABSTOP | win32con.WS_VISIBLE | win32con.BS_NOTIFY]
]
_IDL_LISTPAGE2 = [
["Output", (0, 0, 250, 150), win32con.WS_CAPTION, None, (10, "MS Sans Serif")],
["Static", None, IDC_OUT, (10, 10, 150, 10), win32con.WS_VISIBLE | win32con.WS_BORDER]
]
class TestSheet(dialog.PropertySheet):
def __init__(self, Title, Parent):
dialog.PropertySheet.__init__(self, Title)
self.Parent = Parent
class TestPage(dialog.PropertyPage):
def __init__(self, rcList, Parent, ParentWindow):
dialog.PropertyPage.__init__(self, rcList)
self.Parent = Parent
self.ParentWindow = ParentWindow
self.HookCommand(self.OnSend, IDC_SEND)
self.HookCommand(self.OnSendOwn, IDC_SENDOWN)
def OnSend(self, ID, Code):
if Code == win32con.BN_CLICKED:
Text = self.GetDlgItem(IDC_IN).GetWindowText()
self.GetDlgItem(IDC_OUT).SetWindowText(Text)
def OnSendOwn(self, ID, Code):
if Code == win32con.BN_CLICKED:
Text = self.GetDlgItem(IDC_IN).GetWindowText()
self.GetDlgItem(IDC_OUTOWN).SetWindowText(Text)
def run(Parent):
PropSheet = TestSheet('Tabbed Control Test', Parent)
Page1 = TestPage(_IDL_LISTPAGE1, PropSheet, Parent)
Page2 = TestPage(_IDL_LISTPAGE2, PropSheet, Parent)
PropSheet.AddPage(Page1)
PropSheet.AddPage(Page2)
PropSheet.DoModal()
if __name__=='__main__':
run(None)
Ich weiß, daß viele es als umständlich empfinden die GUI so aufzubauen, das steht hier aber nicht zur Debatte
Gruß
Nergal