Separate map display issues
1. Added back the connection to callbacks for the whole window to enable all of the controls. (bizarre) 2. Fixed animation, which wouldn't work without a valid list of maps to display - regex anticipated the path to start with the `map` directory instead of the whole path from root.
This commit is contained in:
parent
157419e838
commit
c643f02e63
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="2.24"/>
|
<requires lib="gtk+" version="3.0"/>
|
||||||
<!-- interface-naming-policy project-wide -->
|
<!-- interface-naming-policy project-wide -->
|
||||||
<object class="GtkAdjustment" id="adjSpeed">
|
<object class="GtkAdjustment" id="adjSpeed">
|
||||||
<property name="lower">0.10000000000000001</property>
|
<property name="lower">0.10000000000000001</property>
|
||||||
@ -37,8 +37,8 @@
|
|||||||
<object class="GtkScrolledWindow" id="scrolledwindow1">
|
<object class="GtkScrolledWindow" id="scrolledwindow1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="hscrollbar_policy">automatic</property>
|
<!--property name="hscrollbar_policy">automatic</property-->
|
||||||
<property name="vscrollbar_policy">automatic</property>
|
<!--property name="vscrollbar_policy">automatic</property-->
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkViewport" id="viewport1">
|
<object class="GtkViewport" id="viewport1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
@ -172,7 +172,7 @@
|
|||||||
<property name="primary_icon_activatable">False</property>
|
<property name="primary_icon_activatable">False</property>
|
||||||
<property name="secondary_icon_activatable">False</property>
|
<property name="secondary_icon_activatable">False</property>
|
||||||
<property name="primary_icon_sensitive">True</property>
|
<property name="primary_icon_sensitive">True</property>
|
||||||
<property name="secondary_icon_sensitive">True</property>
|
<!--property name="secondary_icon_sensitive">True</property-->
|
||||||
<property name="adjustment">adjSpeed</property>
|
<property name="adjustment">adjSpeed</property>
|
||||||
<property name="digits">2</property>
|
<property name="digits">2</property>
|
||||||
<signal name="value-changed" handler="on_spnSpeed_value_changed" swapped="no"/>
|
<signal name="value-changed" handler="on_spnSpeed_value_changed" swapped="no"/>
|
||||||
|
36
nrsc5-dui.py
36
nrsc5-dui.py
@ -65,7 +65,7 @@ class NRSC5_DUI(object):
|
|||||||
else:
|
else:
|
||||||
# Linux/Mac/proper posix
|
# Linux/Mac/proper posix
|
||||||
# if nrsc5 and transcoder are not in the system path, set the full path here
|
# if nrsc5 and transcoder are not in the system path, set the full path here
|
||||||
self.nrsc5Path = "nrsc5"
|
self.nrsc5Path = "/usr/local/bin/nrsc5"
|
||||||
|
|
||||||
self.debugLog("OS Determination: Windows = {}".format(self.windowsOS))
|
self.debugLog("OS Determination: Windows = {}".format(self.windowsOS))
|
||||||
|
|
||||||
@ -726,7 +726,7 @@ class NRSC5_DUI(object):
|
|||||||
# restart nrsc5 if it crashes
|
# restart nrsc5 if it crashes
|
||||||
self.debugLog("Restarting NRSC5")
|
self.debugLog("Restarting NRSC5")
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
self.nrsc5 = Popen(self.nrsc5Args, stdin=PIPE, stderr=PIPE, stdout=PIPE, universal_newlines=True)
|
self.nrsc5 = Popen(self.nrsc5Args, shell=False, stdin=self.nrsc5slave, stdout=PIPE, stderr=PIPE, universal_newlines=True)
|
||||||
|
|
||||||
def set_synchronization(self, state):
|
def set_synchronization(self, state):
|
||||||
self.imgNoSynch.set_visible(state == 0)
|
self.imgNoSynch.set_visible(state == 0)
|
||||||
@ -1009,10 +1009,12 @@ class NRSC5_DUI(object):
|
|||||||
def proccessWeatherMaps(self):
|
def proccessWeatherMaps(self):
|
||||||
global mapDir
|
global mapDir
|
||||||
numberOfMaps = 0
|
numberOfMaps = 0
|
||||||
r = re.compile("^map.WeatherMap_([a-zA-Z0-9]+)_([0-9]+).png")
|
#r = re.compile("^map.WeatherMap_([a-zA-Z0-9]+)_([0-9]+).png")
|
||||||
|
r = re.compile("^.*map.WeatherMap_([a-zA-Z0-9]+)_([0-9]+).png")
|
||||||
now = dtToTs(datetime.datetime.now(tz.tzutc())) # get current time
|
now = dtToTs(datetime.datetime.now(tz.tzutc())) # get current time
|
||||||
files = glob.glob(os.path.join(mapDir, "WeatherMap_") + "*.png") # look for weather map files
|
files = glob.glob(os.path.join(mapDir, "WeatherMap_") + "*.png") # look for weather map files
|
||||||
files.sort() # sort files
|
files.sort() # sort files
|
||||||
|
#print(files)
|
||||||
for f in files:
|
for f in files:
|
||||||
m = r.match(f) # match regex
|
m = r.match(f) # match regex
|
||||||
if (m):
|
if (m):
|
||||||
@ -1022,7 +1024,8 @@ class NRSC5_DUI(object):
|
|||||||
# remove weather maps older than 12 hours
|
# remove weather maps older than 12 hours
|
||||||
if (now - ts > 60*60*12):
|
if (now - ts > 60*60*12):
|
||||||
try:
|
try:
|
||||||
if (f in self.weatherMaps): self.weatherMaps.pop(self.weatherMaps.index(f)) # remove from list
|
if (f in self.weatherMaps):
|
||||||
|
self.weatherMaps.pop(self.weatherMaps.index(f)) # remove from list
|
||||||
os.remove(f) # remove file
|
os.remove(f) # remove file
|
||||||
self.debugLog("Deleted old weather map: " + f)
|
self.debugLog("Deleted old weather map: " + f)
|
||||||
except:
|
except:
|
||||||
@ -1030,7 +1033,8 @@ class NRSC5_DUI(object):
|
|||||||
|
|
||||||
# skip if not the correct location
|
# skip if not the correct location
|
||||||
elif (id == self.mapData["weatherID"]):
|
elif (id == self.mapData["weatherID"]):
|
||||||
if (f not in self.weatherMaps): self.weatherMaps.append(f) # add to list
|
if (f not in self.weatherMaps):
|
||||||
|
self.weatherMaps.append(f) # add to list
|
||||||
numberOfMaps += 1
|
numberOfMaps += 1
|
||||||
|
|
||||||
|
|
||||||
@ -1536,6 +1540,7 @@ class NRSC5_Map(object):
|
|||||||
# setup gui
|
# setup gui
|
||||||
builder = Gtk.Builder()
|
builder = Gtk.Builder()
|
||||||
builder.add_from_file(os.path.join(resDir,"mapForm.glade"))
|
builder.add_from_file(os.path.join(resDir,"mapForm.glade"))
|
||||||
|
builder.connect_signals(self)
|
||||||
|
|
||||||
self.parent = parent # parent class
|
self.parent = parent # parent class
|
||||||
self.callback = callback # callback function
|
self.callback = callback # callback function
|
||||||
@ -1562,8 +1567,10 @@ class NRSC5_Map(object):
|
|||||||
self.config = data["viewerConfig"] # get the map viewer config
|
self.config = data["viewerConfig"] # get the map viewer config
|
||||||
self.mapWindow.resize(*self.config["windowSize"]) # set the window size
|
self.mapWindow.resize(*self.config["windowSize"]) # set the window size
|
||||||
self.mapWindow.move(*self.config["windowPos"]) # set the window position
|
self.mapWindow.move(*self.config["windowPos"]) # set the window position
|
||||||
if (self.config["mode"] == 0): self.radMapTraffic.set_active(True) # set the map radio buttons
|
if (self.config["mode"] == 0):
|
||||||
elif (self.config["mode"] == 1): self.radMapWeather.set_active(True)
|
self.radMapTraffic.set_active(True) # set the map radio buttons
|
||||||
|
elif (self.config["mode"] == 1):
|
||||||
|
self.radMapWeather.set_active(True)
|
||||||
self.setMap(self.config["mode"]) # display the current map
|
self.setMap(self.config["mode"]) # display the current map
|
||||||
|
|
||||||
self.chkAnimate.set_active(self.config["animate"]) # set the animation mode
|
self.chkAnimate.set_active(self.config["animate"]) # set the animation mode
|
||||||
@ -1615,7 +1622,7 @@ class NRSC5_Map(object):
|
|||||||
self.config["scale"] = btn.get_active()
|
self.config["scale"] = btn.get_active()
|
||||||
if (self.config["mode"] == 1):
|
if (self.config["mode"] == 1):
|
||||||
if (self.config["animate"]):
|
if (self.config["animate"]):
|
||||||
i = len(self.weatherMaps)-1 if (self.mapIndex-1<0) else self.mapIndex-1 # get the index for the current map in the animation
|
i = len(self.weatherMaps)-1 if (self.mapIndex-1 < 0) else self.mapIndex-1 # get the index for the current map in the animation
|
||||||
self.showImage(self.weatherMaps[i], self.config["scale"]) # show the current map in the animation
|
self.showImage(self.weatherMaps[i], self.config["scale"]) # show the current map in the animation
|
||||||
else:
|
else:
|
||||||
self.showImage(self.data["weatherNow"], self.config["scale"]) # show the most recent map
|
self.showImage(self.data["weatherNow"], self.config["scale"]) # show the most recent map
|
||||||
@ -1670,8 +1677,10 @@ class NRSC5_Map(object):
|
|||||||
|
|
||||||
def showImage(self, fileName, scale):
|
def showImage(self, fileName, scale):
|
||||||
if (os.path.isfile(fileName)):
|
if (os.path.isfile(fileName)):
|
||||||
if (scale): mapImg = Image.open(fileName).resize((600,600), Image.LANCZOS) # open and scale map to fit window
|
if (scale):
|
||||||
else: mapImg = Image.open(fileName) # open map
|
mapImg = Image.open(fileName).resize((600,600), Image.LANCZOS) # open and scale map to fit window
|
||||||
|
else:
|
||||||
|
mapImg = Image.open(fileName) # open map
|
||||||
|
|
||||||
self.imgMap.set_from_pixbuf(imgToPixbuf(mapImg)) # convert image to pixbuf and display
|
self.imgMap.set_from_pixbuf(imgToPixbuf(mapImg)) # convert image to pixbuf and display
|
||||||
else:
|
else:
|
||||||
@ -1679,8 +1688,11 @@ class NRSC5_Map(object):
|
|||||||
self.imgMap.set_from_stock(Gtk.STOCK_MISSING_IMAGE, Gtk.IconSize.LARGE_TOOLBAR) # display missing image if file is not found
|
self.imgMap.set_from_stock(Gtk.STOCK_MISSING_IMAGE, Gtk.IconSize.LARGE_TOOLBAR) # display missing image if file is not found
|
||||||
|
|
||||||
def setMap(self, map):
|
def setMap(self, map):
|
||||||
if (map == 0): self.showImage(os.path.join(mapDir, "TrafficMap.png"), False) # show traffic map
|
global mapDir
|
||||||
elif (map == 1):self.showImage(self.data["weatherNow"], self.config["scale"]) # show weather map
|
if (map == 0):
|
||||||
|
self.showImage(os.path.join(mapDir, "TrafficMap.png"), False) # show traffic map
|
||||||
|
elif (map == 1):
|
||||||
|
self.showImage(self.data["weatherNow"], self.config["scale"]) # show weather map
|
||||||
|
|
||||||
def updated(self, imageType):
|
def updated(self, imageType):
|
||||||
if (self.config["mode"] == 0):
|
if (self.config["mode"] == 0):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user