Posts: 4,647
Threads: 1,494
Joined: Sep 2016
what screen size do coders here have? i have increased my size by moving to a smaller font to better accommodate some cloud facility output. my 2-window side-by-side size is now 91x51 (was 82x46). the 1-window size is 184x51 but i can work with the 2-window size more often, now. i do try to follow PEP008 recently, but it can be a little harder now to keep line widths under 80 or 72. it would be nice if the editor helped better in this regard.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 12,031
Threads: 485
Joined: Sep 2016
On windows you can use:
from win32api import GetSystemMetrics
Width = GetSystemMetrics(0)
Height = GetSystemMetrics(1) Not sure on Linux
Posts: 4,647
Threads: 1,494
Joined: Sep 2016
(May-11-2017, 03:34 AM)Larz60+ Wrote: On windows you can use:
from win32api import GetSystemMetrics
Width = GetSystemMetrics(0)
Height = GetSystemMetrics(1) Not sure on Linux
what i am wanting to know is what your screen size is. and that of other people here, too.
but i do have the following code for Linux. i don't have Windows to try it on.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from __future__ import print_function
import fcntl,struct,sys,termios
def get_terminal_geometry(fd=0):
"""get current terminal geometry (width,height)"""
global width,height
try:
height,width=struct.unpack('4H',fcntl.ioctl(fd,
termios.TIOCGWINSZ,struct.pack('4H',0,0,0,0)))[:2]
except:
height,width=None,None
if height==None:
try:
fd=os.open('/dev/tty',os.O_WRONLY)
height,width=struct.unpack('4H',fcntl.ioctl(fd,
termios.TIOCGWINSZ,struct.pack('4H',0,0,0,0)))[:2]
os.close(fd)
del fd
except:
height,width=None,None
return (width,height)
width,height=0,0
get_terminal_geometry(0)
def main(args):
"""command to output terminal geometry"""
get_terminal_geometry()
print(repr(width),'x',repr(height))
return 0
if __name__ == '__main__':
try:
result=main(sys.argv)
sys.stdout.flush()
except BrokenPipeError:
result=99
except KeyboardInterrupt:
print('')
result=98
if result is 0 or result is None or result is True:
exit(0)
if result is 1 or result is False:
exit(1)
if isinstance(result,str):
print(result,file=sys.stderr)
exit(2)
try:
exit(int(result))
except ValueError:
print(str(result),file=sys.stderr)
exit(3)
except TypeError:
exit(4)
# EOF the above is usable as a command or i can do stty -a to get the geometry info and lots more.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 687
Threads: 37
Joined: Sep 2016
May-11-2017, 12:33 PM
(This post was last modified: May-11-2017, 12:33 PM by Ofnuts.)
My usual editor or terminal windows are around 132 chars wide (my screen would allow about twice that).
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Posts: 2,953
Threads: 48
Joined: Sep 2016
Posts: 7,320
Threads: 123
Joined: Sep 2016
No size set,have set guide line at 93 character in Atom.
I agree with Raymond Hettinger' talk " Beyond pep-8",that sometime can 90'ish be okay.
This is if it's unnatural to break a line to get down to 79 characters.
A link to the new CSS styled PEP-8 bye Kenneth Reitz,
for those that have not seen it yet.
Posts: 2,953
Threads: 48
Joined: Sep 2016
Actually, I don't care too much how long the line will be.
I will not sacrifice the readability for some rules.
Posts: 4,647
Threads: 1,494
Joined: Sep 2016
May-12-2017, 09:00 AM
(This post was last modified: May-12-2017, 09:13 AM by Skaperen.)
(May-11-2017, 07:26 PM)wavic Wrote: Actually, I don't care too much how long the line will be.
I will not sacrifice the readability for some rules.
there is that bit about "A Foolish Consistency is the Hobgoblin of Little Minds" which gives 4 "good reasons to ignore a particular guideline". i have been experimenting lately with regard to readability and long lines. i have much code going each way.
(May-11-2017, 12:33 PM)Ofnuts Wrote: My usual editor or terminal windows are around 132 chars wide (my screen would allow about twice that).
so your screen is in the range of 264+ ... enough to have 3 windows wide at the size of 80 characters wide or a bit more.
FYI, i use a script named "e" to start editing a file. it unsets the DISPLAY environment variable so the editor operates in the shell terminal window. i do this for consistency across many ssh sessions.
my "e" script make a backup each time i use it. actually that is done per-file since it supports multiple files per command.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 12,031
Threads: 485
Joined: Sep 2016
May-23-2017, 12:23 PM
(This post was last modified: May-23-2017, 12:23 PM by Larz60+.)
Quote:but i do have the following code for Linux. i don't have Windows to try it on.
This is a bit late, but found this package which works on windows, cygwin, X11, and osx the package was posted last month
from screeninfo import get_monitors on windows 7 I use it as follows
m = str(get_monitors()[0])
m1 = re.sub("[x+]", ',', str(m[m.index('(') + 1:].strip(')'))).split(',')
# list also has offsets in m1[2] and m1[3]
self.screen_width = int(m1[0])
self.screen_height = int(m1[1])
print('self.screen_width: {}, self.screen_height: {}'
.format(self.screen_width, self.screen_height)) result:
Output: self.screen_width: 1920, self.screen_height: 1080
This was
Posts: 1,298
Threads: 38
Joined: Sep 2016
I also do not have a set size. When playing with Python I might, at most have four apps open: cmd terminal, IDE, browser and notepad++. The terminal fits nicely above notepad++, IDE in the middle and browser at the far right.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
|