Developing small "helper" programs?

Forum Forums antiX-development Development Developing small "helper" programs?

  • This topic has 12 replies, 5 voices, and was last updated May 1-12:21 am by masinick.
Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #9761
    Member
    AvatarBobC

    For example, AntiX comes with a “helper program” called wallpaper.py to select a wallpaper and maintain the config file that stores the selection.

    I couldn’t follow the code, but this led me to think that python would be a good language to create programs like that in if I understood the language.

    An example, why does it take 10 or 20 mb of memory for a volume icon program? Certainly there could be a better way, perhaps by feeding commands to amixer? That might be something I could write.

    Or to maintain IceWM configs would be as I see it a set of small programs, called from a main program, to maintain some or all of them, rather than editing all in Geany. I did find a program called ice-pref but it was wildly complex, and I read it doesn’t work anymore, and doesn’t appear to be maintained currently, and isn’t in the repos.

    Another is the text editor selection. I forget where that gets set, but it always causes me trouble.

    Yes, I know they aren’t necessary, as they can be maintained as text files, but it would be nicer, sort of like the difference between asking someone to maintain a theme file by editing text in a file vs having dialogs that try to make it easy for someone to make the changes easily and correctly.

    So, is Python the best language for this kind of thing? Would it be reasonable to use Glade or something like it to write the code or some other way? I see gnome-ppp and wicd-gtk already bring in some glade stuff, as the amount and number of dependencies something brings with it would be important to minimize.

    Could someone point me to a good resource or examples that would help me learn to create small config file maintenance programs with, or is this an unreasonable idea?

    #9762
    Forum Admin
    DaveDave

    Two pages that I have readily bookmarked for pygtk front-ends
    https://python-gtk-3-tutorial.readthedocs.io/en/latest/
    And
    https://developer.gnome.org/gtk3/

    The backends that do most of the settings with what I wrote in the past is done with bash.

    Example:
    Wallpaper.py is a gui to set the config.
    desktop-session-wallpaper is what reads the configs and sets the wallpaper.

    Computers are like air conditioners. They work fine until you start opening Windows. ~Author Unknown

    #9764
    Forum Admin
    anticapitalistaanticapitalista

    volumeicon is gtk3 which is why it uses more RAM, and also why we replaced with a gtk2 version -legacy that uses only a third of the RAM that the gtk3 one uses.

    Philosophers have interpreted the world in many ways; the point is to change it.

    antiX with runit - leaner and meaner.

    #9771
    Member
    AvatarBobC

    I can see there is a lot there I don’t know. It looks like I need to get a fundamental understanding of Python first. Thanks for the links 🙂

    • This reply was modified 2 years, 3 months ago by BobC.
    #9773
    Member
    AvatarBobC

    Anti, Yes, I see its now down to 12.5 mb on my stock AntiX 17.1 Full system, so it has come down a lot.

    #9779
    Moderator
    masinickmasinick

    @BobC: I think that you are doing a pretty good job learning new things – it’s fun – maybe not at first – but QUITE satisfying when you finally figure something out and can then say something like: “So THAT’S how it works!”

    Keep up the interest – and the good work!

    Brian Masinick

    #9783
    Member
    AvatarBobC

    Brian, Thanks for the encouragement. I haven’t given up, I just need to be careful to make sure I understand how and why code works before I try to imitate it and change it into something else.

    One of these days I’ll find an example that makes complete sense to me, and then things will be much easier to understand.

    #9799
    Moderator
    masinickmasinick

    Take a peek at some of the files in the hidden directories beneath .config. Most of them are reasonable to figure out, and the more opportunity you have to look at them (asking questions as needed), the more you will learn until you will be able to help others more often. Keep at it, you are making good progress!

    Brian Masinick

    #9800
    Member
    AvatarBobC

    LOL, I wasn’t very clear there. I’m fine with digging in config files (wherever they might be) and changing settings and such.

    As for hard to understand, its the Python language, with its classes and subclasses and methods, and everything being called from someplace I don’t know, I think, that cause the programs to not be easy to read and understand. Of course if I was used to that, it would be understandable. I’m used to old style code, I guess. It doesn’t mean that I can’t learn new things, it just means I have to learn new things to use that language.

    The glade screens took a lot of that problem away, or at least in the demos it did.

    #9802
    Moderator
    masinickmasinick

    If you are looking at Python code (or any code, for that matter) check to see if you can locate the source code for any libraries that are included (usually at or near the top of a program or a module). Once you can locate all of the routines, you can get an idea what they do. If the program is well written with nicely descriptive names, you may get at least a high level understanding that a certain module does whatever the name of the procedure suggests. But to truly understand it completely, you will want to see what is being passed to the procedure and what the procedure returns back as its output. Once you figure that out, you’ll have a better idea what’s going on. The more you want to understand, the more you’ll have to investigate. Over time, however, you may be able to better deduce what’s going on.

    LOL, I wasn’t very clear there. I’m fine with digging in config files (wherever they might be) and changing settings and such.
    As for hard to understand, its the Python language, with its classes and subclasses and methods, and everything being called from someplace I don’t know, I think, that cause the programs to not be easy to read and understand. Of course if I was used to that, it would be understandable. I’m used to old style code, I guess. It doesn’t mean that I can’t learn new things, it just means I have to learn new things to use that language.

    The glade screens took a lot of that problem away, or at least in the demos it did.

    Brian Masinick

    #9806
    Member
    Avatar736b69646f6f

    why does it take 10 or 20 mb of memory for a volume icon program

    Invoking a new bash shell (e.g. via .desktop launcher) to run a commandline “costs” 4MB+

    Launching a cookbook “Hello world” program brings about 20MB overhead from the stock python libraries.

    Launching a GUI program adds the overhead from loading the graphical toolkit libraries.
    If proggie can display jpgs, even if you might not do so during this run, this session, the prog must load libjpg, or equivalent, “just in case”.

    Would it be reasonable to use Glade or something like it to write the code

    glade
    is a “designer” tool ~~ it’s stocked with drag-n-drop toolkit widgets (ala Lego bricks).
    You drag from a picklist onto a working pane, then drag/resize and reposition and adjust padding and layout.
    By right-clicking the various placed widgets (bricks), you can supply values for the various “properties” of the widget.
    (Each widget will have a default size, color, font, padding… you’re not forced to touch/tweak every detail.)
    After creating a UI in glade, it can be “connected to” your choice of backend program language, typically C, C++, or python.
    Glade isn’t necessary and, IMO, adds difficulty to learning curve for new programmers.

    Many of the antiX utilities are bash scripts which employ “yad” or “gtkdialog” for the UI aspect of the program.
    bash + xdialog, or bash + ncurses is probably the only “lighter” alternative (lighter, and less flexible, and butt-ugly)

    good resource or examples that would help me learn

    The powers-that-be have tanked the pygtk.org site (gtk2 is “deprecated” doncthaknow)
    but https://github.com/GNOME/pygtk
    you can download and refer to a local copy of the gtk2 docs (useful when you’re tweaking or reverse-engineering older python+gtk programs)
    For gtk3, the links Dave posted are the “official” docs. Helpful toward understanding the API, but need to look elsewhere for walkthrough tutorials.

    For gtkdialog, and yad examples / tips, check the puppy (murgalinux.com) forums. IIRC, the yad github repo also has a wiki.

    #9811
    Member
    AvatarBobC

    Yes, I’ve seen some of the gtkdialog and yad code. I do understand at least some of that. I found another called tcl that looked useful, and included in AntiX. The one thing I learned tonight is that if you don’t search well enough, you end up reinventing the wheel.

    Maybe I’ll just write a small script that makes me a cheat sheet of the IceWM key assignments, not sure what to sort by, and get it to pop up on demand somewhow, but lol, that probably already exists, too 🙂

    PS: Thanks to everyone for being helpful. I don’t pretend to know all that much here, sometimes it shows, I guess

    • This reply was modified 2 years, 3 months ago by BobC.
    #9813
    Moderator
    masinickmasinick

    “Reinventing the wheel” is fine. You don’t always end up with a better wheel, but you can learn. Every once in a while, sometimes often, others not, real innovation or a great new alternative emerges.

    Look at antiX. It started as a light alternative to MEPIS as its parent grew in size. An offshoot of antiX, MX, has replaced MEPIS since MEPIS development ceased. Who knows what may emerge next as experiments and learning take place? At the very least we have fun and meet new people. At best, more ideas and different approaches emerge.

    Brian Masinick

Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.