Python Forum
screen size when editing python
Thread Rating:
  • 2 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
screen size when editing python
#1
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.
Reply
#2
On windows you can use:
from win32api import GetSystemMetrics

Width = GetSystemMetrics(0)
Height = GetSystemMetrics(1)
Not sure on Linux
Reply
#3
(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.
Reply
#4
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
Reply
#5
rows 59; columns 213;
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#6
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.
Reply
#7
Actually, I don't care too much how long the line will be.
I will not sacrifice the readability for some rules.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#8
(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.
Reply
#9
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
Reply
#10
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to create a shortcut of your python program on your phone screen (using Q3Python) Alexx 0 1,620 May-20-2020, 06:10 PM
Last Post: Alexx

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020