test modules

formac
Cole Deck 2 years ago
parent f415fe7a6d
commit b4aecb1974

@ -0,0 +1,137 @@
import glob
import wx
import wx.adv
import os
from time import sleep
from multiprocessing import Process, Pipe
from sys import platform
TRAY_TOOLTIP = 'IP Pigeon'
TRAY_ICON = 'icon.png'
"""if platform == "linux" or platform == "linux2":
# linux
elif platform == "darwin":
# OS X
elif platform == "win32":
# Windows...
"""
displaydata = None
settings = None
class ServerPanel(wx.Panel):
def __init__(self, parent):
super().__init__(parent)
main_sizer = wx.BoxSizer(wx.VERTICAL)
self.row_obj_dict = {}
self.list_ctrl = wx.ListCtrl(
self, size=(-1, 100),
style=wx.LC_REPORT | wx.BORDER_SUNKEN
)
self.list_ctrl.InsertColumn(0, 'Server name', width=140)
self.list_ctrl.InsertColumn(1, 'Port number', width=140)
self.list_ctrl.InsertColumn(2, 'Status', width=200)
main_sizer.Add(self.list_ctrl, 0, wx.ALL | wx.EXPAND, 5)
start_button = wx.Button(self, label='Start')
start_button.Bind(wx.EVT_BUTTON, self.on_edit)
stop_button = wx.Button(self, label='Stop')
stop_button.Bind(wx.EVT_BUTTON, self.on_edit)
main_sizer.Add(start_button, 0, wx.ALL | 100, 5)
main_sizer.Add(stop_button, 0, wx.ALL | 100, 5)
self.SetSizer(main_sizer)
def on_edit(self, event):
print('in on_edit')
def update_mp3_listing(self, folder_path):
print(folder_path)
class ServerFrame(wx.Frame):
def __init__(self):
super().__init__(parent=None,
title='Server Dashboard')
self.panel = ServerPanel(self)
self.Show()
### Taskbar Icon
def create_menu_item(menu, label, func):
item = wx.MenuItem(menu, -1, label)
menu.Bind(wx.EVT_MENU, func, id=item.GetId())
menu.Append(item)
return item
class TaskBarIcon(wx.adv.TaskBarIcon):
def __init__(self, frame):
self.frame = frame
super(TaskBarIcon, self).__init__()
self.set_icon(TRAY_ICON)
self.Bind(wx.adv.EVT_TASKBAR_LEFT_DOWN, self.on_left_down)
def CreatePopupMenu(self):
menu = wx.Menu()
create_menu_item(menu, 'Control Panel', self.on_open)
menu.AppendSeparator()
create_menu_item(menu, 'Exit', self.on_exit)
return menu
def set_icon(self, path):
icon = wx.Icon(path)
self.SetIcon(icon, TRAY_TOOLTIP)
def on_left_down(self, event):
print ('Tray icon was left-clicked.')
def on_open(self, event):
foreground()
#self.close_popup()
def on_exit(self, event):
wx.CallAfter(self.Destroy)
self.close_popup()
def close_popup(self):
self.frame.Close()
class TaskbarApp(wx.App):
def OnInit(self):
frame=wx.Frame(None)
self.SetTopWindow(frame)
TaskBarIcon(frame)
return True
class FullApp(wx.App):
def OnInit(self):
fullframe=ServerFrame()
return True
def background():
app = TaskbarApp(False)
with Manager() as manager:
displaydata = manager.list()
settings = manager.list()
"""rawdata = manager.list()
logdata = manager.list()
uploaddata = manager.list()
downloaddata = manager.list()"""
app.MainLoop()
def open_fg(outputdata, uisettings):
app = FullApp(False)
app.MainLoop()
def foreground():
# Open the foreground in a separate process so that UI acts independently of the taskbar icon
p = Process(target=open_fg, args=(displaydata, settings))
p.start()
#p.join()
print("Launched foreground")
if __name__ == '__main__':
background()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 28 KiB

@ -0,0 +1,14 @@
import core
if __name__ == '__main__':
# create manager to share data to me, background, foreground
# launch background app as process
# create worker pool
# launch main, non-blocking, loop
def mainloop():
# worker pool: netstat, netstat cleanup, upload, download, ui tasks
Loading…
Cancel
Save