prettify UI a it further
authormilaq <micha.laqua@gmail.com>
Sun, 25 May 2014 21:56:14 +0000 (23:56 +0200)
committerTamber Penketh <tamber@furryhelix.co.uk>
Wed, 6 Jun 2018 22:49:23 +0000 (23:49 +0100)
 * connect/disconnect buttons in statuspage
 * revise spacing and strings
 * keep tab layout conform with each other

pyobd

diff --git a/pyobd b/pyobd
index e263e8a..98cbdf2 100755 (executable)
--- a/pyobd
+++ b/pyobd
@@ -155,7 +155,7 @@ class MyApp(wx.App):
             if self.port.State==0: #cant connect, exit thread
               self.stop()
               wx.PostEvent(self._notify_window, StatusEvent([666])) #signal apl, that communication was disconnected
-              wx.PostEvent(self._notify_window, StatusEvent([0,1,"Error cant connect..."]))
+              wx.PostEvent(self._notify_window, StatusEvent([0,1,"Could not connect to device"]))
               return None
 
             wx.PostEvent(self._notify_window, StatusEvent([0,1,"Connected"]))
@@ -226,9 +226,9 @@ class MyApp(wx.App):
 
         def stop(self):
             if self.port != None: #if stop is called before any connection port is not defined (and not connected )
-              self.port.close()
+                self.port.close()
             wx.PostEvent(self._notify_window, StatusEvent([0,1,"Disconnected"]))
-            wx.PostEvent(self._notify_window, StatusEvent([2,1,"----"]))
+            wx.PostEvent(self._notify_window, StatusEvent([2,1,"---"]))
 
   #class producer end
 
@@ -240,6 +240,8 @@ class MyApp(wx.App):
         self.dtcmenu.Enable(ID_CLEAR,True)
         self.GetDTCButton.Enable(True)
         self.ClearDTCButton.Enable(True)
+        self.connectButton.Enable(False)
+        self.disconnectButton.Enable(True)
 
         def sensor_toggle(e):
             sel = e.m_itemIndex
@@ -264,9 +266,45 @@ class MyApp(wx.App):
         self.settingmenu.Enable(ID_RESET,True)
         self.GetDTCButton.Enable(False)
         self.ClearDTCButton.Enable(False)
+        self.connectButton.Enable(True)
+        self.disconnectButton.Enable(False)
+
         #http://pyserial.sourceforge.net/                                                    empty function
         #EVT_LIST_ITEM_ACTIVATED(self.sensors,self.sensor_id, lambda : None)
 
+    def build_status_page(self):
+        HOFFSET_LIST=35 #offset from the top of panel (space for buttons)
+        tID = wx.NewId()
+        self.devpanel = wx.Panel(self.nb, -1)
+        self.connectButton  = wx.Button(self.devpanel,-1 ,"Connect" , wx.Point(0,0))
+        self.disconnectButton = wx.Button(self.devpanel,-1,"Disconnect", wx.Point(85,0))
+
+        #bind functions to button click action
+        self.devpanel.Bind(wx.EVT_BUTTON,self.OpenPort,self.connectButton)
+        self.devpanel.Bind(wx.EVT_BUTTON,self.OnDisconnect,self.disconnectButton)
+
+        self.status = self.MyListCtrl(self.devpanel, tID, pos=wx.Point(0,HOFFSET_LIST),
+                          style=wx.LC_REPORT|wx.SUNKEN_BORDER|wx.LC_HRULES|wx.LC_SINGLE_SEL)
+
+        self.status.InsertColumn(0, "Description",width=100)
+        self.status.InsertColumn(1, "Value")
+        self.status.Append(["Link State","Disconnected"]);
+        self.status.Append(["Protocol","---"]);
+        self.status.Append(["Cable version","---"]);
+        self.status.Append(["Device",self.COMPORT]);
+        ####################################################################
+        # This little bit of magic keeps the list the same size as the frame
+        def OnPSize(e, win = self.devpanel):
+            self.devpanel.SetSize(e.GetSize())
+            self.status.SetSize(e.GetSize())
+            w,h = self.frame.GetClientSizeTuple()
+            self.status.SetDimensions(0, HOFFSET_LIST, w-4, h-HOFFSET_LIST-33)
+
+        self.devpanel.Bind(wx.EVT_SIZE,OnPSize)
+        ####################################################################
+
+        self.nb.AddPage(self.devpanel, "Status")
+
     def build_sensor_page(self):
         HOFFSET_LIST=0
         tID = wx.NewId()
