Linked Questions
41 questions linked to/from How to get Linux console window width in Python
2
votes
0
answers
5k
views
Print dashes across full width of screen [duplicate]
I'm looking to print a dash "-" until the end of the user's screen.
Basically my program would print a line of text and then a line of dashes beneath it and then another line of text. This would be ...
-1
votes
1
answer
101
views
Formatting Strings in Python [duplicate]
I'm printing a title in python and I want it on the center of the screen.
I know I can do it by using
"{:^50}".format("Title")
But the thing with this command is it only utilizes the width I give in ...
0
votes
0
answers
103
views
Finding the width of the terminal? [duplicate]
I'm trying to find the width of the terminal window using python (3.8.2), so that I can store it in a variable. By doing this, I can centre text I display in the terminal, no matter the width of it. ...
440
votes
10
answers
277k
views
How do I find the width & height of a terminal window?
As a simple example, I want to write a CLI script which can print = across the entire width of the terminal window.
#!/usr/bin/env php
<?php
echo str_repeat('=', ???);
or
#!/usr/bin/env python
...
47
votes
5
answers
27k
views
Control formatting of the argparse help argument list?
import argparse
parser = argparse.ArgumentParser(prog='tool')
args = [('-u', '--upf', 'ref. upf', dict(required='True')),
('-s', '--skew', 'ref. skew', {}),
('-m', '--model', 'ref. ...
13
votes
4
answers
13k
views
Reading input from raw_input() without having the prompt overwritten by other threads in Python
I'm trying to let the user input commands at a console using raw_input(), this works fine. The problem is I have background threads that occasionally output log-information to the screen and when they ...
16
votes
1
answer
13k
views
What is termios.TIOCGWINSZ
I want to get the size of the terminal. I am using this functionality:
import sys, struct, fcntl, termios
s = struct.pack('HHHH', 0, 0, 0, 0)
t = fcntl.ioctl(sys.stdout.fileno(), termios.TIOCGWINSZ,...
11
votes
2
answers
11k
views
How to fill an entire line with * characters in Python [closed]
I want to fill an entire line in the screen with * characters and stop just before break line?
Something like this
********** MENU **********
Thanks
9
votes
5
answers
21k
views
Loop print through two lists to get two columns with fixed(custom set) space between the first letter of each element of each list
Suppose I have these two lists:
column1 = ["soft","pregnant","tall"]
column2 = ["skin","woman", "man"]
How do I loop print through these two lists while using a custom, fixed space(say 10, as in ...
4
votes
3
answers
6k
views
Allign left and right in python?
I've seen a question on justifying a 'print' right, but could I have text left and right on the same line, for a --help? It'd look like this in the terminal:
| ...
tkbx's user avatar
- 16.4k
6
votes
3
answers
3k
views
Linux Terminal Display and Python
I am writing a Python script to print out displayable user interface. The problem is every Linux user would have their own unique terminal size. This will cause the hard-coded user interface to go out ...
6
votes
2
answers
4k
views
Python Curses - module 'curses' has no attribute 'LINES'
I am looking at some source-code from a book and noticed that some of the code does not seem to be in the current Python2.7 API. The module curses is, according to this code, supposed to have a ...
1
vote
2
answers
9k
views
A long string is being truncated using print()
I tried the following code
s='Python is an interpreted high-level programming language for general-purpose programming. Created by Guido van Rossum and first released in 1991, Python has a design ...
4
votes
2
answers
2k
views
Python print - how to clear output before print end="\r"
Normally print ("{}".foo, end="\r") works well.
But the exception is when foo is long, and next time foo becomes short. The output becomes incorrect. Below is an example:
import time
print ("{}"....
1
vote
4
answers
2k
views
ASCII Characters Text Align
I'm coding a very small and basic text based adventure game in python, and I want to be able to align my title (which is in ASCII)
I've looked it up but I either didn't understand it or it didn't work....