Larger window


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Larger window
# 1  
Old 08-02-2018
Larger window

I would like the window that this opens to be larger.
Can it be modified to do so?

Thanks.

Code:
#!/usr/bin/env python3
# Text snippets are in /home/andy/.config/snippet_paste/
import os
import subprocess

home = os.environ["HOME"]
directory = home+"/.config/snippet_paste"
if not os.path.exists(directory):
    os.mkdir(directory)
# create file list with snippets
files = [
    directory+"/"+item for item in os.listdir(directory) \
         if not item.endswith("~") and not item.startswith(".")
    ]
# create string list
strings = []
for file in files:
    with open(file) as src:
        strings.append(src.read())
# create list to display in option menu
list_items = ["manage snippets"]+[
    (str(i+1)+". "+strings[i].replace("\n", " ").replace\
     ('"', "'")[:20]+"..") for i in range(len(strings))
    ]
# define (zenity) option menu
test= 'zenity --list '+'"'+('" "')\
      .join(list_items)+'"'\
      +' --column="text fragments" --title="Paste snippets Ctrl V"'
# process user input
try:
    choice = subprocess.check_output(["/bin/bash", "-c", test]).decode("utf-8")
    if "manage snippets" in choice:
# My current file manager goes after call([
        subprocess.call(["thunar", directory])
    else:
        i = int(choice[:choice.find(".")])
        # copy the content of corresponding snippet
        copy = "xclip -in -selection c "+"'"+files[i-1]+"'"
        subprocess.call(["/bin/bash", "-c", copy])
        # paste into open frontmost file
        paste = "xdotool key Control_L+v"
        subprocess.Popen(["/bin/bash", "-c", paste])
except Exception:
    pass

# 2  
Old 08-02-2018
Yes it can, but only to the better terminals:
I wrote this 6 years ago, and it was voted up:
A DEMO To Show How To Expand A Standard Python Terminal On The Fly... << Python recipes << ActiveState Code
The crucial piece is this:
Code:
import sys
row=40
column=120
junk=sys.stdout.write("\x1b[8;{rows};{cols}t".format(rows=row,cols=column))

Read the above URL to see how it works.
To eliminate the string length being displayed inside STDERR in later versions of python 3.x just dump it into a junk variable.
This still works as of version 3.5.2 which is the highest I have got.

EDIT:
I wrote this too which might be of use to you and was voted up very highly:
A DEMO to show how to write text into the Python terminal Title Bar... << Python recipes << ActiveState Code

Last edited by wisecracker; 08-02-2018 at 07:29 PM.. Reason: See above.
# 3  
Old 08-02-2018
This is what I have now. Not working.
Code:
#!/usr/bin/env python3

import os
import subprocess
# added 8/2/18
import sys
row=40
column=120
junk=sys.stdout.write("\x1b[8;{rows};{cols}t".format(rows=row,cols=column))
#
home = os.environ["HOME"]
directory = home+"/.config/snippet_paste"
if not os.path.exists(directory):
    os.mkdir(directory)
# create file list with snippets
files = [
    directory+"/"+item for item in os.listdir(directory) \
         if not item.endswith("~") and not item.startswith(".")
    ]
# create string list
strings = []
for file in files:
    with open(file) as src:
        strings.append(src.read())
# create list to display in option menu
list_items = ["manage snippets"]+[
    (str(i+1)+". "+strings[i].replace("\n", " ").replace\
     ('"', "'")[:20]+"..") for i in range(len(strings))
    ]
# define (zenity) option menu
test= 'zenity --list '+'"'+('" "')\
      .join(list_items)+'"'\
      +' --column="text fragments" --title="Paste snippets Ctrl V"'
# process user input
try:
    choice = subprocess.check_output(["/bin/bash", "-c", test]).decode("utf-8")
    if "manage snippets" in choice:
        subprocess.call(["thunar", directory])
    else:
        i = int(choice[:choice.find(".")])
        # copy the content of corresponding snippet
        copy = "xclip -in -selection c "+"'"+files[i-1]+"'"
        subprocess.call(["/bin/bash", "-c", copy])
        # paste into open frontmost file
        paste = "xdotool key Control_L+v"
        subprocess.Popen(["/bin/bash", "-c", paste])
except Exception:
    pass

# 4  
Old 08-03-2018
Did you read the very first line of my post?

