-2

when started "screen5-5.py it instantly starts with "blink_cer" script. and gives a error...

I have 2 Qs

1 how to start "def blink_cer(cer_name):" function WHEN i call it?

2 How to correct this "(cer_name).config(fg='yellow', bg='black')"?

error msg

Traceback (most recent call last):
  File "/home/pi/Desktop/screen5-5.py", line 239, in <module>
    sog_label.bind('<Button>', blink_cer(aws_cer))
  File "/home/pi/Desktop/screen5-5.py", line 33, in blink_cer
   (cer_name).config(fg='yellow', bg='black')
  File "/usr/lib/python3.5/tkinter/__init__.py", line 1342, in configure
   return self._configure('configure', cnf, kw)
  File "/usr/lib/python3.5/tkinter/__init__.py", line 1333, in _configure
   self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
  _tkinter.TclError: unknown option "-fg"

My code is like that:

import time

try:
    import Tkinter as tk
    from Tkinter import *
except ImportError:
    import tkinter as tk
    from tkinter import *

nmea_data = '$HCHDT,49.9,T'

def blink_cer(cer_name):
   (cer_name).config(fg='yellow', bg='black')
   print ("WHY?")

def tick(time1=''):
time2 = time.strftime('%M:%S')

....

root = Tk()
root.title("Screen GUI")

....

clock_cer = Frame(info01_frame, width=310, height=135)
clock_cer.pack_propagate(0)
clock_cer.pack(side = LEFT)
clock_label = Label(clock_cer, anchor="e", text='59:59', font=Font104, 
padx="10", pady="14", bg='black', fg='#e065ff')
clock_label.pack(fill=BOTH, expand=1)

----

tick()       

root.mainloop()
Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
G Flame
  • 27
  • 7
  • 1
    your tick function does not have a body, or at least no indentation which would allow parsing a body. please update the code to be a working and verifiable code snippet. – Minn Nov 29 '18 at 08:39

1 Answers1

0

Without knowing what you're trying to do with your program I'm not sure how to help you.

I managed to get your program working, I had to remove the Font and info01_frame to get it working but when I call blink_cer(clock_lable) the code runs printsWHY?` and turns the clock numbers yellow.

Answers:

1) You will start it with blink_cer(clock_label) <-- or whatever attribute you want to change.

2) I didn't receive this message, the program fired right up after removing some of those items.

import time

try:
    import Tkinter as tk
    from Tkinter import *
except ImportError:
    import tkinter as tk
    from tkinter import *

nmea_data = '$HCHDT,49.9,T'

def blink_cer(cer_name):
   (cer_name).config(fg='yellow', bg='black')
   print ("WHY?")

def tick(time1=''):
    time2 = time.strftime('%M:%S')

root = Tk()
root.title("Screen GUI")

clock_cer = Frame(width=310, height=135)
clock_cer.pack_propagate(0)
clock_cer.pack(side = LEFT)
clock_label = Label(clock_cer, anchor="e", text='59:59',
padx="10", pady="14", bg='black', fg='#e065ff')
clock_label.pack(fill=BOTH, expand=1)

tick() 
blink_cer(clock_label)      

root.mainloop()

Hope this helps!