Skip to content

Commit

Permalink
hints for testing setTrayIcon (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
quintijn authored Sep 1, 2023
1 parent a3f427a commit dea86ad
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 3 deletions.
50 changes: 50 additions & 0 deletions pythonsrc/tests/test_setTrayIcon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
def testIcons(self):
r"""in the subdirectory icons of Unimacro there are 4 icons
These should show up when natlink.setTrayIcon('_repeat.ico', 'tooltip', func) is called,
but this is not working any more.
There are also predefined icons, which are now stored in defaulticons directory of unimacro (fork)
I don't know how to call these again...
It was tested in C:\DT\NatlinkDoug\pythonsrc\tests\unittestNatlink.py, this test could be taken out and put into
a pytest module!
**From natlink.txt**:
setTrayIcon( iconName, toolTip, callback )
This function, provided by Jonathan Epstein, will draw an icon in the
tray section of the tackbar.
Pass in the absolute path to a Windows icon file (.ico) or pass in one
of the following predefined names:
'right', 'right2', 'down', 'down2',
'left', 'left2', 'up', 'up2', 'nodir'
You can also pass in an empty string (or nothing) to remove the tray
icon.
The toolTip parameter is optional. It is the text which is displayed
as a tooltip when the mouse is over the tray icon. If missing, a generic
tooltip is used.
The callback parameter is optional. When used, it should be a Python
function which will be called when a mouse event occurs for the tray
icon. The function should take one parameters which is the type of
mouse event:
wm_lbuttondown, wm_lbuttonup, wm_lbuttondblclk, wm_rbuttondown,
wm_rbuttonup, wm_rbuttondblclk, wm_mbuttondown, wm_mbuttonup,
or wm_mbuttondblclk (all defined in natlinkutils)
Raises ValueError if the iconName is invalid.
The following functions are used in the natlinkmain base module. You
should only used these if you are control NatSpeak using the NatLink module
instead of using Python as a command and control subsystem for NatSpeak. In
the later case, users programs should probably not use either of these two
functions because they replace the callback used by the natlinkmain module
which could prevent proper module (re)loading and user changes.
"""
natlink.setTrayIcon('_repeat.ico')
natlink.setTrayIcon('_down') # ????

6 changes: 3 additions & 3 deletions pythonsrc/tests/unittestNatlink.py
Original file line number Diff line number Diff line change
Expand Up @@ -2833,9 +2833,9 @@ def checkExperiment(self,sawBegin,recogType,words,start,end):

#---------------------------------------------------------------------------
# Testing the tray icon is hard since we can not conviently interact with
# the UI from this test script. But I test what I can.
# the UI from this test script. But I test what I can.

def tttestTrayIcon(self):
def testTrayIcon(self):
self.log("testTrayIcon")

testForException =self.doTestForException
Expand All @@ -2858,7 +2858,7 @@ def tttestTrayIcon(self):
iconFile = baseDirectory+'/../NatlinkSource/idi_nodir.ico'
## special test icon, assume baseDirectory is on same level as PyTest:
## QH, cannot get baseDirectory correct...
import natlinkmain
# import natlinkmain
baseDirectory = natlinkmain.baseDirectory
iconFile = baseDirectory+'/../PyTest/unittest_icon.ico'
if not os.path.isfile(iconFile):
Expand Down

0 comments on commit dea86ad

Please sign in to comment.