You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ff/helloWorld.py

187 lines
6.7 KiB
Python

import glob
import wx
import wx.lib.buttons as buttons
import numpy as np
import pandas as pd
BG_IMG = 'icon.png'
COLUMN_NAMES = np.flip(['Server name', 'Port number', 'Status', 'Source IP', 'Destination IP', 'Source port number', 'Destination port number', 'Number of requests made since flag', 'Date', 'Process Name', 'Address hostname', 'Refresh rate'])
TEST_FILE = pd.read_csv('out.csv', )
TEST_FILE = TEST_FILE.iloc[1:, :]
TEST_FILE.columns = ['Server name', 'Port number', 'Status', 'Source IP', 'Destination IP', 'Source port']
print(TEST_FILE)
print(len(TEST_FILE))
print(TEST_FILE.iloc[1, 1])
class OtherFrame(wx.Frame):
"""
Class used for creating frames other than the main one
"""
def __init__(self):
wx.Frame.__init__(self, None, -1, 'Server Panel', size=(600, 250))
panel = ServerPanel(self)
self.Show()
def on_edit(self, event):
print('in on_edit')
def update_mp3_listing(self, folder_path):
print(folder_path)
def on_window(self, event):
return
class HelpFrame(wx.Frame):
"""
Class used for creating frames other than the main one
"""
def __init__(self):
wx.Frame.__init__(self, None, -1, 'Help', size=(600, 250))
panel = HelpPanel(self)
self.Show()
# Panel with all the login widgets
class LoginPanel(wx.Panel):
def __init__(self, parent):
super(LoginPanel, self).__init__(parent)
self.SetBackgroundColour((44, 51, 51))
basicLabel = wx.StaticText(self, -1, "Username")
basicLabel.SetForegroundColour((255,255,255))
basicText = wx.TextCtrl(self, -1, "", size=(175, -1))
# basicText.SetInsertionPoint(0)
pwdLabel = wx.StaticText(self, -1, "Password")
pwdText = wx.TextCtrl(self, -1, "", size=(175, -1), style=wx.TE_PASSWORD)
pwdLabel.SetForegroundColour((255, 255, 255))
vbox = wx.BoxSizer(wx.VERTICAL)
hbox = wx.BoxSizer(wx.HORIZONTAL)
vbox.Add(basicLabel, 0, wx.ALIGN_CENTER | 100, 5)
vbox.Add(basicText, 0, wx.ALIGN_CENTER | 100, 5)
vbox.Add(pwdLabel, 0, wx.ALIGN_CENTER | 100, 5)
vbox.Add(pwdText, 0, wx.ALIGN_CENTER | 100, 5)
login_button = wx.Button(self, label='Login')
login_button.Bind(wx.EVT_BUTTON, self.on_login)
help_button = wx.Button(self, label='Help')
help_button.Bind(wx.EVT_BUTTON, self.on_help)
# signup_button = wx.Button(self, label='Sign Up')
hbox.Add(login_button, 0, wx.ALL | 200, 20)
# hbox.Add(signup_button, 0, wx.ALL | 200, 20)
hbox.Add(help_button, 0, wx.ALL | 200, 20)
vbox.Add(hbox, 0, wx.ALIGN_CENTER | 100, 5)
self.SetSizer(vbox)
def on_login(self, event):
OtherFrame()
def on_help(self, event):
HelpFrame()
# Panel with all the login widgets
class HelpPanel(wx.Panel):
def __init__(self, parent):
super(HelpPanel, self).__init__(parent)
self.SetBackgroundColour((44, 51, 51))
# basicLabel = wx.StaticText(self, -1, "Username")
# basicLabel.SetForegroundColour((255,255,255))
# basicText = wx.TextCtrl(self, -1, "", size=(175, -1))
#
# # basicText.SetInsertionPoint(0)
# pwdLabel = wx.StaticText(self, -1, "Password")
# pwdText = wx.TextCtrl(self, -1, "", size=(175, -1), style=wx.TE_PASSWORD)
# pwdLabel.SetForegroundColour((255, 255, 255))
# vbox = wx.BoxSizer(wx.VERTICAL)
# hbox = wx.BoxSizer(wx.HORIZONTAL)
# vbox.Add(basicLabel, 0, wx.ALIGN_CENTER | 100, 5)
# vbox.Add(basicText, 0, wx.ALIGN_CENTER | 100, 5)
# vbox.Add(pwdLabel, 0, wx.ALIGN_CENTER | 100, 5)
# vbox.Add(pwdText, 0, wx.ALIGN_CENTER | 100, 5)
# login_button = wx.Button(self, label='Login')
# login_button.Bind(wx.EVT_BUTTON, self.on_login)
# help_button = wx.Button(self, label='Help')
# # signup_button = wx.Button(self, label='Sign Up')
# hbox.Add(login_button, 0, wx.ALL | 200, 20)
# # hbox.Add(signup_button, 0, wx.ALL | 200, 20)
# hbox.Add(help_button, 0, wx.ALL | 200, 20)
# vbox.Add(hbox, 0, wx.ALIGN_CENTER | 100, 5)
# self.SetSizer(vbox)
class ServerPanel(wx.Panel):
def __init__(self, parent):
super().__init__(parent, size=(500, 500))
self.SetBackgroundColour((44, 51, 51))
# self.toolbar = self.CreateToolBar()
# tb = wx.ToolBar(self, -1)
main_sizer = wx.BoxSizer(wx.VERTICAL)
secondary_sizer = wx.BoxSizer(wx.HORIZONTAL)
self.row_obj_dict = {}
self.list_ctrl = wx.ListCtrl(
self, size=(-1, 75),
style=wx.LC_REPORT | wx.BORDER_SUNKEN
)
# self.pnl1.SetBackgroundColour(wx.BLACK)
self.handle_columns()
for i in range(len(TEST_FILE)):
self.list_ctrl.InsertItem(i, TEST_FILE.iloc[i, 0])
for j in range(1, 5):
self.list_ctrl.SetItem(i, j, TEST_FILE.iloc[i, j])
main_sizer.Add(self.list_ctrl, 0, wx.ALL | wx.EXPAND, 20)
start_button = wx.Button(self, label='Start')
start_button.SetBackgroundColour((205, 215, 206))
start_button.Bind(wx.EVT_BUTTON, self.on_edit)
start_button.Bind(wx.EVT_ENTER_WINDOW, self.on_edit)
stop_button = wx.Button(self, label='Stop')
stop_button.SetBackgroundColour('#F08080')
secondary_frame_button = wx.Button(self, label='Window')
secondary_frame_button.Bind(wx.EVT_BUTTON, self.on_window)
# wx.BORDER(stop_button, wx.BORDER_NONE)
stop_button.Bind(wx.EVT_BUTTON, self.on_edit)
main_sizer.Add(start_button, 0, wx.CENTER | wx.ALL | 100, 5)
main_sizer.Add(stop_button, 0, wx.CENTER | 100, 5)
main_sizer.Add(secondary_frame_button, 0, wx.CENTER | 100, 5)
self.SetSizer(main_sizer)
def handle_columns(self):
for col in COLUMN_NAMES:
self.list_ctrl.InsertColumn(0, col, width=200)
def on_edit(self, event):
print('in on_edit')
def update_mp3_listing(self, folder_path):
print(folder_path)
def on_window(self, event):
OtherFrame()
def ShowImage(self, imageFile):
if imageFile == "":
self.bitmap = wx.StaticBitmap(self, -1, size=(0, 0))
else:
bmp = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
self.bitmap = wx.StaticBitmap(self, -1, bmp, (0, 0))
class ServerFrame(wx.Frame):
def __init__(self):
super().__init__(parent=None,
title='Server Dashboard')
self.panel = LoginPanel(self)
# image = wx.StaticBitmap(self, wx.ID_ANY)
# image.SetBitmap(wx.Bitmap('WXPython.png'))
self.Show()
if __name__ == '__main__':
app = wx.App(False)
frame = ServerFrame()
app.MainLoop()