1 ## import all of the wxPython GUI package 
   2 from wxPython
.wx 
import * 
   5 I am trying to write a routine which will produce an entryform which I can 
   6 later use to write GUI entryforms for databasis work.  When you run this 
   7 program and chose option 150 (Invoer) under "L=EAers" the following error 
   8 appears (repeated 6 times): 
  10 Gtk-CRITICAL **: file gtkwidget.c: line 1592 (gtk_widget_map): assertion 
  11 `GTK_WIDGET_VISIBLE (widget) == TRUE' failed.=20 
  14 class ToetsInvoer(wxPanel
): 
  15     def __init__(self
, parent
): 
  16         wxPanel
.__init
__(self
, parent
, -1) 
  18         wxStaticText(self
, -1, "wxTextCtrl", wxPoint(5, 25), wxSize(75, 20)) 
  19         wxTextCtrl(self
, 10, "", wxPoint(80, 25), wxSize(150, 20)) 
  20         EVT_TEXT(self
, 10, self
.EvtText
) 
  22         wxStaticText(self
, -1, "Passsword", wxPoint(5, 50), wxSize(75, 20)) 
  23         wxTextCtrl(self
, 20, "", wxPoint(80, 50), wxSize(150, 20), wxTE_PASSWORD
) 
  24         EVT_TEXT(self
, 20, self
.EvtText
) 
  26         wxStaticText(self
, -1, "Multi-line", wxPoint(5, 75), wxSize(75, 20)) 
  27         wxTextCtrl(self
, 30, "", wxPoint(80, 75), wxSize(200, 150), wxTE_MULTILINE
) 
  28         EVT_TEXT(self
, 30, self
.EvtText
) 
  32     def EvtText(self
, event
): 
  33         self
.log
.WriteText('EvtText: %s\n' % event
.GetString()) 
  35 #--------------------------------------------------------------------------- 
  37 ## Create a new frame class, derived from the wxPython Frame. 
  38 class HoofRaam(wxFrame
): 
  40     def __init__(self
, pa
, id, titel
): 
  41         # First, call the base class' __init__ method to create the frame 
  42         wxFrame
.__init
__(self
, pa
, id, titel
,wxPyDefaultPosition
, 
  45         self
.CreateStatusBar(2) 
  46         mainmenu 
= wxMenuBar() 
  48         menu
.Append(100, '&Kopieer', 'Maak rugsteun') 
  49         menu
.Append(101, '&Nuwe stel', 'Begin nuwe databasis') 
  50         menu
.Append(150, '&Invoer', 'Toets invoervorm') 
  51         menu
.AppendSeparator() 
  52         menu
.Append(200, 'Kl&aar', 'Gaan uit die program uit!') 
  53         mainmenu
.Append(menu
, "&L=EAers") 
  54         self
.SetMenuBar(mainmenu
) 
  55 #         if wxPlatform == '__WXMSW__': 
  56 #             print menu.GetHelpString(100) 
  57 #             print mainmenu.GetHelpString(101) 
  58 #             print mainmenu.GetHelpString(200) 
  59 #             self.DragAcceptFiles(true) 
  63         # Associate some events with methods of this class 
  64         self
.Connect(-1, -1, wxEVT_SIZE
, self
.OnSize
) 
  65         self
.Connect(-1, -1, wxEVT_MOVE
, self
.OnMove
) 
  66         self
.Connect(-1, -1, wxEVT_COMMAND_MENU_SELECTED
, self
.OnMenuCommand
) 
  67         self
.Connect(-1, -1, wxEVT_DROP_FILES
, self
.OnDropFiles
) 
  70         #self.child = ToetsInvoer(self) 
  72     # This method is called automatically when the CLOSE event is 
  74     def OnCloseWindow(self
, event
): 
  75         # tell the window to kill itself 
  79     # This method is called by the System when the window is resized, 
  80     # because of the association above. 
  81     def OnSize(self
, event
): 
  82         size 
= event
.GetSize() 
  83         print "grootte:", size
.width
, size
.height
 
  86     # This method is called by the System when the window is moved, 
  87     # because of the association above. 
  88     def OnMove(self
, event
): 
  89         pos 
= event
.GetPosition() 
  90         print "pos:", pos
.x
, pos
.y
 
  92     def OnMenuCommand(self
, event
): 
  93         # why isn't this a wxMenuEvent??? 
  94         print event
, event
.GetInt() 
  95         if event
.GetInt() == 200: 
  97         if event
.GetInt() == 150: 
  99         if event
.GetInt() == 101: 
 100             print "Nommer 101 is gekies" 
 102     def OnDropFiles(self
, event
): #werk net in windows 
 103         fileList 
= event
.GetFiles() 
 104         for file in fileList
: 
 107     def OnCloseWindow(self
, event
): 
 111 #--------------------------------------------------------------------------- 
 113 # Every wxWindows application must have a class derived from wxApp 
 116     # wxWindows calls this method to initialize the application 
 119         # Create an instance of our customized Frame class 
 120         raam 
= HoofRaam(NULL
, -1, "Taalunie") 
 123         # Tell wxWindows that this is our main window 
 124         self
.SetTopWindow(raam
) 
 126         # Return a success flag 
 129 #--------------------------------------------------------------------------- 
 132 app 
= MyProg(0)     # Create an instance of the application class 
 133 app
.MainLoop()     # Tell it to start processing events