Python Forum
Label.Place did not work?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Label.Place did not work?
#11
Okay, here my code is WORKED for me here:
from tkinter import *
import time
import curses

win = Tk()
win.attributes('-fullscreen', True)
win.configure(bg='black')
win.config(cursor="none")

T = StringVar()
S = StringVar()
G = StringVar()
C = StringVar()


fgc="yellow"
bgc="black"
T.set(time.strftime("%I %M"))

lab1=Label(win, textvariable=T, font=('DIGITAL DISMAY',600),fg=fgc, bg=bgc).place(x=130,y=100)
lab2=Label(win, textvariable=S, font=('DIGITAL DISMAY',60),fg=fgc, bg=bgc).place(x=1790,y=710)
lab3=Label(win, textvariable=G, font=('TICKING TIMEBOMB BB',60),fg=fgc, bg=bgc).place(x=1790,y=210)
lab4=Label(win, textvariable=C, font=('TICKING TIMEBOMB BB',900),fg=fgc, bg=bgc).place(x=800,y=10)

def presskey():
    win.bind('<Escape>', quit, win.config(cursor=''))

def update_clock():
    T.set(time.strftime("%I %M"))
    n=int(time.strftime("%S"))
    G.set(time.strftime("%P"))
    S.set(time.strftime("%S"))
    if n%2 == 0:
        C.set(":")
    else:
        C.set("")
    win.after(1,update_clock)
    return()


update_clock()
presskey()
time.sleep(1)
win.mainloop()
The font TTF is: https://www.1001fonts.com/digital-dismay-font.html
AND
https://www.1001fonts.com/ticking-timebomb-bb-font.html


If you think my code need change to better, please do so and show me, I can look at it and learn what's different. Thanks again!!!

Here what the screen looks like:
[Image: view?usp=sharing]
Reply
#12
just to comment on something that looks like misconception. return() on line 38 is redundant.

1. Functions by defualt (i.e. if they don't return explicitly) will return None
2. return is a statment, not a function (i.e. it looks like you think yon need to call it)
3. return() is just returning empty tuple. you don't care about returned value anyway.

def spam():
    pass

def eggs():
    return

def foo():
    return()


print(spam())
print(eggs())
print(foo())
print(type(foo()))
Output:
None None () <class 'tuple'>
I would suggest that you post the code in code review section if you want a feedback.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#13
Humm, I am not sure to understand how that's works.

Let me give you guys of my logical in my background:
I will understand very much how works if I get any completed examples, so I can change anything in the example to see what results and will learn quickly. For the tutor or youtube, etc will not help me much and headache.

For example, when I posted with the codes, anyone copies it and changes to the better and right way then back to my post then I will analyze it how it works and learn much which best for me.

Of Course, it will lot of time for changes the codes.

Thanks.
RAM


ps: I donated to this the server, Thanks again.
Reply
#14
I changed a bit:
from tkinter import *
import time, curses

win = Tk()
win.attributes('-fullscreen', True)
win.configure(bg='black')
win.config(cursor="none")

T = StringVar()
S = StringVar()
G = StringVar()
C = StringVar()
fgc="yellow"
bgc="black"


lab1=Label(win, textvariable=T, font=('DIGITAL DISMAY',600),fg=fgc, bg=bgc).place(x=130,y=100)
lab2=Label(win, textvariable=S, font=('DIGITAL DISMAY',60),fg=fgc, bg=bgc).place(x=1790,y=710)
lab3=Label(win, textvariable=G, font=('TICKING TIMEBOMB BB',60),fg=fgc, bg=bgc).place(x=1790,y=210)
lab4=Label(win, textvariable=C, font=('TICKING TIMEBOMB BB',900),fg=fgc, bg=bgc).place(x=800,y=10)

def presskey():
    win.bind('<Escape>', quit, win.config(cursor=''))
    return

def update_clock():
    T.set(time.strftime("%I %M"))
    n=int(time.strftime("%S"))
    G.set(time.strftime("%P"))
    S.set(time.strftime("%S"))
    if n%2 == 0:
        C.set(":")
    else:
        C.set("")
    win.after(1,update_clock)
    return
    
update_clock()
presskey()
win.mainloop()
But need change with textvariable ?
Reply
#15
why do you keep adding redundunt return?
why do you need presskey() function?. just keep line 23, not in function.

(Sep-18-2020, 03:05 PM)ATARI_LIVE Wrote: But need change with textvariable ?
I would definitely use more meaningful names. I would have combined some of them, but I guess it's how you like it (for display reasons)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#16
(Sep-18-2020, 03:25 PM)buran Wrote: why do you keep adding redundunt return?
Man, I removed both return

(Sep-18-2020, 03:25 PM)buran Wrote: why do you need presskey() function?. just keep line 23, not in function.
Alright, I removed the function and it's worked.

(Sep-18-2020, 03:25 PM)buran Wrote: I would definitely use more meaningful names. I would have combined some of them, but I guess it's how you like it (for display reasons)
OK, what I should change to in your prefer if you have?

UPDATED:
from tkinter import *
import time

win = Tk()
win.attributes('-fullscreen', True)
win.configure(bg='black')


T = StringVar()
S = StringVar()
G = StringVar()
C = StringVar()
fgc = "white"
bgc = "black"


lab1 = Label(win, textvariable=T, font=('DIGITAL DISMAY', 600), fg=fgc, bg=bgc).place(x=130, y=100)
lab2 = Label(win, textvariable=S, font=('DIGITAL DISMAY', 60), fg=fgc, bg=bgc).place(x=1790, y=710)
lab3 = Label(win, textvariable=G, font=('TICKING TIMEBOMB BB', 60), fg=fgc, bg=bgc).place(x=1790, y=210)
lab4 = Label(win, textvariable=C, font=('TICKING TIMEBOMB BB', 900), fg=fgc, bg=bgc).place(x=800, y=10)


def update_clock():
    T.set(time.strftime("%I %M"))
    n = int(time.strftime("%S"))
    G.set(time.strftime("%P"))
    S.set(time.strftime("%S"))
    if n%2 == 0:
        C.set(":")
    else:
        C.set("")
    win.after(1, update_clock)

win.bind('<Escape>', quit)
update_clock()
win.mainloop()

Do there have other way to turn off the mouse pointer?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to place global tk text widget in class or on canvas puje 1 512 Jul-04-2020, 09:25 AM
Last Post: deanhystad
  [Tkinter] How to place scroll bar correctly scratchmyhead 1 941 May-18-2020, 04:17 PM
Last Post: scratchmyhead
  How to use place holders in tkinter sqlite scratchmyhead 1 528 May-12-2020, 06:13 PM
Last Post: Larz60+
  thinker button gui place next to each other jacklee26 9 1,702 Jul-04-2019, 07:48 AM
Last Post: wuf

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020