I'm a newby with python programming and tought, to learn let me create a project. Here is what i'm trying to do. I want to create a program that runs in system tray and fire's a program that is loaded in the background. Loaded in the background so I can reduce the start time of Kivy. After searching here and on google, i could not find the answer.
I have two files
from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.uix.boxlayout import BoxLayout
from kivy.config import Config
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.core.window import Window
from kivy.config import Config
#
import kivy
from kivy.app import App
from kivy.uix.button import Button
from kivy.core.window import Window
Config.set('graphics', 'window_state', 'hidden')
class MyApp(App):
visible = False
def build(self):
Window.bordeless = 'True'
return Button(text='Hello World')
def on_start(self):
if self.visible:
self.root_window.hide()
self.visible = not self.visible
# self.root.focus = True
def do_show(self):
rootWindow = self.root_window
rootWindow.show()
print(self.root_window.focus)
if __name__ in ('__main__'):
ma = MyApp().run()
and
import wx
import someKivyThigy
from kivy.app import App
from someKivyThigy import MyApp
from buttonThing import MyDebugApp
from kivy.core.window import Window
TRAY_TOOLTIP = 'System Tray Demo'
TRAY_ICON = 'icon.png'
testVar = MyApp
def create_menu_item(menu, label, func):
item = wx.MenuItem(menu, -1, label)
menu.Bind(wx.EVT_MENU, func, id=item.GetId())
menu.AppendItem(item)
return item
class TaskBarIcon(wx.TaskBarIcon):
def __init__(self):
super(TaskBarIcon, self).__init__()
self.set_icon(TRAY_ICON)
self.Bind(wx.EVT_TASKBAR_LEFT_DOWN, self.on_left_down)
def CreatePopupMenu(self):
menu = wx.Menu()
create_menu_item(menu, 'Say Hello', self.on_hello)
menu.AppendSeparator()
create_menu_item(menu, 'Exit', self.on_exit)
return menu
def set_icon(self, path):
icon = wx.IconFromBitmap(wx.Bitmap(path))
self.SetIcon(icon, TRAY_TOOLTIP)
def on_left_down(self, event):
print 'Tray icon was left-clicked.'
MyApp().do_show()
def on_hello(self, event):
print 'Hello, world!'
def on_exit(self, event):
wx.CallAfter(self.Destroy)
def main():
app = wx.PySimpleApp()
TaskBarIcon()
testVar = MyApp().run()
app.MainLoop()
if __name__ == '__main__':
main()
When i left click the system tray icon, i get the error: "AttributeError: 'NoneType' object has no attribute 'show'". What am I doing wrong?