~toolpart/+junk/pythoncard

« back to all changes in this revision

Viewing changes to tests/runTimeTest.py

  • Committer: Bazaar Package Importer
  • Author(s): Mohammed Adnène Trojette
  • Date: 2006-11-12 17:52:13 UTC
  • mfrom: (2.1.5 feisty)
  • Revision ID: james.westby@ubuntu.com-20061112175213-tv8bnl6rtpa2qw1o
Tags: 0.8.1-8.1
* Non-maintainer upload.
* Fix path to findfiles, codeEditor and resourceEditor:
   + patch from Ernest ter Kuile <ernestjw@xs4all.nl>. (Closes: #397018)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""
 
2
__version__ = "$Revision: 1.1 $"
 
3
__date__ = "$Date: 2004/05/25 19:47:08 $"
 
4
"""
 
5
 
 
6
import sys
 
7
from PythonCard import model
 
8
import threading
 
9
import wx
 
10
 
 
11
class Runtime( threading.Thread ) :
 
12
    
 
13
    def __init__( self, path, clazz ) :
 
14
        threading.Thread.__init__( self )
 
15
        sys.argv = [ path ]
 
16
        self._clazz = clazz
 
17
        self._running = False 
 
18
        self.start()
 
19
        
 
20
    def run( self ) :
 
21
       self._app = model.Application( self._clazz )
 
22
       self._running = True
 
23
       self._app.MainLoop()
 
24
       
 
25
    def getApplication( self ) :
 
26
        while not self._running :
 
27
            pass
 
28
        return self._app
 
29
 
 
30
class User( object ) :
 
31
 
 
32
    def __init__( self, window ) :
 
33
        """
 
34
        Create a test proxy to a PythonCard window.
 
35
        """
 
36
        self._window = window 
 
37
        
 
38
    def click( self, path ) :
 
39
        """
 
40
        Generate a mouse down event for the button
 
41
        identified by 'path'.          
 
42
        Path example: myPanel.myButton
 
43
        """
 
44
        button = self._window.getComponent( path )
 
45
        event = wx.CommandEvent( wx.wxEVT_COMMAND_BUTTON_CLICKED, button.GetId() )
 
46
        wx.PostEvent( button, event )
 
47
        
 
48
    def type( self, path, text ) :
 
49
        """
 
50
        Type the 'text', character by character, into
 
51
        the TextField or TextArea identified by 'path'
 
52
        Path example: myPanel.myField
 
53
        """
 
54
        field = self._window.getComponent( path )
 
55
        field.SetValue( text )
 
56
        #event = wx.CommandEvent( wx.wxEVT_COMMAND_TEXT_ENTER, field.GetId() )
 
57
        #wx.PostEvent( field, event )
 
58
        
 
59
    def select( self, path, value ) :
 
60
        """
 
61
        Set the selected value of the component
 
62
        identified by path to 'value'.  This method
 
63
        can be used for popop menus, and single selection lists.
 
64
        Path example: myPanel.myMenu
 
65
        """
 
66
        pass
 
67
 
 
68