if so, then your terminal has not got the ability to be expanded on the fly.

The two images show those four lines in action on a terminal that can.
In this case on OSX 10.13.6, default bash terminal and exactly the same on xterm and others. (In this particular case calling python 3.5.x.)

Note the size in the title bar...
Larger window-expand1jpeg
Larger window-expand2jpeg

Last edited by wisecracker; 08-03-2018 at 03:40 AM..
# 5  
Old 08-03-2018
Thanks.

I prefer to keep my Mate-Terminal.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Toggle between xterm window and standard terminal window

Is it possible to toggle back and forth between an xterm invoked from one tty, and a shell invoked from a different tty? I am running Centos 7 with KDE and booting in non-graphic mode. After logging in on the default window (/dev/tty1) , I can then use ALT-F2 to access a new window (/dev/tty2),... (1 Reply)
Discussion started by: rhgscty
1 Replies

2. Shell Programming and Scripting

Output Row if Third Column is Larger

Hi, I am fairly new to Unix scripting. We are running Solaris 5.10. I have the following question: Assume a text file with one text column, followed by 2 integer columns. How would I generate a script or, preferably, a command that will output the rows in which the value of the third... (6 Replies)
Discussion started by: QZ1
6 Replies

3. AIX

Tar files larger than 2GB

Hi, Does anyone know if it is possible to tar files larger than 2GB? The reason being is they want me to dump a single file (which is around 20GB) to a tape drive and they will restore it on a Solaris box. I know the tar have a limitation of 2GB so I am thinking of a way how to overcome this.... (11 Replies)
Discussion started by: depam
11 Replies

4. Shell Programming and Scripting

How to initialize array with a larger number?

Language: ksh OS: SunOS I have been getting the 'subscript out of range' error when the below array variable gets elements greater that 1024. I understand that 1024 is the default size for 'set -A' dynamic array, but is there a way to initialize it with a larger number? set -A arr `grep... (6 Replies)
Discussion started by: ChicagoBlues
6 Replies

5. Red Hat

Maximizing X window without Window Switcher

Hi everyone! I have a strange situation. I'm running an NX remote Gnome desktop session. On the remote machine, there is a whole load of unsaved data in a window. A problem that I've been having with this NX session is that I can't load Gnome Applets, including the Window Switcher. So.. when I... (0 Replies)
Discussion started by: alexandicity
0 Replies

6. Shell Programming and Scripting

using grep for find values larger/less than

Hi I have been experimenting with grep to find values for a particular column that is greater than or less than certain #'s. So my file looks like this: name -2 2 name1 -2 2 name2 -1 4 name3 3 3 So I want to find rows with values less than or equal to -2 and those greater than... (5 Replies)
Discussion started by: phil_heath
5 Replies

7. Shell Programming and Scripting

Grab a smaller and larger value

Hi All, I am trying to grab a term which is just smaller and larger than the assigned value using the below code. But there seems to be some problem. The value i assign is 25 so i would expect it to output a smaller value to be 20 instead of 10 and 20 and larger value to be 30 instead of 30 and... (3 Replies)
Discussion started by: Raynon
3 Replies

8. UNIX for Advanced & Expert Users

sending larger files via ftp

hi all, i am looking for ways to make ftp efficient by tuning the parameters currently, tcp_max_buf is 1 MB tcp_xmit_hiwat is 48 KB say to transmit multiple 2 gb files from unix server to mainframe sys, will increasing the window size or the send buffer size of the current TCP/IP... (6 Replies)
Discussion started by: matrixmadhan
6 Replies

9. Solaris

Upgrading To Larger Disk?

I have just been assigned the task of upgrading to a larger disk on a e250; however, I am use to working on Linux and x86 hardware. I would be very appreciative if someone could inform me on how this procedure can be done safely. To begin with, the e250 has a 18 Gig primary scsi disk and a 18... (3 Replies)
Discussion started by: cstovall
3 Replies

10. Windows & DOS: Issues & Discussions

window 2000 professional not pinging my window 98 system.

Hello, We someone help me resolve this problem. I have window 2000 professional, windows 98 and Unixware 7.0.1 on the network. I was able to establish connection with all. However, l was unable to ping window 98 from window 2000 professional. I was able to ping the window 2000 from the window... (10 Replies)
Discussion started by: kayode
10 Replies
Login or Register to Ask a Question