Skip to content

added compatibility with windows in term of link to png #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions WAGO/Python/wago_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
# Feb 11, 2019 03:26:12 PM CET platform: Windows NT

import sys
import os

#store current path to find .png
currentPath = os.path.dirname(__file__)


try:
import Tkinter as tk
Expand Down Expand Up @@ -91,7 +96,7 @@ def __init__(self, top=None):
self.btnOutput1.configure(foreground="#000000")
self.btnOutput1.configure(highlightbackground="#d9d9d9")
self.btnOutput1.configure(highlightcolor="black")
self._img1 = tk.PhotoImage(file="./off_slider.png")
self._img1 = tk.PhotoImage(file=os.path.join(currentPath, 'off_slider.png'))
self.btnOutput1.configure(image=self._img1)
self.btnOutput1.configure(pady="0")
self.btnOutput1.configure(relief='sunken')
Expand All @@ -108,7 +113,7 @@ def __init__(self, top=None):
self.btnOutput2.configure(foreground="#000000")
self.btnOutput2.configure(highlightbackground="#d9d9d9")
self.btnOutput2.configure(highlightcolor="black")
self._img2 = tk.PhotoImage(file="./off_slider.png")
self._img2 = tk.PhotoImage(file=os.path.join(currentPath, 'off_slider.png'))
self.btnOutput2.configure(image=self._img2)
self.btnOutput2.configure(pady="0")
self.btnOutput2.configure(relief='sunken')
Expand All @@ -125,7 +130,7 @@ def __init__(self, top=None):
self.btnOutput3.configure(foreground="#000000")
self.btnOutput3.configure(highlightbackground="#d9d9d9")
self.btnOutput3.configure(highlightcolor="black")
self._img3 = tk.PhotoImage(file="./off_slider.png")
self._img3 = tk.PhotoImage(file=os.path.join(currentPath, 'off_slider.png'))
self.btnOutput3.configure(image=self._img3)
self.btnOutput3.configure(pady="0")
self.btnOutput3.configure(relief='sunken')
Expand All @@ -142,7 +147,7 @@ def __init__(self, top=None):
self.btnOutput4.configure(foreground="#000000")
self.btnOutput4.configure(highlightbackground="#d9d9d9")
self.btnOutput4.configure(highlightcolor="black")
self._img4 = tk.PhotoImage(file="./off_slider.png")
self._img4 = tk.PhotoImage(file=os.path.join(currentPath, 'off_slider.png'))
self.btnOutput4.configure(image=self._img4)
self.btnOutput4.configure(pady="0")
self.btnOutput4.configure(relief='sunken')
Expand All @@ -158,7 +163,7 @@ def __init__(self, top=None):
self.lblInput1.configure(foreground="#000000")
self.lblInput1.configure(highlightbackground="#d9d9d9")
self.lblInput1.configure(highlightcolor="black")
self._img5 = tk.PhotoImage(file="./off.png")
self._img5 = tk.PhotoImage(file=os.path.join(currentPath, 'off.png'))
self.lblInput1.configure(image=self._img5)
self.lblInput1.configure(text='''Label''')

Expand All @@ -172,7 +177,7 @@ def __init__(self, top=None):
self.lblInput2.configure(foreground="#000000")
self.lblInput2.configure(highlightbackground="#d9d9d9")
self.lblInput2.configure(highlightcolor="black")
self._img6 = tk.PhotoImage(file="./off.png")
self._img6 = tk.PhotoImage(file=os.path.join(currentPath, 'off.png'))
self.lblInput2.configure(image=self._img6)
self.lblInput2.configure(text='''Label''')

Expand All @@ -186,7 +191,7 @@ def __init__(self, top=None):
self.lblInput3.configure(foreground="#000000")
self.lblInput3.configure(highlightbackground="#d9d9d9")
self.lblInput3.configure(highlightcolor="black")
self._img7 = tk.PhotoImage(file="./off.png")
self._img7 = tk.PhotoImage(file=os.path.join(currentPath, 'off.png'))
self.lblInput3.configure(image=self._img7)
self.lblInput3.configure(text='''Label''')

