Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
basic ignorance help
#1
I am a basic Python user in Linux, and I am trying to activate the geany text editor with Python, and a preset windows size and position. The libraries confuse me for such a simple task. Help is most appreciated.

import os, subprocess
from tkinter import * 
gui_= tk_()
time.sleep(0.1)

subprocess(gui_[0], shell = false, executable="geany")

gui_.geometry("768x864")

gui_.mainloop()
Linux Mint Cinnamon 22 - Python 3.12.3 - Autokey-gtk 0.96.0 as of 2024-01-13.
Reply
#2
You do realize that geany has it's own window right?
I don't understand why you would want to open geany in a tkinter window.
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
Download my project scripts


Reply
#3
I would try something like
import subprocess as sp
sp.Popen("geany --geometry=768x864+200+100  </dev/null >/dev/null 2>&1 &", shell=True)
« We can solve any problem by introducing an extra level of indirection »
Reply
#4
Do you realize that Geany has its window right?
I don't understand why you want to open geany in a Tkinter window.
buran write Oct-01-2024, 12:56 PM:
Clickbait linked removed
Reply
#5
(Oct-01-2024, 05:22 AM)menator01 Wrote: You do realize that geany has it's own window right?
I don't understand why you would want to open geany in a tkinter window.

This would give a user the ability to open a 2nd Geany window with a <=72 column automatic text line wrap. Geany can only wrap paragraph text automatically to the window size. The settings came from the width of the 72 column line indicator available in Geany. This is discussed on Geany's site, which may shed light on topics of my interests. Geany is 80% code editor, and 20% general text editor. Its limitation is the lack of contributing coders. For my minimal scripting, any editor is OK, but for text I would rather adapt to Geany for all my needs. P.S: I tried every other Linux editor! But, for serious manipulation of paragraphs for Wikipedia text databases, I still use a Windows app TextPad, in Wine.
   
Linux Mint Cinnamon 22 - Python 3.12.3 - Autokey-gtk 0.96.0 as of 2024-01-13.
Reply
#6
Unfortunately, subprocess.Popen(["geany"]) works fine but subprocess.Popen(["geany" --geometry=768x864]) doesn't because geany has no geometry property.
Linux Mint Cinnamon 22 - Python 3.12.3 - Autokey-gtk 0.96.0 as of 2024-01-13.
Reply
#7
(Oct-04-2024, 02:26 AM)ineuw Wrote: Unfortunately, subprocess.Popen(["geany"]) works fine but subprocess.Popen(["geany" --geometry=768x864]) doesn't because geany has no geometry property.
What you could do is start Geany first, then use the wmctrl command to change the size of the window (this can be done only after the Geany window has appeared)
Output:
wmctrl -r Geany -e 0,-1,-1,768,864
In Ubuntu you can install wmctrl with sudo apt install wmctrl.

An alternative to using wmctrl is the Python module ewmh which I use every day to tidy up my desktop automatically.

In order to change the number of 72 columns wrap, I think you need to update the geany.conf file, probably the line_break_column option. Also note that by playing with the -c or --config option of the geany command, you can maintain and use simultaneously several geany.conf files.

EDIT: I asked chatgpt and it found the same solution!
Output:
geany & sleep 0.5 && wmctrl -r "Geany" -e 0,100,100,800,600
and also
Output:
geany & sleep 0.5 && xdotool search --name "Geany" windowsize 800 600
« We can solve any problem by introducing an extra level of indirection »
Reply
#8
(Oct-07-2024, 06:31 PM)mojobadshah Wrote: I'd suggest skipping the tkinter part if all you're doing is launching Geany with a specific window size and position. You can use subprocess to open Geany directly and pass in the geometry settings with a command.
import subprocess

subprocess.Popen(["geany", "--geometry=768x864+100+100"])
This way, you're not overcomplicating things with tkinter. You just launch Geany, and the geometry option should handle the window size and position.

@mojobadshah thanks for your reply. That is what I did, but Geany has no "--geometry" option, so I researched other possibilities. I read up on X-lib to create an empty window, and then open Geany in it, but that is beyond my knowledge level and available time.

Using wmctrl -r :ACTIVE: -e 0,0,0,768,796 works, provided the existing window in not opened to it's maximum width and height. wmctrl, or Python, cannot reduce a fully opened window.
Linux Mint Cinnamon 22 - Python 3.12.3 - Autokey-gtk 0.96.0 as of 2024-01-13.
Reply
#9
(Oct-10-2024, 04:06 AM)ineuw Wrote: wmctrl, or Python, cannot reduce a fully opened window.
Have you tried using the ewmh module? It gives a good control on the windows.
« We can solve any problem by introducing an extra level of indirection »
Reply


Forum Jump:

User Panel Messages

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