screen size when editing python - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: General (https://python-forum.io/forum-1.html) +--- Forum: News and Discussions (https://python-forum.io/forum-31.html) +--- Thread: screen size when editing python (/thread-3281.html) Pages:
1
2
|
screen size when editing python - Skaperen - May-11-2017 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. RE: screen size when editing python - Larz60+ - May-11-2017 On windows you can use: from win32api import GetSystemMetrics Width = GetSystemMetrics(0) Height = GetSystemMetrics(1)Not sure on Linux RE: screen size when editing python - Skaperen - May-11-2017 (May-11-2017, 03:34 AM)Larz60+ Wrote: On windows you can use: 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) # EOFthe above is usable as a command or i can do stty -a to get the geometry info and lots more.
RE: screen size when editing python - Ofnuts - May-11-2017 My usual editor or terminal windows are around 132 chars wide (my screen would allow about twice that). RE: screen size when editing python - wavic - May-11-2017 rows 59; columns 213; RE: screen size when editing python - snippsat - May-11-2017 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. RE: screen size when editing python - wavic - May-11-2017 Actually, I don't care too much how long the line will be. I will not sacrifice the readability for some rules. RE: screen size when editing python - Skaperen - May-12-2017 (May-11-2017, 07:26 PM)wavic Wrote: Actually, I don't care too much how long the line will be. 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. RE: screen size when editing python - Larz60+ - May-23-2017 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_monitorson 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: This was
RE: screen size when editing python - sparkz_alot - May-23-2017 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. |