hallo zusammen,
ich habe ein wenig in python experimentiert und mir viel dabei etwas auf wenn ich das gleiche in autoit umsetze. hier mal das python script:
Python
import tkinter as tk
from datetime import datetime
class ClockApp:
def __init__(self):
# Create main window
self.root = tk.Tk()
self.root.title("System Clock")
# Create and configure the time label
self.time_label = tk.Label(
self.root,
font=('Arial', 30, 'bold'),
bg='black',
fg='green'
)
self.time_label.pack(padx=20, pady=20)
# Start the clock
self.update_time()
def update_time(self):
# Get current time with milliseconds
now = datetime.now()
# Convert microseconds to milliseconds (divide by 1000) and limit to 3 digits
milliseconds = now.microsecond // 1000
time_str = f"{now.strftime('%H:%M:%S')}.{milliseconds:03d}"
self.time_label.config(text=time_str)
# Schedule next update (every 10ms for smooth millisecond updates)
self.root.after(10, self.update_time)
def run(self):
self.root.mainloop()
# Create and run the application
if __name__ == "__main__":
app = ClockApp()
app.run()
Alles anzeigen
und hier mal zum vergleich das selbe script in autoit:
C
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
; Define colors explicitly
Local $COLOR_BLACK = 0x000000
Local $COLOR_GREEN = 0x00FF00
; Create main window
$window = GUICreate("System Clock", 350, 150)
GUISetBkColor($COLOR_BLACK)
; Create label for time display
$label = GUICtrlCreateLabel("", 50, 40, 250, 60)
GUICtrlSetFont($label, 30, 800, 0, "Arial")
GUICtrlSetColor($label, $COLOR_GREEN)
; Show window
GUISetState(@SW_SHOW)
; Initialize counter
Local $counter = 0
; Main loop
While 1
; Increment counter (increases by 10 each iteration due to Sleep(10))
$counter += 10
; Get current time
$time = @HOUR & ":" & @MIN & ":" & @SEC
; Format milliseconds (will cycle through 000-990)
Local $milliseconds = Mod($counter, 1000)
$milliseconds = StringFormat("%03d", $milliseconds)
; Update label text
GUICtrlSetData($label, $time & "." & $milliseconds)
; Check for window close
If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop
; Sleep to prevent high CPU usage
Sleep(10)
WEnd
; Exit program
Exit
Alles anzeigen
meine frage ist jetzt folgende: in python laeuft alles fluessig und schoen. in auto it flackert das immer so. warum ist das so und kann man das flackern beheben?
gruss
bankesbusters