Guest User

Untitled

a guest
Jun 23rd, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.42 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. import wx
  5. from datetime import date
  6.  
  7.  
  8. class MyFrame(wx.Frame):
  9.     def __init__(self, *args, **kwds):
  10.         kwds["style"] = wx.ICONIZE|wx.STAY_ON_TOP # remove stay on top if u want
  11.         wx.Frame.__init__(self, *args, **kwds)
  12.         self.panel_1 = wx.Panel(self, -1)
  13.         self.deys = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']
  14.         self.nfo = ''
  15.  
  16.         self.__set_properties()
  17.         self.__do_layout()
  18.        
  19.         self.panel_1.Bind(wx.EVT_LEFT_DOWN, self.upfresh, self.panel_1)
  20.         self.panel_1.Bind(wx.EVT_RIGHT_DOWN, self.kloz, self.panel_1)
  21.  
  22.     def __set_properties(self):
  23.         self.SetTitle("untitled")
  24.         self.SetSize((50, 5))
  25.         self.SetPosition((1220, 795)) # sidakah galhaala  =)
  26.         self.panel_1.SetBackgroundColour(wx.BLACK)
  27.         self.panel_1.SetToolTipString("this will change on refresh")
  28.         # tooltip holds reminders
  29.         self.refrush()
  30.  
  31.     def __do_layout(self):
  32.         sizer_1 = wx.BoxSizer(wx.VERTICAL)
  33.         sizer_1.Add(self.panel_1, 1, wx.EXPAND, 0)
  34.         self.SetSizer(sizer_1)
  35.         self.Layout()
  36.    
  37.     def refrush(self):
  38.         g = ''
  39.         pathk = "path/to/dayx.txt"
  40.         with open(pathk, "r") as f:
  41.             g = f.read()
  42.             f.close()
  43.         wde = "x"+self.deys[date.weekday(date.today())]
  44.         xx = g.find(wde[:3])
  45.         kt = g.count(wde[:3])/2
  46.         sey = ''
  47.         seyx = ''
  48.         if xx != -1: # if a match for today is found, do the extraction
  49.             for i in range(kt):
  50.                 a = g.find(wde[:3])+5
  51.                 b = g.find("/"+wde[:3])-1
  52.                 sey = sey+str(i+1)+": "+g[a:b]+"\n"
  53.                 g = g[(b+3):]
  54.             seyx = "you have "+str(kt)+" things to do today!\n"
  55.             self.nfo = seyx+sey[:-1]
  56.         else:
  57.             self.nfo = "you have no reminders for today"
  58.         self.panel_1.SetToolTipString(self.nfo)
  59.    
  60.     def kloz(self, event):
  61.         self.Close()
  62.         event.Skip()
  63.    
  64.     def upfresh(self, event):
  65.         self.refrush()
  66.         event.Skip()
  67.  
  68. # [mouse]right down will close it
  69. # [mouse]left down will refresh it
  70. # mouseover will show tooltip
  71.  
  72.  
  73. if __name__ == "__main__":
  74.     app = wx.PySimpleApp(0)
  75.     wx.InitAllImageHandlers()
  76.     frame_1 = MyFrame(None, -1, "")
  77.     app.SetTopWindow(frame_1)
  78.     frame_1.Show()
  79.     app.MainLoop()
Add Comment
Please, Sign In to add comment