System Tray Icon

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • flaper87
    New Member
    • Dec 2006
    • 1

    System Tray Icon

    Hi everybody!!!!

    I am developing an aplication, and i want it to stay on the system tray, i found out how to put the icon, but i can minimize it there, What do i have to do?, I'm using python(of course).

    and this is the code:

    Code:
    # -*- coding: iso-8859-1 -*-
    # Don't modify comment 
    
    import wx
    import VwXComponent
    ID_MENU_5 = 5
    #[inc]add your include files here
    import ingresar
    import os.path
    import time
    import datetime
    import locale
    import days
    import string
    import sys
    #[inc]end your include
    
    class MyFrame(wx.Frame):
        def __init__(self,parent,id = -1,title='',pos = wx.Point(1,1),size = wx.Size(685,525),style = wx.DEFAULT_FRAME_STYLE,name = 'frame'):
            pre=wx.PreFrame()
            self.OnPreCreate()
            pre.Create(parent,id,title,pos,size,style,name)
            self.PostCreate(pre)
            self.initBefore()
            self.VwXinit()
            self.initAfter()
    
        def __del__(self):
            self.Ddel()
            return
    
    
        def VwXinit(self):
            self.fileImgBuf=[None] * 1
            self.fileImgBuf[0] = wx.Bitmap("libe.ico",wx.BITMAP_TYPE_ICO)
            self.taskbarImg4=self.fileImgBuf[0];
            self.SetIcon(wx.Icon("libe.ico",wx.BITMAP_TYPE_ICO));
            self.SetTitle('Femme')
            self.Show(True)
            self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_MENU))
            self.menubar= wx.MenuBar()
            self.archivo = wx.Menu()
            self.menubar.Append(self.archivo,"Archivos")
            self.ayuda = wx.Menu()
            self.menubar.Append(self.ayuda,"Ayuda")
            itemmenu = wx.MenuItem(self.archivo,ID_MENU_5,"Ingresar","",0)
            self.archivo.AppendItem(itemmenu)
            self.SetMenuBar(self.menubar)
            self.Bind(wx.EVT_MENU,self.mb_ingresar,id=ID_MENU_5)
            self.st3c = wx.StaticText(self,-1,"",wx.Point(10,38),wx.Size(274,18),wx.ST_NO_AUTORESIZE)
            self.st3c.SetLabel("Fecha de llegada de la menstruacion:")
            self.st3c.SetFont(wx.Font(10,74,90,92,0,"Verdana"))
            self.st3c.SetForegroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOWTEXT))
            self.lb_init_pas = wx.StaticText(self,-1,"",wx.Point(317,40),wx.Size(114,18),wx.ST_NO_AUTORESIZE)
            self.lb_init_pas.SetFont(wx.Font(11,74,90,90,0,"Tahoma"))
            self.lnv5c = wx.StaticLine(self,-1,wx.Point(0,320),wx.Size(687,7),wx.LI_VERTICAL)
            self.lnv5c.SetForegroundColour(wx.Colour(255,0,255))
            self.lnv5c.SetBackgroundColour(wx.Colour(128,0,128))
            self.lnv6c = wx.StaticLine(self,-1,wx.Point(295,35),wx.Size(7,442),wx.LI_VERTICAL)
            self.lnv6c.SetBackgroundColour(wx.Colour(128,0,128))
            self.st3cC = wx.StaticText(self,-1,"",wx.Point(10,93),wx.Size(244,18),wx.ST_NO_AUTORESIZE)
            self.st3cC.SetLabel("Primer dia de ovulacion (Dia 12):")
            self.st3cC.SetFont(wx.Font(10,74,90,92,0,"Verdana"))
            self.st3cC.SetForegroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOWTEXT))
            self.lb_seg_ov = wx.StaticText(self,-1,"",wx.Point(317,95),wx.Size(114,18),wx.ST_NO_AUTORESIZE)
            self.lb_seg_ov.SetFont(wx.Font(11,74,90,90,0,"Tahoma"))
            self.lnv5cC = wx.StaticLine(self,-1,wx.Point(0,70),wx.Size(687,7),wx.LI_VERTICAL)
            self.lnv5cC.SetForegroundColour(wx.Colour(255,0,255))
            self.lnv5cC.SetBackgroundColour(wx.Colour(128,0,128))
            self.st3cCC = wx.StaticText(self,-1,"",wx.Point(15,153),wx.Size(254,18),wx.ST_NO_AUTORESIZE)
            self.st3cCC.SetLabel("Segundo dia de ovulacion (Dia 13):")
            self.st3cCC.SetFont(wx.Font(10,74,90,92,0,"Verdana"))
            self.st3cCC.SetForegroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOWTEXT))
            self.lb_ter_ov = wx.StaticText(self,-1,"",wx.Point(317,160),wx.Size(114,18),wx.ST_NO_AUTORESIZE)
            self.lb_ter_ov.SetFont(wx.Font(11,74,90,90,0,"Tahoma"))
            self.lnv5cCC = wx.StaticLine(self,-1,wx.Point(0,130),wx.Size(687,7),wx.LI_VERTICAL)
            self.lnv5cCC.SetForegroundColour(wx.Colour(255,0,255))
            self.lnv5cCC.SetBackgroundColour(wx.Colour(128,0,128))
            self.st3cCCC = wx.StaticText(self,-1,"",wx.Point(15,215),wx.Size(169,18),wx.ST_NO_AUTORESIZE)
            self.st3cCCC.SetLabel("Dia mas fertil (Dia 14):")
            self.st3cCCC.SetFont(wx.Font(10,74,90,92,0,"Verdana"))
            self.st3cCCC.SetForegroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOWTEXT))
            self.lb_cuar_ov = wx.StaticText(self,-1,"",wx.Point(317,215),wx.Size(114,18),wx.ST_NO_AUTORESIZE)
            self.lb_cuar_ov.SetFont(wx.Font(11,74,90,90,0,"Tahoma"))
            self.lnv5cCCC = wx.StaticLine(self,-1,wx.Point(0,195),wx.Size(687,7),wx.LI_VERTICAL)
            self.lnv5cCCC.SetForegroundColour(wx.Colour(255,0,255))
            self.lnv5cCCC.SetBackgroundColour(wx.Colour(128,0,128))
            self.st3cCCCC = wx.StaticText(self,-1,"",wx.Point(15,285),wx.Size(254,18),wx.ST_NO_AUTORESIZE)
            self.st3cCCCC.SetLabel("Cuarto dia de ovulacion (Dia 15):")
            self.st3cCCCC.SetFont(wx.Font(10,74,90,92,0,"Verdana"))
            self.st3cCCCC.SetForegroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOWTEXT))
            self.lb_quin_ov = wx.StaticText(self,-1,"",wx.Point(317,290),wx.Size(114,18),wx.ST_NO_AUTORESIZE)
            self.lb_quin_ov.SetFont(wx.Font(11,74,90,90,0,"Tahoma"))
            self.lnv5cCCCC = wx.StaticLine(self,-1,wx.Point(0,255),wx.Size(687,7),wx.LI_VERTICAL)
            self.lnv5cCCCC.SetForegroundColour(wx.Colour(255,0,255))
            self.lnv5cCCCC.SetBackgroundColour(wx.Colour(128,0,128))
            self.st3cCCCCC = wx.StaticText(self,-1,"",wx.Point(15,350),wx.Size(254,18),wx.ST_NO_AUTORESIZE)
            self.st3cCCCCC.SetLabel("Quinto dia de ovulacion (Dia 16):")
            self.st3cCCCCC.SetFont(wx.Font(10,74,90,92,0,"Verdana"))
            self.st3cCCCCC.SetForegroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOWTEXT))
            self.lb_sext_ov = wx.StaticText(self,-1,"",wx.Point(317,350),wx.Size(114,18),wx.ST_NO_AUTORESIZE)
            self.lb_sext_ov.SetFont(wx.Font(11,74,90,90,0,"Tahoma"))
            self.taskbar = VwXComponent.VwXtaskBar(self)
            self.Bind(wx.EVT_TASKBAR_LEFT_DCLICK,self.taskbar_VwXEvOnTaskBarLeftDClick)
            self.taskbar.SetIcon(wx.Icon("libe.ico",wx.BITMAP_TYPE_ICO),"Femme")
            self.Refresh()
            return
        def VwXDelComp(self):
            if(self.taskbar != None): self.taskbar.Destroy(); self.taskbar = None
            return
    
    #[win]add your code here
    
        def taskbar_VwXEvOnTaskBarLeftDClick(self,event): #init function
            #[550]Code event VwX...Don't modify[550]#
            #add your code here
            frame = MyFrame(self)
            frame.Show(True)
            return #end function
    
        def mb_ingresar(self,event): #init function
            #[671]Code menu VwX...Don't modify[671]#
            #add your code here
            frm = ingresar.ingresar(self)
            frm.Show()
            return #end function
    
    
        def OnPreCreate(self):
            #add your code here
    
            return
    
        def initBefore(self):
            #add your code here
    
            return
    
        def initAfter(self):
            #add your code here
            self.Centre() 
            self.Show()
            self.read()
            #self.asignar()
            return
    
        def Ddel(self): #init function
            #[ f9]Code VwX...Don't modify[ f9]#
            #add your code here
    
            return #end function
        
        def asignar(self):
            
            self.lb_init_pas.SetLabel(content[0])        
            self.lb_seg_ov.SetLabel(content[1])
            self.lb_ter_ov.SetLabel(content[2])
            self.lb_cuar_ov.SetLabel(content[3])
            self.lb_quin_ov.SetLabel(content[4])
            self.lb_sext_ov.SetLabel(content[5])       
        
        def read(self):
            today = datetime.date.today()
            past = str(days.get_date(today.year, today.month-1, today.day)).split("-")
            
            if os.path.isfile(str(today.year) + "/" + str(today.month) + "-1" + ".data"):
                f = open(str(today.year) + "/" + str(today.month) + "-1" + ".data", "r")
                content = f.read()
                content = content.split("\n")
                self.lb_init_pas.SetLabel(content[0])        
                self.lb_seg_ov.SetLabel(content[1])
                self.lb_ter_ov.SetLabel(content[2])
                self.lb_cuar_ov.SetLabel(content[3])
                self.lb_quin_ov.SetLabel(content[4])
                self.lb_sext_ov.SetLabel(content[5])         
                f.close()
            
            elif os.path.isfile(str(today.year) + "/" + str(today.month) + ".data"):
                f = open(str(today.year) + "/" + str(today.month) + ".data", "r")
                content = f.read()
                content = content.split("\n")
                self.lb_init_pas.SetLabel(content[0])        
                self.lb_seg_ov.SetLabel(content[1])
                self.lb_ter_ov.SetLabel(content[2])
                self.lb_cuar_ov.SetLabel(content[3])
                self.lb_quin_ov.SetLabel(content[4])
                self.lb_sext_ov.SetLabel(content[5])         
                f.close()
                
            elif os.path.isfile(str(today.year) + "/" + past[1] + ".data"):
                f = open(str(today.year) + "/" + past[1] + ".data", "r")
                content = f.read()
                content = content.split("\n")
                self.lb_init_pas.SetLabel(content[0])        
                self.lb_seg_ov.SetLabel(content[1])
                self.lb_ter_ov.SetLabel(content[2])
                self.lb_cuar_ov.SetLabel(content[3])
                self.lb_quin_ov.SetLabel(content[4])
                self.lb_sext_ov.SetLabel(content[5])         
                f.close()
            return
    
    #[win]end your code
  • bartonc
    Recognized Expert Expert
    • Sep 2006
    • 6478

    #2
    What should we do first, guys? Give him the system tray thing or a lesson on refactoring?

    Comment

    • bartonc
      Recognized Expert Expert
      • Sep 2006
      • 6478

      #3
      flaper87, was this code generated by some GUI builder?
      Can you point out the system tray parts for us?
      Thanks.

      Comment

      Working...