انجمنهای فارسی اوبونتو
کمک و پشتیبانی => برنامهسازی => نویسنده: علی ۵۰۰ در 15 اردیبهشت 1396، 04:22 بظ
-
سلام
احتمالاً از برنامهٔ زیر خوشتان میآید. نظرتون چیه؟
(http://forum.ubuntu.ir/index.php?action=dlattach;topic=145917.0;attach=46830;image)
#!/usr/bin/env python3
import os
import time
import sys
os.system('clear')
rows, columns = os.popen('stty size', 'r').read().split()
yellow = True
for i in range(1, int(rows) + 1):
for j in reversed(range(1, int(columns))):
print("\033[{};{}H".format(i, j), end='')
if yellow == True:
print("\033[33m=", end='') # yellow
yellow = False
else:
print("\033[34m=", end='') # blue
yellow = True
print("\033[{};{}H".format(i, j - 1), end='')
sys.stdout.flush()
time.sleep(0.05)
print('\033[0m', end='')
print()
-
قشنگ بود علی جان, حتما سر فرصت سورسش را هم میخونم :)
-
قشنگ بود علی جان, حتما سر فرصت سورسش را هم میخونم :)
ممنون.
برای ساخت برنامهٔ بالا از منابع زیر هم کمک گرفتم:
http://stackoverflow.com/questions/18937058/clear-screen-in-shell
http://stackoverflow.com/questions/566746/how-to-get-linux-console-window-width-in-python/14422538
http://stackoverflow.com/questions/287871/print-in-terminal-with-colors-using-python
http://stackoverflow.com/questions/493386/how-to-print-without-newline-or-space
https://en.wikipedia.org/wiki/ANSI_escape_code
نکته: در برنامهٔ بالا، دستور زیر مهمه.
sys.stdout.flush()