Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
First steps working in Pythonista for iPhone 11
-
I would like to make a clock that has the hours minutes seconds and underneath it it would have the month day year so the format would look like this
Hours: minutes: seconds
Month: day: year:00: 00: 00
MM/dd/yyyyThat way it would be in the code so that when you boot the program it would fetch the time you have on the pc clock and match the time zone also update the calendar from the pc calendar this is the code so far
import datetime import time def clock(): while True: print(datetime.datetime.now().strftime("%H:%M:%S"), end="\r") time.sleep(1) clock()
-
What pc? ;-)
F-strings make
strftime()
unnecessary.>>> from datetime import datetime >>> date = datetime(1992, 7, 4) >>> f'{date} was on a {date:%A}' '1992-07-04 00:00:00 was on a Saturday'
Your code does several things already. What does it not do that you need it to do?
from datetime import datetime from time import sleep from console import clear def clock(): while True: print(f"{datetime.now():%H:%M:%S\n%m/%d/%Y}") sleep(1) clear() clock()
-
I am on my phone :(
-
How would I change the format to make it
Mm/dd/yyyy
00:00:00 -
print(f"{datetime.now():%m/%d/%Y}\n00:00:00")
print(f"{datetime.now():%m/%d/%Y\n%H:%M:%S}")
-
Why does the bottom peice of code have a n infront of the h
-
Thanks for the help I really appreciate it
-
print("0\n1\n2\n3\n")
-
@scarlett said:
Why does the bottom peice of code have a n infront of the h
\n = carriage return = new line
-
Oh can I join these two pieces of code together to make them work together
Start of interactive chat boximport ui def button_tapped(sender): sender.title = 'Hello' view = ui.View() view.name = 'Demo' view.background_color = 'white' button = ui.Button(title='Tap me!') button.center = (view.width * .5, view.height * .5) button.flex = 'LRTB' button.action = button_tapped view.add_subview(button) view.present('sheet') from datetime import datetime from time import sleep from console import clear def clock(): while True: print(f"{datetime.now():%m/%d/%Y\n%H:%M:%S}") sleep(1) clear() clock()
-
@scarlett said:
while True: print(f"{datetime.now():%m/%d/%Y\n%H:%M:%S}") sleep(1) clear()
Is an infinite loop! Do you really want it?
-
@cvp not an infinite loop
-
@scarlett you ever go outside your while True, you should need a break
-
When you run your script, even if you close the view, by the x, you will see that it's still run...
It stops only when your press this button
-
@cvp I will have a better idea if I have a example of what yku are talking about if I could see the code
-
@scarlett but I use your code, some posts above where you present your view/button and you start the clock().
When you close the view by its top/left x, you see the console where your timer goes on.
Until you really stop the script by the x in the Pythonista menu, not the same x. -
@cvp there is that and right now the stuff is acting screwy and what not I will try again later
-
So I figured out the program basement that I want to build I just needed working assets in order to do it
The program is built as follows
When you log in the main face of the Ui will look like this
[
Time
H: M: S:Date
Dd/mm/yyyyLogin:
User name:
Pasword:
Log in button
]
When log in button is pressed it time stamps the entrance into the server and starts a running timer as to how long you and the user you are chatting with are in the chat roomUse example below to insert code into proper places
Code goes Between the brackets
template for the programming is as follows
[
user code is as follows belowcopy as template for user B
User A: logged in as username:
User A: logged in with pasword:
User A logged in with password and user name of password and username @(h:m:s)dd/mm/yyyy)
[
[
[
[User A connected with user B @ (h:m:s)(dd/mm/yyyy)User A&B logged in @(m:h:s)(mm/dd/yyyy)
UserA total time stamp= log in time stamp + msg time stamp= total time online for user A
User B : message time stamp + log in time stamp= total time online for user B
Total time for user A+ total time for user B= total time of users in the chat room
active chat ends depending on time between messages sent
UserA: msg time stamp -userB message time stamp = time Afk or rather x# of hours idle
Boot both users off server if user(A)and user (B) are afk for more than x# of hours Donot delete conversation
If user A and user B are booted for afk save conversation to server and refetch at next login if same users connect
User A log in and user B log in= fetch last conversation
Last conversation = fetch tag
userA last log out time stamp + user B last log out time stamp= total time on server
fetch tag= last total time on line of user A and User B
Fetch tag = git conversation of last total time on server of user a + user B
find() time stamp