@@ -282,7 +320,7 @@ class MyApp(wx.App):
 
 
         self.sensors.InsertColumn(0, "Supported",width=70)
-        self.sensors.InsertColumn(1, "Sensor",format=wx.LIST_FORMAT_RIGHT, width=250)
+        self.sensors.InsertColumn(1, "Sensor (doubleclick a row to enable)",format=wx.LIST_FORMAT_RIGHT, width=250)
         self.sensors.InsertColumn(2, "Value")
         for i in range(0, len(obd_io.obd_sensors.SENSORS)):
             s = obd_io.obd_sensors.SENSORS[i].name
@@ -296,7 +334,7 @@ class MyApp(wx.App):
             panel.SetSize(e.GetSize())
             self.sensors.SetSize(e.GetSize())
             w,h = self.frame.GetClientSizeTuple()
-            self.sensors.SetDimensions(0,HOFFSET_LIST, w-10 , h - 35 )
+            self.sensors.SetDimensions(0, HOFFSET_LIST, w-4, h-HOFFSET_LIST-33)
 
         panel.Bind(wx.EVT_SIZE,OnPSize)
         ####################################################################
@@ -304,11 +342,11 @@ class MyApp(wx.App):
         self.nb.AddPage(panel, "Sensors")
 
     def build_DTC_page(self):
-        HOFFSET_LIST=30 #offset from the top of panel (space for buttons)
+        HOFFSET_LIST=35 #offset from the top of panel (space for buttons)
         tID = wx.NewId()
         self.DTCpanel = wx.Panel(self.nb, -1)
-        self.GetDTCButton  = wx.Button(self.DTCpanel,-1 ,"Get DTC" , wx.Point(15,0))
-        self.ClearDTCButton = wx.Button(self.DTCpanel,-1,"Clear DTC", wx.Point(100,0))
+        self.GetDTCButton  = wx.Button(self.DTCpanel,-1 ,"Get DTC" , wx.Point(0,0))
+        self.ClearDTCButton = wx.Button(self.DTCpanel,-1,"Clear DTC", wx.Point(85,0))
 
         #bind functions to button click action
         self.DTCpanel.Bind(wx.EVT_BUTTON,self.GetDTC,self.GetDTCButton)
@@ -326,8 +364,7 @@ class MyApp(wx.App):
             self.DTCpanel.SetSize(e.GetSize())
             self.dtc.SetSize(e.GetSize())
             w,h = self.frame.GetClientSizeTuple()
-            # I have no idea where 70 comes from
-            self.dtc.SetDimensions(0,HOFFSET_LIST, w-16 , h - 70 )
+            self.dtc.SetDimensions(0, HOFFSET_LIST, w-4, h-HOFFSET_LIST-33)
 
         self.DTCpanel.Bind(wx.EVT_SIZE,OnPSize)
         ####################################################################
@@ -377,15 +414,7 @@ class MyApp(wx.App):
         # Main notebook frames
         self.nb = wx.Notebook(frame, -1, style = wx.NB_TOP)
 
-        self.status = self.MyListCtrl(self.nb, tID,style=wx.LC_REPORT|wx.SUNKEN_BORDER)
-        self.status.InsertColumn(0, "Description",width=100)
-        self.status.InsertColumn(1, "Value")
-        self.status.Append(["Link State","Disconnected"]);
-        self.status.Append(["Protocol","---"]);
-        self.status.Append(["Cable version","---"]);
-        self.status.Append(["Device",self.COMPORT]);
-
-        self.nb.AddPage(self.status, "Status")
+        self.build_status_page()
 
         self.OBDTests = self.MyListCtrl(self.nb, tID,style=wx.LC_REPORT|wx.SUNKEN_BORDER)
         self.OBDTests.InsertColumn(0, "Description",width=200)