• Quick note - the problem with Youtube videos not embedding on the forum appears to have been fixed, thanks to ZiprHead. If you do still see problems let me know.

Linux GUI programming help - Python?

ChrisC

Critical Thinker
Joined
Dec 27, 2005
Messages
466
Hi all,

I don't know jack about programming, with the exception of QBasic which I've almost entirely forgotten. What I'd like to do is write a really tiny, simple, single-window program to calculate delay times. It would have a box to enter a number for BPM (say, .1 to 1000*), another box to enter a number for divisions (.1 to 256 perhaps), and a box to print the output of the equation "(240000/box1)/box2". Right now, I just use a spreadsheet which works fine but it would be nice to have a little floating window that takes up no space and few resources. Python looked like a decent bet since I understand is reasonably easy to use and I already have it ready to go on this machine. Anyone able to point me in the right direction or give me a chunk of code to experiment with?

Thanks!

* I realise the that the numbers seem insane for the application but I like the flexibility for experimentation. Sometimes I want a delay length of 1 / 3.2152 of a bar which will be played back at 704.8 BPM. ;)
 
Python is one language that I have never tried. I just wrote a whole bunch of code for GUIs but it was all in Matlab. I don't think that would be very helpful.
 
You can use wxPython for the GUI. That makes it relatively easy and portable, though it's still some work to set up an app with a window, get the box sizes how you want them, handle events, etc.

Personally, even though I'm well-versed in wxPython, I'd stick with the spreadsheet for this. I usually have it running anyway for other uses.
 
This is a very simple application in terms of calculation.

I would suggest not using Python. It's a great language, but you're going to go through some aggravation for the user interface. Instead, I'd look at something that easily makes user interfaces.

If you are using a PC, I'd suggest a free version of Visual Studio using C#. It makes it very easy to put together a simple user interface. C# is a real language, but for your purposes it should be as easy as using a form of BASIC.
 
I used Glade to design the GUI for the one and only Linux application I ever programmed. I thought it was pretty easy.
 
Thanks for all the replies. The issue with using the spreadsheet is that I've got to run a piece of software that doesn't stay out of my way physically and takes precious resources away from the audio software I'm running. Truth be told, it's not really that a big deal but I like the idea of a tiny little app that just does this particular job in the corner of my desktop. I also worry about something going wonky with my complicated spreadsheet software and causing a recording to get screwed up.

Maybe it's not worth the effort, though. I have a tendency to overcomplicate things. Wasn't planning to make it pretty or worth using for anyone else, just a bare bones, single-function calculator. In fact, I've got a TI-83 in front of me that will remove the software component from my PC entirely. I'll have a look at Glade anyway since I like tinkering with stuff.

Thanks again!
 
I can't help you regarding Python as I don't use it, although I understand that it's well regarded.

If you end up going down the route of using C# (as suggested), this only took a minute to generate;

http://imageshack.us/photo/my-images/339/codeaz.jpg/

I couldn't preview it - I've used up my monthly data and am at dialup speed! :blush:

Code used,

Code:
double bpm = Convert.ToDouble(tbxBpm.Text.ToString());
double divisions = Convert.ToDouble(tbxDivisions.Text.ToString());
double result = (240000 / bpm) / divisions;
tbxResult.Text = result.ToString("#.#");

Autocomplete does most of the work; the rest is just sizing the window, and drag/dropping the textboxes and button and modifying a couple of properties (e.g. textbox names, readonly attributes etc.)
 
Last edited:
Hi all,

I don't know jack about programming, with the exception of QBasic which I've almost entirely forgotten. What I'd like to do is write a really tiny, simple, single-window program to calculate delay times. It would have a box to enter a number for BPM (say, .1 to 1000*), another box to enter a number for divisions (.1 to 256 perhaps), and a box to print the output of the equation "(240000/box1)/box2". Right now, I just use a spreadsheet which works fine but it would be nice to have a little floating window that takes up no space and few resources. Python looked like a decent bet since I understand is reasonably easy to use and I already have it ready to go on this machine. Anyone able to point me in the right direction or give me a chunk of code to experiment with?

Thanks!

* I realise the that the numbers seem insane for the application but I like the flexibility for experimentation. Sometimes I want a delay length of 1 / 3.2152 of a bar which will be played back at 704.8 BPM. ;)

I'll stop by long enough to wish ya luck, python along with ruby on rails; two languages I've never found enough time to really embrace. I'm limited to php myself, perl was an abomination.
 
I'm pretty ignorant on the system resources used, but I think this is what you need via javascript:

Code:
<html>
<script>
function calculateBeats(){

var beats = document.getElementById("bpm").value;
var division = document.getElementById("divisions").value;

document.getElementById("results").value = (240000/beats)/division;

}

</script>

<body>

BPM: <input type="text" id="bpm"/><br />
Divisions: <input type="text" id="divisions"/><br />
<input type="button" value="Calculate" onclick="calculateBeats()"/><br />
Results: <input type="text" id="results"/>

</body>
</html>

I would think a browser window would be much less resource intensive than a spread sheet, but I have no idea if it will be good enough for your needs. Let me know if you need any more help and how it works.
 

Back
Top Bottom