There is a program like chat. About 5 users. The exchange of information is not constant, that is, they write as necessary and there may be large temporary breaks. I want to make it so that after someone wrote a message, it was possible to attract the attention of other users who are running the program. Sound without options (no speakers). Ideally, it would be flashing the program on the panel. The program will work on windows server 2008 r2. In Google I can not find anything applicable to Python (I have 3.4). This is my first program.
# -*- coding: utf-8 -*- import tkinter from tkinter import * from tkinter import messagebox as mb import time name = str() fname = str(time.strftime("%d_%m_%Y")) def messange(): global mdname if entry.get() < '0': mb.showerror('ΠΡΠΈΠ±ΠΊΠ°', 'ΠΡ Π½Π΅ Π½Π°ΠΏΠΈΡΠ°Π»ΠΈ ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΠ΅, ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΠ΅ Π½Π΅ Π΄ΠΎΠ»ΠΆΠ½ΠΎ Π½Π°ΡΠΈΠ½Π°ΡΡΡΡ Ρ ΠΏΡΠΎΠ±Π΅Π»Π°') # ΠΡΠΈΠ±ΠΊΠ° else: mess = entry.get() entry.delete(0, END) f = open(fname + '.txt', 'a') f.write(time.strftime("%H:%M") + ' ' + name + ' ΠΏΠΈΡΠ΅Ρ: ' + mess + '\n') f.close() def login(event): global name name = entry.get() if name < '0': mb.showerror('ΠΡΠΈΠ±ΠΊΠ°', 'ΠΠ°ΠΏΠΈΡΠΈΡΠ΅ Π²Π°ΡΠ΅ ΠΈΠΌΡ, ΠΈΠΌΡ Π½Π΅ Π΄ΠΎΠ»ΠΆΠ½ΠΎ Π½Π°ΡΠΈΠ½Π°ΡΡΡΡ Ρ ΠΏΡΠΎΠ±Π΅Π»Π°') # ΠΡΠΈΠ±ΠΊΠ° else: event.widget.pack_forget() # Π‘ΠΊΡΡΡΡ ΡΠΊΠ½ΠΎΠΏΠΊΡ name = entry.get() entry.delete(0, END) f = open(fname + '.txt', 'a') f.write('ΠΡΠΈΠ²Π΅Ρ ' + name + '\n') f.close() button_visible_false.pack() # ΠΡΠΎΠ±ΡΠ°Π·ΠΈΡΡ ΠΊΠ½ΠΎΠΏΠΊΡ while True: f = open(fname + '.txt') data = f.read() time.sleep(0.3) f.close() textbox.delete(1.0, END) textbox.insert(1.0, data) textbox.see("end") root.update_idletasks() root.update() root = Tk() root.title('ΠΠ°ΡΠΌΠΎΠ½ΠΈΡΠ½ΡΠΉ ΡΠ°Ρ v.1') panelFrame = Frame(root, height = 60, bg = 'green') textFrame = Frame(root, height = 340, width = 600) panelFrame.pack(side = 'top', fill = 'x') textFrame.pack(side = 'bottom', fill = 'both', expand = 1) textbox = Text(textFrame, font='Arial 10', wrap='word') scrollbar = Scrollbar(textFrame) scrollbar['command'] = textbox.yview textbox['yscrollcommand'] = scrollbar.set textbox.pack(side = 'left', fill = 'both', expand = 1) scrollbar.pack(side = 'right', fill = 'y') entry = Entry(width = 80) entry.pack(pady = 10) btn1 = Button(panelFrame, text='ΠΠ°ΠΏΠΈΡΠΈΡΠ΅ Π²Π°ΡΠ΅ ΠΈΠΌΡ', width=17, height=3, bg="white", fg="black") btn1.bind('<Button-1>', login) btn1.pack() button_visible_false = tkinter.Button(panelFrame, text='ΠΠ°ΠΏΠΈΡΠ°ΡΡ ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΠ΅', width=17, height=3, bg="white", fg="black", command = messange) try: f = open(fname + '.txt') except: f = open(fname + '.txt', 'w') else: pass root.mainloop()