Expand All @@ -200,7 +205,7 @@ def __init__(self, top=None):
self.lblInput4.configure(foreground="#000000")
self.lblInput4.configure(highlightbackground="#d9d9d9")
self.lblInput4.configure(highlightcolor="black")
self._img8 = tk.PhotoImage(file="./off.png")
self._img8 = tk.PhotoImage(file=os.path.join(currentPath, 'off.png'))
self.lblInput4.configure(image=self._img8)
self.lblInput4.configure(text='''Label''')

Expand All @@ -215,7 +220,7 @@ def __init__(self, top=None):
self.Button1.configure(foreground="#000000")
self.Button1.configure(highlightbackground="#d9d9d9")
self.Button1.configure(highlightcolor="black")
self._img9 = tk.PhotoImage(file="./exit.png")
self._img9 = tk.PhotoImage(file=os.path.join(currentPath, 'exit.png'))
self.Button1.configure(image=self._img9)
self.Button1.configure(pady="0")
self.Button1.configure(relief='sunken')
Expand Down Expand Up @@ -618,7 +623,7 @@ def __init__(self, top=None):
self.LOGO.configure(foreground="#000000")
self.LOGO.configure(highlightbackground="#f0f0f0")
self.LOGO.configure(highlightcolor="#646464")
self._img10 = tk.PhotoImage(file="./LOGO.png")
self._img10 = tk.PhotoImage(file=os.path.join(currentPath, 'LOGO.png'))
self.LOGO.configure(image=self._img10)

if __name__ == '__main__':
Expand Down
26 changes: 16 additions & 10 deletions WAGO/Python/wago_1_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
from pymodbus.client.sync import ModbusTcpClient
import datetime

import os

#store current path to find .png
currentPath = os.path.dirname(__file__)


try:
import Tkinter as tk
except ImportError:
Expand Down Expand Up @@ -54,35 +60,35 @@ def updateTemp(self):

result = client.read_coils(0,4)
if(result.bits[0]):
w._img5 = tk.PhotoImage(file="./on.png")
w._img5 = tk.PhotoImage(file=os.path.join(currentPath, 'on.png'))
w.lblInput1.configure(image=w._img5)

else:
w._img5 = tk.PhotoImage(file="./off.png")
w._img5 = tk.PhotoImage(file=os.path.join(currentPath, 'off.png'))
w.lblInput1.configure(image=w._img5)

if(result.bits[1]):
w._img6 = tk.PhotoImage(file="./on.png")
w._img6 = tk.PhotoImage(file=os.path.join(currentPath, 'on.png'))
w.lblInput2.configure(image=w._img6)

else:
w._img6 = tk.PhotoImage(file="./off.png")
w._img6 = tk.PhotoImage(file=os.path.join(currentPath, 'off.png'))
w.lblInput2.configure(image=w._img6)

if(result.bits[2]):
w._img7 = tk.PhotoImage(file="./on.png")
w._img7 = tk.PhotoImage(file=os.path.join(currentPath, 'on.png'))
w.lblInput3.configure(image=w._img7)

else:
w._img7 = tk.PhotoImage(file="./off.png")
w._img7 = tk.PhotoImage(file=os.path.join(currentPath, 'off.png'))
w.lblInput3.configure(image=w._img7)

if(result.bits[3]):
w._img8 = tk.PhotoImage(file="./on.png")
w._img8 = tk.PhotoImage(file=os.path.join(currentPath, 'on.png'))
w.lblInput4.configure(image=w._img8)

else:
w._img8 = tk.PhotoImage(file="./off.png")
w._img8 = tk.PhotoImage(file=os.path.join(currentPath, 'off.png'))
w.lblInput4.configure(image=w._img8)

root.after(100, self.updateTemp)
Expand Down Expand Up @@ -127,8 +133,8 @@ def init(top, gui, *args, **kwargs):
w = gui
top_level = top
root = top
w.image_on = tk.PhotoImage(file='on_slider.png')
w.image_off = tk.PhotoImage(file='off_slider.png')
w.image_on = tk.PhotoImage(file=os.path.join(currentPath, 'on_slider.png'))
w.image_off = tk.PhotoImage(file=os.path.join(currentPath, 'off_slider.png'))
w.images1 = it.cycle([w.image_off, w.image_on])
w.images2 = it.cycle([w.image_off, w.image_on])
w.images3 = it.cycle([w.image_off, w.image_on])
Expand Down