[SOLVED] seeking GUI apps & utils written in python

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
User avatar
SaintDanBert
Level 4
Level 4
Posts: 449
Joined: Sat Feb 20, 2010 4:04 pm
Location: Covington, LA USA

[SOLVED] seeking GUI apps & utils written in python

Post by SaintDanBert »

Colleagues,
Will someone direct me to GUI-based apps and utilities that are written in python and part of Linux Mint 18 or later? Alternately, is there some way to detect that some installed app or utility is python-based with some sort of command line inspection?

I would fetch the source package and start reading. I might even borrow parts of the package to start my own project. I would hope to find packages that include mainstream Linux Mint desktop {I use Cinnamon} compatible GUI programming along with contemporary object oriented design. In addition to leaning how to implement and document a reasonable user experience, I need to discover how to do many of the things that I'm used to doing with bash shell scripts. Lastly, I hope to learn effective ways to manage structured data, log files, and such.

I've been coding in C, C++, and Bourne/BASH shell since 80s. Now that I'm retired, I've started teaching myself python. I try to learn good coding by reading, er, "good code." This has worked for me over the years so I'm prone to continue that effort.

Thanks in advance,
~~~ 0;-Dan
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
gm10

Re: seeking GUI apps & utils written in python

Post by gm10 »

Behold the wonders of GitHub: ;)
https://github.com/linuxmint?language=python

Although I wouldn't necessarily call all of Mint's Python "good code" - or at least not up to date code. Also some of the performance-relevant quirks about Python are not self-evident from reading the code. The rest is easy to learn though. I taught myself Python last year to mess around with Mint's code, based on an experience with mostly C-dialects as well. The language was trivial to pick up, and the online documentation is quite good. Speaking of documentation, I just love this site https://learnxinyminutes.com/docs/python3/ to get a quick overview over a programming language's structure.
User avatar
SaintDanBert
Level 4
Level 4
Posts: 449
Joined: Sat Feb 20, 2010 4:04 pm
Location: Covington, LA USA

Re: seeking GUI apps & utils written in python

Post by SaintDanBert »

gm10 wrote: Thu Jul 04, 2019 11:24 am Behold the wonders of GitHub: ;)
https://github.com/linuxmint?language=python
I will check this out. I've not made the move to 'git'. I'm still a CVS & Emacs guy. Of course my projects are now "just me." I plan to explore subversion and git and friends while I'm re-learning. I welcome your suggestions for a python development environment and workflow
gm10 wrote: Thu Jul 04, 2019 11:24 am Although I wouldn't necessarily call all of Mint's Python "good code" - or at least not up to date code. Also some of the performance-relevant quirks about Python are not self-evident from reading the code. The rest is easy to learn though. I taught myself Python last year to mess around with Mint's code, based on an experience with mostly C-dialects as well. The language was trivial to pick up, and the online documentation is quite good. Speaking of documentation, I just love this site https://learnxinyminutes.com/docs/python3/ to get a quick overview over a programming language's structure.
As with learning any "language" it is the use of "idioms" and "slang" that can make things very difficult. It also separates a "native speaker" from a "tourist." Once I got beyond the tab formatting challenge (very foreign to a C/C++ guy) coding came very quickly. As a long-time user of Linux Mint, I want to learn "Mint-style", "Mint-convention", and appropriate implementation idioms. What is common practice for:
  • embedded documentation
  • unit testing
  • object oriented design and implementation
  • available "package"/"module"/"component" use
  • deployment of "components" that I've built -- for one app; for multiple apps
  • patches and updates to what I've built
  • distribution of my app/util to others
I'm reminded of something that my Comp-Sci professors said:
"Working code often makes for an effective specification."

Thanks for the reply,
~~~ 0;-Dan
User avatar
Flemur
Level 20
Level 20
Posts: 10096
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: seeking GUI apps & utils written in python

Post by Flemur »

I'm pretty sure almost all (some as bash) the "mintXXX" programs are written in python:
$ W mint

Code: Select all

mint-release-upgrade
mint-release-upgrade-root
mint-remove-application
mint-switch-to-local-mirror
mint-xfce-delete
mintbackup
mintinstall
mintinstall-fp-handler
mintinstall-remove-app
mintinstall-update-flatpak
mintinstall-update-pkgcache
mintlocale
mintlocale-im
mintreport
mintstick
mintupdate
mintupdate-cli
mintupdate-disable-auto-updates
mintupdate-enable-auto-updates
mintupdate-launcher
mintupdate-tool
mintwelcome
mintwelcome-launcher
sha256sum-mint
Then you can see each one with something like

Code: Select all

vi `which mint-release-upgrade`
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
gm10

Re: seeking GUI apps & utils written in python

Post by gm10 »

SaintDanBert wrote: Thu Jul 04, 2019 12:09 pm I will check this out. I've not made the move to 'git'. I'm still a CVS & Emacs guy. Of course my projects are now "just me." I plan to explore subversion and git and friends while I'm re-learning. I welcome your suggestions for a python development environment and workflow
You will have to learn git if you want to do open source in general and Mint in particular, there's no way around it. It's far more powerful than svn though once you get the hang of it. For a development environment everybody has their own preference. Personally I've always been using Microsoft's Visual Studio Code as the code editor (it's got great extensions for simplifying your work with git, too), whereas most of the team still uses Sublime I believe.
SaintDanBert wrote: Thu Jul 04, 2019 12:09 pm As with learning any "language" it is the use of "idioms" and "slang" that can make things very difficult. It also separates a "native speaker" from a "tourist." Once I got beyond the tab formatting challenge (very foreign to a C/C++ guy) coding came very quickly.
For me dropping the semi-colon came harder than using the tabs (or rather not using the curly brackets). ;)

