I search 2 features in wxPython

Hi,

let's go

first, *wx.TaskBarIcon*
I would like to add a menu when I right click on the icon, well I can do that but I don't understand the limits on this menu :
  I can't use the &
  I can't use wx.ITEM_CHECK
the & is not a big problem, but the ITEM_CHECK annoy me a lots :frowning:
is there some tips / workaround for the ITEM_CHEK ?

and to conclude *wx.ListCtrl*
Well, now I know how to use it :slight_smile:
The feature I search for this class is a way to use images / progress bar or more widget. I know that we can use an icon on the first column but we can't use 2, 3 or more icon in different column.
maybe using a wxFlexGridSizer and a ScrolledPanel ?

thx in advance for your help :slight_smile:
whaly

whaly wrote:

Hi,

let's go

first, *wx.TaskBarIcon*
I would like to add a menu when I right click on the icon, well I can do that but I don't understand the limits on this menu :
    I can't use the &
    I can't use wx.ITEM_CHECK
the & is not a big problem, but the ITEM_CHECK annoy me a lots :frowning:
is there some tips / workaround for the ITEM_CHEK ?

wx.ITEM_CHECK works fine here.

and to conclude *wx.ListCtrl*
Well, now I know how to use it :slight_smile:
The feature I search for this class is a way to use images / progress bar or more widget. I know that we can use an icon on the first column but we can't use 2, 3 or more icon in different column.
maybe using a wxFlexGridSizer and a ScrolledPanel ?

But then you wouldn't have a wx.ListCtrl, but gobs of individual controls... (blech!)

The only way to do it currently with wx.ListCtrl is to create child widgets for the icons or bars, and then on every size or scroll event reposition them with the item they are associated with, using GetItemRect to calculate the position. But it may be a bit choppy as things are moved a bit out of sync with the actual change in the listctrl.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Robin Dunn wrote:

wx.ITEM_CHECK works fine here.

with a popup menu on the taskbar ?

well currently I am under windows xp sp1
with python 2.3.4 and wxPythonWIN32-3.5.2.7u-Py23
and here is the exemple (u must have a hw.ico file in the same dir as the script)

thx in advance

and here is the code :

import wx

···

# -----------------------------------------------------------------------------

class TaskBarApp(wx.Frame):
     def __init__(self, parent, id, title):
         wx.Frame.__init__(self, parent, -1, title, size = (1, 1),
             style=wx.FRAME_NO_TASKBAR|wx.NO_FULL_REPAINT_ON_RESIZE)
         self.tbicon = wx.TaskBarIcon()
         icon = wx.Icon('hw.ico', wx.BITMAP_TYPE_ICO)
         self.tbicon.SetIcon(icon, '')
         self.tbicon.Bind(wx.EVT_TASKBAR_RIGHT_UP, self.OnTaskBarMenu)

         # create the NewId()
         self.TBMENU_1 = wx.NewId()
         self.TBMENU_2 = wx.NewId()
         self.TBMENU_QUIT = wx.NewId()

         # make THE menu
         self.menu = wx.Menu()
         self.menu.Append(self.TBMENU_1, "&Hello")
         self.menu.Append(self.TBMENU_2, "World", kind=wx.ITEM_CHECK)
         self.menu.AppendSeparator()
         self.menu.Append(self.TBMENU_QUIT, "&Quit")

         # bind the Event
         self.tbicon.Bind(wx.EVT_MENU, self.OnQuit, id=self.TBMENU_QUIT)

         # ---------------------------------------------------------------------
         self.Show(True)

     # -------------------------------------------------------------------------
     def OnTaskBarMenu(self, evt):
         self.tbicon.PopupMenu(self.menu)

     # -------------------------------------------------------------------------
     def OnQuit(self, evt):
         self.Close(True)
         wx.GetApp().ProcessIdle()

# -----------------------------------------------------------------------------

class MyApp(wx.App):
     def OnInit(self):
         frame = TaskBarApp(None, -1, ' ')
         frame.Center(wx.BOTH)
         frame.Show(False)
         return True

# -----------------------------------------------------------------------------

def main():
     app = MyApp(0)
     app.MainLoop()

# -----------------------------------------------------------------------------

if __name__ == '__main__':
     main()

whaly wrote:

Robin Dunn wrote:

wx.ITEM_CHECK works fine here.

with a popup menu on the taskbar ?

Yes, but I had only checked that self.menu.Check worked. This may be a general problem with popup menus on MSW (not just with wx.TaskbarIcon). Please enter a bug report about it.

In the meantime you can work around it by managing the check state yourself.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!