Skip to content

Commit

Permalink
Merge branch 'release/v0.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim Maciejewski committed Oct 15, 2014
2 parents e926863 + 3609df8 commit 6a2a469
Show file tree
Hide file tree
Showing 8 changed files with 280 additions and 92 deletions.
Binary file added dsub.ico
Binary file not shown.
Binary file added dsub.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dsub_old.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions imgres.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 47 additions & 0 deletions inno_setup.iss
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "Serial Ports"
#define MyAppVersion "v0.0.3"
#define MyAppPublisher "Itsmagic Software"
#define MyAppURL "http://www.ornear.com/serial_ports"
#define MyAppExeName "serial_ports.exe"

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{B8AD6AFD-03D2-47DE-9245-A277A732EF8E}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}
OutputDir=C:\Users\jim.maciejewski\Documents\serial_ports\Output
OutputBaseFilename=serial_ports_v0.0.3_setup
SetupIconFile=C:\Users\jim.maciejewski\Documents\serial_ports\dist\serial_ports\dsub.ico
Compression=lzma
SolidCompression=yes

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
Source: "C:\Users\jim.maciejewski\Documents\serial_ports\dist\serial_ports\serial_ports.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\jim.maciejewski\Documents\serial_ports\dist\serial_ports\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

120 changes: 32 additions & 88 deletions serial_ports.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
"""Serial Port Finder"""
import wx
import sys
from PySide import QtGui
import time
import os
import serial
from threading import Thread
from pydispatch import dispatcher


class MonitorThread(Thread):

#----------------------------------------------------------------------
Expand All @@ -24,12 +23,11 @@ def run(self):
for item in self.serial_ports():
ports.append(item)
if ports != ports_old:
wx.CallAfter(self.updateStatus, ports)
self.updateStatus(ports)
ports_old = ports
time.sleep(5)


#----------------------------------------------------------------------
#----------------------------------------------------------------------
def serial_ports(self):
"""
Returns a generator for all available serial ports
Expand All @@ -51,65 +49,14 @@ def updateStatus(self, data):
"""
dispatcher.send(signal="PortChange", sender=data)

########################################################################

class MainFrame(wx.Frame):
""""""

#----------------------------------------------------------------------
def __init__(self):
"""Constructor"""
wx.Frame.__init__(self, None, id=wx.ID_ANY, title=wx.EmptyString,
pos=wx.DefaultPosition, size=wx.Size(110, 230), style=0)


self.SetSizeHintsSz(wx.DefaultSize, wx.DefaultSize)

bSizer8 = wx.BoxSizer(wx.VERTICAL)

self.m_panel3 = wx.Panel(self, wx.ID_ANY, wx.DefaultPosition,
wx.DefaultSize, wx.TAB_TRAVERSAL)
bSizer9 = wx.BoxSizer(wx.VERTICAL)

bSizer10 = wx.BoxSizer(wx.VERTICAL)

self.m_staticText5 = wx.StaticText(self.m_panel3, wx.ID_ANY,
u"Serial Ports", wx.DefaultPosition, wx.DefaultSize, 0)
self.m_staticText5.Wrap(-1)
bSizer10.Add(self.m_staticText5, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 5)


bSizer9.Add(bSizer10, 0, wx.EXPAND, 5)

bSizer11 = wx.BoxSizer(wx.VERTICAL)

self.m_staticline2 = wx.StaticLine(self.m_panel3, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL)
bSizer11.Add(self.m_staticline2, 0, wx.EXPAND |wx.ALL, 5)


bSizer9.Add(bSizer11, 0, wx.EXPAND, 5)

self.portSizer = wx.BoxSizer(wx.VERTICAL)


bSizer9.Add(self.portSizer, 1, wx.EXPAND, 5)


self.m_panel3.SetSizer(bSizer9)
self.m_panel3.Layout()
bSizer9.Fit(self.m_panel3)
bSizer8.Add(self.m_panel3, 1, wx.EXPAND |wx.ALL, 0)


self.SetSizer(bSizer8)
self.Layout()

self.Centre(wx.BOTH)
self.m_panel3.Bind(wx.EVT_LEFT_DOWN, self.on_left_click)
class SystemTrayIcon(QtGui.QSystemTrayIcon):


def __init__(self, icon, parent=None):
QtGui.QSystemTrayIcon.__init__(self, icon, parent)



self.port_list = []
self.gui_port_text = []

Expand All @@ -120,40 +67,35 @@ def __init__(self):
self.monitor = MonitorThread()
self.monitor.setDaemon(True)
self.monitor.start()
self.Show()
self.Fit()
self.setToolTip('None')
self.quitAction = QtGui.QAction("&Quit", self,
triggered=QtGui.qApp.quit)

self.trayIconMenu = QtGui.QMenu(parent)
self.trayIconMenu.addAction(self.quitAction)
self.setContextMenu(self.trayIconMenu)


#----------------------------------------------------------------------
def on_left_click(self, event):
"""left click"""
self.onClose(None)

def add_ports(self, sender):
""" add the ports to the gui """
self.port_list = []
for port in sender:
if port not in self.port_list:
self.port_list.append(port)
self.update_gui()



popup_text = ''
for item in self.port_list:
popup_text = popup_text + item + '\n'
self.setToolTip(popup_text)
self.showMessage('Port Change Detected', popup_text)


def update_gui(self):
for item in self.gui_port_text:
item.Destroy()
self.gui_port_text = []
for item in self.port_list:
staticText = wx.StaticText(self.m_panel3, wx.ID_ANY,
str(item), wx.DefaultPosition, wx.DefaultSize, 0)
staticText.Wrap(-1)
self.portSizer.Add(staticText, 0,
wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 5)
self.gui_port_text.append(staticText)
self.Layout()
self.Fit()
self.gui_port_text.append(item)
self.setToolTip(self.gui_port_text)


def onClose(self, evt):
Expand All @@ -162,15 +104,17 @@ def onClose(self, evt):
"""
#self.monitor.Exit()
self.Destroy()



#----------------------------------------------------------------------

def main():
""""""
app = wx.App(False)
frame = MainFrame()
app.MainLoop()

if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)

w = QtGui.QWidget()
trayIcon = SystemTrayIcon(QtGui.QIcon("dsub.png"), w)

trayIcon.show()
sys.exit(app.exec_())

if __name__ == '__main__':
main()
21 changes: 17 additions & 4 deletions serial_ports.spec
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,27 @@ a = Analysis(['serial_ports.py'],
hiddenimports=[],
hookspath=None,
runtime_hooks=None)
a.datas += [('dsub.png', 'dsub.png', 'DATA')]
a.datas += [('dsub.ico', 'dsub.ico', 'DATA')]

pyz = PYZ(a.pure)

exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
exclude_binaries=True,
name='serial_ports.exe',
debug=False,
strip=None,
upx=True,
console=False )
console=False,
icon='dsub.ico')


coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=None,
upx=True,
name='serial_ports')

Loading

0 comments on commit 6a2a469

Please sign in to comment.