From d5d5198c756e7545fdeaa3e7011d6333dbcc7992 Mon Sep 17 00:00:00 2001 From: cliechti Date: Thu, 10 Apr 2008 23:48:55 +0000 Subject: Port to wx 2.8 by Peleg --- pyserial/examples/wxSerialConfigDialog.py | 133 +++++++++++++++--------------- pyserial/examples/wxTerminal.py | 111 +++++++++++++------------ 2 files changed, 123 insertions(+), 121 deletions(-) diff --git a/pyserial/examples/wxSerialConfigDialog.py b/pyserial/examples/wxSerialConfigDialog.py index 5543537..7085035 100644 --- a/pyserial/examples/wxSerialConfigDialog.py +++ b/pyserial/examples/wxSerialConfigDialog.py @@ -1,7 +1,8 @@ #!/usr/bin/env python # generated by wxGlade 0.3.1 on Thu Oct 02 23:25:44 2003 -from wxPython.wx import * +#from wxPython.wx import * +import wx import serial SHOW_BAUDRATE = 1<<0 @@ -16,7 +17,7 @@ except NameError: def enumerate(sequence): return zip(range(len(sequence)), sequence) -class SerialConfigDialog(wxDialog): +class SerialConfigDialog(wx.Dialog): """Serial Port confiuration dialog, to be used with pyserial 2.0+ When instantiating a class of this dialog, then the "serial" keyword argument is mandatory. It is a reference to a serial.Serial instance. @@ -35,29 +36,29 @@ class SerialConfigDialog(wxDialog): del kwds['show'] # begin wxGlade: SerialConfigDialog.__init__ # end wxGlade - kwds["style"] = wxDEFAULT_DIALOG_STYLE - wxDialog.__init__(self, *args, **kwds) - self.label_2 = wxStaticText(self, -1, "Port") - self.combo_box_port = wxComboBox(self, -1, choices=["dummy1", "dummy2", "dummy3", "dummy4", "dummy5"], style=wxCB_DROPDOWN) + kwds["style"] = wx.DEFAULT_DIALOG_STYLE + wx.Dialog.__init__(self, *args, **kwds) + self.label_2 = wx.StaticText(self, -1, "Port") + self.combo_box_port = wx.ComboBox(self, -1, choices=["dummy1", "dummy2", "dummy3", "dummy4", "dummy5"], style=wx.CB_DROPDOWN) if self.show & SHOW_BAUDRATE: - self.label_1 = wxStaticText(self, -1, "Baudrate") - self.choice_baudrate = wxChoice(self, -1, choices=["choice 1"]) + self.label_1 = wx.StaticText(self, -1, "Baudrate") + self.choice_baudrate = wx.Choice(self, -1, choices=["choice 1"]) if self.show & SHOW_FORMAT: - self.label_3 = wxStaticText(self, -1, "Data Bits") - self.choice_databits = wxChoice(self, -1, choices=["choice 1"]) - self.label_4 = wxStaticText(self, -1, "Stop Bits") - self.choice_stopbits = wxChoice(self, -1, choices=["choice 1"]) - self.label_5 = wxStaticText(self, -1, "Parity") - self.choice_parity = wxChoice(self, -1, choices=["choice 1"]) + self.label_3 = wx.StaticText(self, -1, "Data Bits") + self.choice_databits = wx.Choice(self, -1, choices=["choice 1"]) + self.label_4 = wx.StaticText(self, -1, "Stop Bits") + self.choice_stopbits = wx.Choice(self, -1, choices=["choice 1"]) + self.label_5 = wx.StaticText(self, -1, "Parity") + self.choice_parity = wx.Choice(self, -1, choices=["choice 1"]) if self.show & SHOW_TIMEOUT: - self.checkbox_timeout = wxCheckBox(self, -1, "Use Timeout") - self.text_ctrl_timeout = wxTextCtrl(self, -1, "") - self.label_6 = wxStaticText(self, -1, "seconds") + self.checkbox_timeout = wx.CheckBox(self, -1, "Use Timeout") + self.text_ctrl_timeout = wx.TextCtrl(self, -1, "") + self.label_6 = wx.StaticText(self, -1, "seconds") if self.show & SHOW_FLOW: - self.checkbox_rtscts = wxCheckBox(self, -1, "RTS/CTS") - self.checkbox_xonxoff = wxCheckBox(self, -1, "Xon/Xoff") - self.button_ok = wxButton(self, -1, "OK") - self.button_cancel = wxButton(self, -1, "Cancel") + self.checkbox_rtscts = wx.CheckBox(self, -1, "RTS/CTS") + self.checkbox_xonxoff = wx.CheckBox(self, -1, "Xon/Xoff") + self.button_ok = wx.Button(self, -1, "OK") + self.button_cancel = wx.Button(self, -1, "Cancel") self.__set_properties() self.__do_layout() @@ -131,49 +132,49 @@ class SerialConfigDialog(wxDialog): def __do_layout(self): # begin wxGlade: SerialConfigDialog.__do_layout # end wxGlade - sizer_2 = wxBoxSizer(wxVERTICAL) - sizer_3 = wxBoxSizer(wxHORIZONTAL) - sizer_basics = wxStaticBoxSizer(wxStaticBox(self, -1, "Basics"), wxVERTICAL) - sizer_5 = wxBoxSizer(wxHORIZONTAL) - sizer_5.Add(self.label_2, 1, wxALL|wxALIGN_CENTER_VERTICAL, 4) + sizer_2 = wx.BoxSizer(wx.VERTICAL) + sizer_3 = wx.BoxSizer(wx.HORIZONTAL) + sizer_basics = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Basics"), wx.VERTICAL) + sizer_5 = wx.BoxSizer(wx.HORIZONTAL) + sizer_5.Add(self.label_2, 1, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4) sizer_5.Add(self.combo_box_port, 1, 0, 0) - sizer_basics.Add(sizer_5, 0, wxRIGHT|wxEXPAND, 0) + sizer_basics.Add(sizer_5, 0, wx.RIGHT|wx.EXPAND, 0) if self.show & SHOW_BAUDRATE: - sizer_baudrate = wxBoxSizer(wxHORIZONTAL) - sizer_baudrate.Add(self.label_1, 1, wxALL|wxALIGN_CENTER_VERTICAL, 4) - sizer_baudrate.Add(self.choice_baudrate, 1, wxALIGN_RIGHT, 0) - sizer_basics.Add(sizer_baudrate, 0, wxEXPAND, 0) - sizer_2.Add(sizer_basics, 0, wxEXPAND, 0) + sizer_baudrate = wx.BoxSizer(wx.HORIZONTAL) + sizer_baudrate.Add(self.label_1, 1, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4) + sizer_baudrate.Add(self.choice_baudrate, 1, wx.ALIGN_RIGHT, 0) + sizer_basics.Add(sizer_baudrate, 0, wx.EXPAND, 0) + sizer_2.Add(sizer_basics, 0, wx.EXPAND, 0) if self.show & SHOW_FORMAT: - sizer_8 = wxBoxSizer(wxHORIZONTAL) - sizer_7 = wxBoxSizer(wxHORIZONTAL) - sizer_6 = wxBoxSizer(wxHORIZONTAL) - sizer_format = wxStaticBoxSizer(wxStaticBox(self, -1, "Data Format"), wxVERTICAL) - sizer_6.Add(self.label_3, 1, wxALL|wxALIGN_CENTER_VERTICAL, 4) - sizer_6.Add(self.choice_databits, 1, wxALIGN_RIGHT, 0) - sizer_format.Add(sizer_6, 0, wxEXPAND, 0) - sizer_7.Add(self.label_4, 1, wxALL|wxALIGN_CENTER_VERTICAL, 4) - sizer_7.Add(self.choice_stopbits, 1, wxALIGN_RIGHT, 0) - sizer_format.Add(sizer_7, 0, wxEXPAND, 0) - sizer_8.Add(self.label_5, 1, wxALL|wxALIGN_CENTER_VERTICAL, 4) - sizer_8.Add(self.choice_parity, 1, wxALIGN_RIGHT, 0) - sizer_format.Add(sizer_8, 0, wxEXPAND, 0) - sizer_2.Add(sizer_format, 0, wxEXPAND, 0) + sizer_8 = wx.BoxSizer(wx.HORIZONTAL) + sizer_7 = wx.BoxSizer(wx.HORIZONTAL) + sizer_6 = wx.BoxSizer(wx.HORIZONTAL) + sizer_format = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Data Format"), wx.VERTICAL) + sizer_6.Add(self.label_3, 1, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4) + sizer_6.Add(self.choice_databits, 1, wx.ALIGN_RIGHT, 0) + sizer_format.Add(sizer_6, 0, wx.EXPAND, 0) + sizer_7.Add(self.label_4, 1, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4) + sizer_7.Add(self.choice_stopbits, 1, wx.ALIGN_RIGHT, 0) + sizer_format.Add(sizer_7, 0, wx.EXPAND, 0) + sizer_8.Add(self.label_5, 1, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4) + sizer_8.Add(self.choice_parity, 1, wx.ALIGN_RIGHT, 0) + sizer_format.Add(sizer_8, 0, wx.EXPAND, 0) + sizer_2.Add(sizer_format, 0, wx.EXPAND, 0) if self.show & SHOW_TIMEOUT: - sizer_timeout = wxStaticBoxSizer(wxStaticBox(self, -1, "Timeout"), wxHORIZONTAL) - sizer_timeout.Add(self.checkbox_timeout, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4) + sizer_timeout = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Timeout"), wx.HORIZONTAL) + sizer_timeout.Add(self.checkbox_timeout, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4) sizer_timeout.Add(self.text_ctrl_timeout, 0, 0, 0) - sizer_timeout.Add(self.label_6, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4) + sizer_timeout.Add(self.label_6, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4) sizer_2.Add(sizer_timeout, 0, 0, 0) if self.show & SHOW_FLOW: - sizer_flow = wxStaticBoxSizer(wxStaticBox(self, -1, "Flow Control"), wxHORIZONTAL) - sizer_flow.Add(self.checkbox_rtscts, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4) - sizer_flow.Add(self.checkbox_xonxoff, 0, wxALL|wxALIGN_CENTER_VERTICAL, 4) - sizer_flow.Add((10,10), 1, wxEXPAND, 0) - sizer_2.Add(sizer_flow, 0, wxEXPAND, 0) + sizer_flow = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Flow Control"), wx.HORIZONTAL) + sizer_flow.Add(self.checkbox_rtscts, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4) + sizer_flow.Add(self.checkbox_xonxoff, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 4) + sizer_flow.Add((10,10), 1, wx.EXPAND, 0) + sizer_2.Add(sizer_flow, 0, wx.EXPAND, 0) sizer_3.Add(self.button_ok, 0, 0, 0) sizer_3.Add(self.button_cancel, 0, 0, 0) - sizer_2.Add(sizer_3, 0, wxALL|wxALIGN_RIGHT, 4) + sizer_2.Add(sizer_3, 0, wx.ALL|wx.ALIGN_RIGHT, 4) self.SetAutoLayout(1) self.SetSizer(sizer_2) sizer_2.Fit(self) @@ -181,10 +182,10 @@ class SerialConfigDialog(wxDialog): self.Layout() def __attach_events(self): - EVT_BUTTON(self, self.button_ok.GetId(), self.OnOK) - EVT_BUTTON(self, self.button_cancel.GetId(), self.OnCancel) + wx.EVT_BUTTON(self, self.button_ok.GetId(), self.OnOK) + wx.EVT_BUTTON(self, self.button_cancel.GetId(), self.OnCancel) if self.show & SHOW_TIMEOUT: - EVT_CHECKBOX(self, self.checkbox_timeout.GetId(), self.OnTimeout) + wx.EVT_CHECKBOX(self, self.checkbox_timeout.GetId(), self.OnTimeout) def OnOK(self, events): success = True @@ -203,18 +204,18 @@ class SerialConfigDialog(wxDialog): try: self.serial.timeout = float(self.text_ctrl_timeout.GetValue()) except ValueError: - dlg = wxMessageDialog(self, 'Timeout must be a numeric value', - 'Value Error', wxOK | wxICON_ERROR) + dlg = wx.MessageDialog(self, 'Timeout must be a numeric value', + 'Value Error', wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() success = False else: self.serial.timeout = None if success: - self.EndModal(wxID_OK) + self.EndModal(wx.ID_OK) def OnCancel(self, events): - self.EndModal(wxID_CANCEL) + self.EndModal(wx.ID_CANCEL) def OnTimeout(self, events): if self.checkbox_timeout.GetValue(): @@ -225,10 +226,10 @@ class SerialConfigDialog(wxDialog): # end of class SerialConfigDialog -class MyApp(wxApp): +class MyApp(wx.App): """Test code""" def OnInit(self): - wxInitAllImageHandlers() + wx.InitAllImageHandlers() ser = serial.Serial() print ser @@ -240,7 +241,7 @@ class MyApp(wxApp): self.SetTopWindow(dialog_serial_cfg) result = dialog_serial_cfg.ShowModal() print ser - if result != wxID_OK: + if result != wx.ID_OK: break #the user can play around with the values, CANCEL aborts the loop while 1: @@ -248,7 +249,7 @@ class MyApp(wxApp): self.SetTopWindow(dialog_serial_cfg) result = dialog_serial_cfg.ShowModal() print ser - if result != wxID_OK: + if result != wx.ID_OK: break return 0 diff --git a/pyserial/examples/wxTerminal.py b/pyserial/examples/wxTerminal.py index 622f485..646c272 100644 --- a/pyserial/examples/wxTerminal.py +++ b/pyserial/examples/wxTerminal.py @@ -1,7 +1,8 @@ #!/usr/bin/env python # generated by wxGlade 0.3.1 on Fri Oct 03 23:23:45 2003 -from wxPython.wx import * +#from wxPython.wx import * +import wx import wxSerialConfigDialog import serial import threading @@ -12,14 +13,14 @@ import threading # access the GUI without crashing. wxMutexGuiEnter/wxMutexGuiLeave # could be used too, but an event is more elegant. -SERIALRX = wxNewEventType() +SERIALRX = wx.NewEventType() # bind to serial data receive events -EVT_SERIALRX = wxPyEventBinder(SERIALRX, 0) +EVT_SERIALRX = wx.PyEventBinder(SERIALRX, 0) -class SerialRxEvent(wxPyCommandEvent): +class SerialRxEvent(wx.PyCommandEvent): eventType = SERIALRX def __init__(self, windowID, data): - wxPyCommandEvent.__init__(self, self.eventType, windowID) + wx.PyCommandEvent.__init__(self, self.eventType, windowID) self.data = data def Clone(self): @@ -27,11 +28,11 @@ class SerialRxEvent(wxPyCommandEvent): #---------------------------------------------------------------------- -ID_CLEAR = wxNewId() -ID_SAVEAS = wxNewId() -ID_SETTINGS = wxNewId() -ID_TERM = wxNewId() -ID_EXIT = wxNewId() +ID_CLEAR = wx.NewId() +ID_SAVEAS = wx.NewId() +ID_SETTINGS = wx.NewId() +ID_TERM = wx.NewId() +ID_EXIT = wx.NewId() NEWLINE_CR = 0 NEWLINE_LF = 1 @@ -45,20 +46,20 @@ class TerminalSetup: self.unprintable = False self.newline = NEWLINE_CRLF -class TerminalSettingsDialog(wxDialog): +class TerminalSettingsDialog(wx.Dialog): """Simple dialog with common terminal settings like echo, newline mode.""" def __init__(self, *args, **kwds): self.settings = kwds['settings'] del kwds['settings'] # begin wxGlade: TerminalSettingsDialog.__init__ - kwds["style"] = wxDEFAULT_DIALOG_STYLE - wxDialog.__init__(self, *args, **kwds) - self.checkbox_echo = wxCheckBox(self, -1, "Local Echo") - self.checkbox_unprintable = wxCheckBox(self, -1, "Show unprintable characters") - self.radio_box_newline = wxRadioBox(self, -1, "Newline Handling", choices=["CR only", "LF only", "CR+LF"], majorDimension=0, style=wxRA_SPECIFY_ROWS) - self.button_ok = wxButton(self, -1, "OK") - self.button_cancel = wxButton(self, -1, "Cancel") + kwds["style"] = wx.DEFAULT_DIALOG_STYLE + wx.Dialog.__init__(self, *args, **kwds) + self.checkbox_echo = wx.CheckBox(self, -1, "Local Echo") + self.checkbox_unprintable = wx.CheckBox(self, -1, "Show unprintable characters") + self.radio_box_newline = wx.RadioBox(self, -1, "Newline Handling", choices=["CR only", "LF only", "CR+LF"], majorDimension=0, style=wx.RA_SPECIFY_ROWS) + self.button_ok = wx.Button(self, -1, "OK") + self.button_cancel = wx.Button(self, -1, "Cancel") self.__set_properties() self.__do_layout() @@ -77,16 +78,16 @@ class TerminalSettingsDialog(wxDialog): def __do_layout(self): # begin wxGlade: TerminalSettingsDialog.__do_layout - sizer_2 = wxBoxSizer(wxVERTICAL) - sizer_3 = wxBoxSizer(wxHORIZONTAL) - sizer_4 = wxStaticBoxSizer(wxStaticBox(self, -1, "Input/Output"), wxVERTICAL) - sizer_4.Add(self.checkbox_echo, 0, wxALL, 4) - sizer_4.Add(self.checkbox_unprintable, 0, wxALL, 4) + sizer_2 = wx.BoxSizer(wx.VERTICAL) + sizer_3 = wx.BoxSizer(wx.HORIZONTAL) + sizer_4 = wx.StaticBoxSizer(wx.StaticBox(self, -1, "Input/Output"), wx.VERTICAL) + sizer_4.Add(self.checkbox_echo, 0, wx.ALL, 4) + sizer_4.Add(self.checkbox_unprintable, 0, wx.ALL, 4) sizer_4.Add(self.radio_box_newline, 0, 0, 0) - sizer_2.Add(sizer_4, 0, wxEXPAND, 0) + sizer_2.Add(sizer_4, 0, wx.EXPAND, 0) sizer_3.Add(self.button_ok, 0, 0, 0) sizer_3.Add(self.button_cancel, 0, 0, 0) - sizer_2.Add(sizer_3, 0, wxALL|wxALIGN_RIGHT, 4) + sizer_2.Add(sizer_3, 0, wx.ALL|wx.ALIGN_RIGHT, 4) self.SetAutoLayout(1) self.SetSizer(sizer_2) sizer_2.Fit(self) @@ -95,24 +96,24 @@ class TerminalSettingsDialog(wxDialog): # end wxGlade def __attach_events(self): - self.Bind(EVT_BUTTON, self.OnOK, id = self.button_ok.GetId()) - self.Bind(EVT_BUTTON, self.OnCancel, id = self.button_cancel.GetId()) + self.Bind(wx.EVT_BUTTON, self.OnOK, id = self.button_ok.GetId()) + self.Bind(wx.EVT_BUTTON, self.OnCancel, id = self.button_cancel.GetId()) def OnOK(self, events): """Update data wil new values and close dialog.""" self.settings.echo = self.checkbox_echo.GetValue() self.settings.unprintable = self.checkbox_unprintable.GetValue() self.settings.newline = self.radio_box_newline.GetSelection() - self.EndModal(wxID_OK) + self.EndModal(wx.ID_OK) def OnCancel(self, events): """Do not update data but close dialog.""" - self.EndModal(wxID_CANCEL) + self.EndModal(wx.ID_CANCEL) # end of class TerminalSettingsDialog -class TerminalFrame(wxFrame): +class TerminalFrame(wx.Frame): """Simple terminal program for wxPython""" def __init__(self, *args, **kwds): @@ -122,21 +123,21 @@ class TerminalFrame(wxFrame): self.thread = None self.alive = threading.Event() # begin wxGlade: TerminalFrame.__init__ - kwds["style"] = wxDEFAULT_FRAME_STYLE - wxFrame.__init__(self, *args, **kwds) - self.text_ctrl_output = wxTextCtrl(self, -1, "", style=wxTE_MULTILINE|wxTE_READONLY) + kwds["style"] = wx.DEFAULT_FRAME_STYLE + wx.Frame.__init__(self, *args, **kwds) + self.text_ctrl_output = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE|wx.TE_READONLY) # Menu Bar - self.frame_terminal_menubar = wxMenuBar() + self.frame_terminal_menubar = wx.MenuBar() self.SetMenuBar(self.frame_terminal_menubar) - wxglade_tmp_menu = wxMenu() - wxglade_tmp_menu.Append(ID_CLEAR, "&Clear", "", wxITEM_NORMAL) - wxglade_tmp_menu.Append(ID_SAVEAS, "&Save Text As...", "", wxITEM_NORMAL) + wxglade_tmp_menu = wx.Menu() + wxglade_tmp_menu.Append(ID_CLEAR, "&Clear", "", wx.ITEM_NORMAL) + wxglade_tmp_menu.Append(ID_SAVEAS, "&Save Text As...", "", wx.ITEM_NORMAL) wxglade_tmp_menu.AppendSeparator() - wxglade_tmp_menu.Append(ID_SETTINGS, "&Port Settings...", "", wxITEM_NORMAL) - wxglade_tmp_menu.Append(ID_TERM, "&Terminal Settings...", "", wxITEM_NORMAL) + wxglade_tmp_menu.Append(ID_SETTINGS, "&Port Settings...", "", wx.ITEM_NORMAL) + wxglade_tmp_menu.Append(ID_TERM, "&Terminal Settings...", "", wx.ITEM_NORMAL) wxglade_tmp_menu.AppendSeparator() - wxglade_tmp_menu.Append(ID_EXIT, "&Exit", "", wxITEM_NORMAL) + wxglade_tmp_menu.Append(ID_EXIT, "&Exit", "", wx.ITEM_NORMAL) self.frame_terminal_menubar.Append(wxglade_tmp_menu, "&File") # Menu Bar end @@ -170,8 +171,8 @@ class TerminalFrame(wxFrame): def __do_layout(self): # begin wxGlade: TerminalFrame.__do_layout - sizer_1 = wxBoxSizer(wxVERTICAL) - sizer_1.Add(self.text_ctrl_output, 1, wxEXPAND, 0) + sizer_1 = wx.BoxSizer(wx.VERTICAL) + sizer_1.Add(self.text_ctrl_output, 1, wx.EXPAND, 0) self.SetAutoLayout(1) self.SetSizer(sizer_1) self.Layout() @@ -179,14 +180,14 @@ class TerminalFrame(wxFrame): def __attach_events(self): #register events at the controls - self.Bind(EVT_MENU, self.OnClear, id = ID_CLEAR) - self.Bind(EVT_MENU, self.OnSaveAs, id = ID_SAVEAS) - self.Bind(EVT_MENU, self.OnExit, id = ID_EXIT) - self.Bind(EVT_MENU, self.OnPortSettings, id = ID_SETTINGS) - self.Bind(EVT_MENU, self.OnTermSettings, id = ID_TERM) - self.text_ctrl_output.Bind(EVT_CHAR, self.OnKey) + self.Bind(wx.EVT_MENU, self.OnClear, id = ID_CLEAR) + self.Bind(wx.EVT_MENU, self.OnSaveAs, id = ID_SAVEAS) + self.Bind(wx.EVT_MENU, self.OnExit, id = ID_EXIT) + self.Bind(wx.EVT_MENU, self.OnPortSettings, id = ID_SETTINGS) + self.Bind(wx.EVT_MENU, self.OnTermSettings, id = ID_TERM) + self.text_ctrl_output.Bind(wx.EVT_CHAR, self.OnKey) self.Bind(EVT_SERIALRX, self.OnSerialRead) - self.Bind(EVT_CLOSE, self.OnClose) + self.Bind(wx.EVT_CLOSE, self.OnClose) def OnExit(self, event): """Menu point Exit""" @@ -201,8 +202,8 @@ class TerminalFrame(wxFrame): def OnSaveAs(self, event): """Save contents of output window.""" filename = None - dlg = wxFileDialog(None, "Save Text As...", ".", "", "Text File|*.txt|All Files|*", wxSAVE) - if dlg.ShowModal() == wxID_OK: + dlg = wx.FileDialog(None, "Save Text As...", ".", "", "Text File|*.txt|All Files|*", wx.SAVE) + if dlg.ShowModal() == wx.ID_OK: filename = dlg.GetPath() dlg.Destroy() @@ -233,11 +234,11 @@ class TerminalFrame(wxFrame): result = dialog_serial_cfg.ShowModal() dialog_serial_cfg.Destroy() #open port if not called on startup, open it on startup and OK too - if result == wxID_OK or event is not None: + if result == wx.ID_OK or event is not None: try: self.serial.open() except serial.SerialException, e: - dlg = wxMessageDialog(None, str(e), "Serial Port Error", wxOK | wxICON_ERROR) + dlg = wx.MessageDialog(None, str(e), "Serial Port Error", wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() else: @@ -317,9 +318,9 @@ class TerminalFrame(wxFrame): # end of class TerminalFrame -class MyApp(wxApp): +class MyApp(wx.App): def OnInit(self): - wxInitAllImageHandlers() + wx.InitAllImageHandlers() frame_terminal = TerminalFrame(None, -1, "") self.SetTopWindow(frame_terminal) frame_terminal.Show(1) -- cgit v1.2.1