Bonjour,

Pour une question de lisibilité, je souhaite intégrer un sous-menu à "MENU 1" et "MENU 2", mais je ne sais pas comment m'y prendre, si quelqu'un peut m'aider !

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# -*- coding: cp1252 -*-
import os.path
import sys
import wx
 
class MyTaskBarIcon(wx.TaskBarIcon):
	TBMENU_MENU1 = wx.NewId()
	TBMENU_MENU2 = wx.NewId()
 
	def __init__(self, frame):
		wx.TaskBarIcon.__init__(self)
		self.frame = frame
		icon = wx.Icon('py.ico', wx.BITMAP_TYPE_ICO)
		self.SetIcon(icon, "Privosquid")
		self.Bind(wx.EVT_MENU, self.MONMENU1, id = self.TBMENU_MENU1)
		self.Bind(wx.EVT_MENU, self.MONMENU2, id = self.TBMENU_MENU2)
		self.menu = wx.Menu()
		self.menu.AppendCheckItem(self.TBMENU_MENU1, "MENU UN")
		self.menu.AppendSeparator()
		self.menu.AppendCheckItem(self.TBMENU_MENU2, "MENU DEUX")
		self.menu.AppendSeparator()
 
	def CreatePopupMenu(self):
		self.PopupMenu(self.menu)
 
	def MONMENU1(self, event):
            print "menu 1"
 
	def MONMENU2(self, event):
            print "menu 2"
 
class MyFrame(wx.Frame):
	def __init__(self, parent, title):
		wx.Frame.__init__(self, parent, -1, title, size = (1, 1), \
			style = wx.FRAME_NO_TASKBAR | wx.ALIGN_CENTRE)
		self.Bind(wx.EVT_CLOSE, self.OnClose)
		self.tbIcon = MyTaskBarIcon(self)		
 
	def OnClose(self, event):
		self.tbIcon.Destroy()
		self.Destroy()
 
class MyApp(wx.App):
	def OnInit(self):
            try:
		self.SetAssertMode(wx.PYAPP_ASSERT_DIALOG)
		frame = MyFrame(None, "TEST")
		frame.Show()
	    except OSError:
                    sys.exit()
	    return True
 
def main(args):
    app = MyApp()
    app.MainLoop()
 
if __name__ == "__main__":
    try:
        main(sys.argv[1:])
    except OSError:
        sys.exit()