Mint's coding style guidelines are here: https://linuxmint-developer-guide.readt ... ding-style although personally I'd say try to write the best Python you can no matter what's currently in use in Mint. I know the style of the code I contributed was in parts quite different from what was originally there, and that despite trying to "fit" into the existing code base already (my personal style differs quite a bit in structure actually, I prefer splitting a project into several modules and files - see my version of mintupdate in my PPA vs the offical release version, for example -- the lack of OOP in some parts of that app is deplorable, by the way, certainly something that should be improved upon rather than imitated IMHO).
SaintDanBert wrote: Thu Jul 04, 2019 12:09 pm [*]available "package"/"module"/"component" use
The only shared python module is the mint-common package, which I extended and turned into separate sub-modules for 19.2 (the changelog module in there was actually the first python project I ever wrote - to teach me the language ;)).
SaintDanBert wrote: Thu Jul 04, 2019 12:09 pm [*]deployment of "components" that I've built -- for one app; for multiple apps
[*]patches and updates to what I've built
[*]distribution of my app/util to others
This really depends on what you are planning to do, i.e. if you're planning to contribute to the project or just do your own thing within the project's environment. If you want to contribute to and deploy with official Mint then join their communication channels and discuss it with Clem. Otherwise you are free to do whatever you want - since we're Ubuntu based you can just pop up a PPA for free and do it that way just like I'm currently doing.
User avatar
murray
Level 5
Level 5
Posts: 784
Joined: Tue Nov 27, 2018 4:22 pm
Location: Auckland, New Zealand

Re: seeking GUI apps & utils written in python

Post by murray »

SaintDanBert wrote: Thu Jul 04, 2019 12:09 pm Once I got beyond the tab formatting challenge (very foreign to a C/C++ guy) coding came very quickly.
I've only dabbled with Python because I find the whole indenting thing really hard to get over. Reminds me of COBOL and FORTRAN (although not as bad) where certain things had to start in certain columns. I know I just need to accept it if I want to use Python but still...

Like gm10 I really like Microsoft's Visual Studio Code editor. It has built-in support for Git, although I haven't used that part of it yet.
Running Mint 19.3 Cinnamon on an Intel NUC8i5BEH with 16GB RAM and 500GB SSD
User avatar
SaintDanBert
Level 4
Level 4
Posts: 449
Joined: Sat Feb 20, 2010 4:04 pm
Location: Covington, LA USA

Re: seeking GUI apps & utils written in python

Post by SaintDanBert »

Flemur wrote: Thu Jul 04, 2019 12:20 pm I'm pretty sure almost all (some as bash) the "mintXXX" programs are written in python:
$ W mint
Thanks for this approach!

I was able to use find to locate a group of "mint*" files.
I then used file {filename} to locate those that were python scripts. file /usr/bin/mintupdate
/usr/bin/mintupdate: Python script, ASCII text executable

Code: Select all

prompt$   file /usr/bin/mintupdate
/usr/bin/mintupdate: Python script, ASCII text executable
For example, '/usr/bin/mintupdate' looked like this:

Code: Select all

#!/usr/bin/python3
import os
import subprocess
import argparse
if __name__ == "__main__":
    # Parse arguments
    parser = argparse.ArgumentParser(prog="mintupdate", description="The Linux Mint Update Manager")
    parser.add_argument("-v", "--version", action="version", version=subprocess.getoutput("/usr/lib/linuxmint/common/version.py mintupdate"), help="Display the current version")
    
    args = parser.parse_args()
    
    command = "/usr/lib/linuxmint/mintUpdate/mintUpdate.py show &"
    os.system(command)
# end
I was then able to inspect that real application /usr/lib/linuxmint/mintUpdate/mintUpdate.py

Rinse & Repeat

In the process of reading these python files, my first "lesson" involved learning what all of these do and where they come from:

Code: Select all


import os	
import sys
import gi
import tempfile
import threading
import time
import gettext
import io
import json
import tarfile
import urllib.request
import proxygsettings
import subprocess
import pycurl
import datetime
import configparser
import traceback
import setproctitle

The fun begins ... in earnest,
~~~ 0;-Dan
User avatar
Flemur
Level 20
Level 20
Posts: 10096
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: seeking GUI apps & utils written in python

Post by Flemur »

SaintDanBert wrote: Fri Jul 05, 2019 12:02 pm
Flemur wrote: Thu Jul 04, 2019 12:20 pm I'm pretty sure almost all (some as bash) the "mintXXX" programs are written in python:
$ W mint
Thanks for this approach!

I was able to use find to locate a group of "mint*" files.
I then used file {filename} to locate those that were python scripts. file /usr/bin/mintupdate
/usr/bin/mintupdate: Python script, ASCII text executable

Code: Select all

prompt$   file /usr/bin/mintupdate
/usr/bin/mintupdate: Python script, ASCII text executable
Here's a couple of hints -
'which' shows the path to an executable, so you can do

Code: Select all

$ file `which mintupdate`
/usr/bin/mintupdate: Python script, ASCII text executable
The 'W' command is a script I use a lot because I don't use system menus:
$ cat ~/bin/W

Code: Select all

#!/bin/bash
#
if [ $# -lt 1 ]
then
  echo Usage: `basename $0` pattern 
  exit 1
fi 
echo $PATH | sed 's/^/ls -A /' | sed 's/:/ |grep -i '$1'; ls -A /g' | sed 's/$/ |grep -i '$1'/' | bash | sort 
exit 0
It returns the executables in your $PATH which match a string you pass, e.g. show all the executables with "mint" in the name.
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
Locked

Return to “Software & Applications”